Skip to content

Commit dc70b65

Browse files
author
Artem Stepin
committed
refactored code ( psr7, psr17 support)
1 parent 7448a1b commit dc70b65

17 files changed

+2298
-842
lines changed

README.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,35 @@ $ php composer.phar require cloudplaydev/confluence-php-client
1919
<?php
2020
declare(strict_types=1);
2121

22-
use CloudPlayDev\ConfluenceClient\Client;
23-
use CloudPlayDev\ConfluenceClient\Curl;
24-
use CloudPlayDev\ConfluenceClient\Entity\ConfluencePage;
25-
26-
//Create and configure a curl web client
27-
$httpClient = new Curl('confluence_host_url','username','password');
28-
// $curl = new CurlTokenAuth('confluence_host_url','NjU9OTXA4NDI2MRY5OkBznOUO8YjaUF7KoOruZRXhILJ9');
22+
use CloudPlayDev\ConfluenceClient\ConfluenceClient;
23+
use CloudPlayDev\ConfluenceClient\Entity\Content as ContentEntity;
2924

3025
//Create the Confluence Client
31-
$client = new Client($httpClient);
26+
$client = new ConfluenceClient('https://url-to-conluence');
27+
28+
//authenticate with a private access token
29+
$client->authenticate('NjU2OTA4NDI2MTY5OkBznOUO8YjaUF7KoOruZRXhILJ9');
3230

33-
//Create a confluence page
34-
$page = new ConfluencePage();
31+
//Create a confluence content
32+
$page = new ContentEntity();
3533

3634
//Configure your page
37-
$page->setSpace('testSpaceKey')->setTitle('Test')->setContent('<p>test page</p>');
35+
$page->setSpace('testSpaceKey')
36+
->setTitle('Test')
37+
->setContent('<p>test page</p>');
3838

3939
//Create the page in confluence in the test space
40-
$client->createPage($page);
40+
$client->content()->create($page);
4141

4242
//Get the page we created
43-
$createdPage = $client->selectPageBy([
43+
$createdPage = $client->content()->findOneBy([
4444
'spaceKey' => 'testSpaceKey',
4545
'title' => 'Test'
4646
]);
4747

4848
//Update page content
4949
$createdPage->setContent('some new content');
50-
$client->updatePage($createdPage);
50+
$client->content()->update($createdPage);
5151

5252

5353

composer.json

+21-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "cloudplaydev/confluence-php-client",
33
"description": "Confluence API PHP Client",
4-
"version": "0.0.2",
4+
"version": "0.1.0",
55
"license": "MIT",
66
"keywords": [
77
"Atlassian",
@@ -11,10 +11,6 @@
1111
"Client"
1212
],
1313
"authors": [
14-
{
15-
"name": "Yuxiao (Shawn) Tan",
16-
"email": "[email protected]"
17-
},
1814
{
1915
"name": "Artem Stepin",
2016
"email": "[email protected]"
@@ -24,19 +20,36 @@
2420
"autoload": {
2521
"psr-4": {
2622
"CloudPlayDev\\ConfluenceClient\\": [
27-
"src/",
23+
"src/"
24+
]
25+
}
26+
},
27+
"autoload-dev": {
28+
"psr-4": {
29+
"CloudPlayDev\\Tests\\ConfluenceClient\\": [
2830
"tests/"
2931
]
3032
}
3133
},
3234
"require": {
3335
"php": "^7.4",
3436
"ext-curl": "*",
35-
"ext-json": "*"
37+
"ext-json": "*",
38+
"psr/http-message": "^1.0",
39+
"psr/http-client": "^1.0",
40+
"psr/http-client-implementation": "^1.0",
41+
"psr/http-factory": "^1.0",
42+
"php-http/httplug": "^2.0",
43+
"php-http/discovery": "^1.0",
44+
"php-http/promise": "^1.0",
45+
"php-http/client-common": "^2.0"
3646
},
3747
"require-dev": {
48+
"roave/security-advisories": "dev-latest",
3849
"phpunit/phpunit": "^9.5.5",
3950
"phpstan/phpstan": "^0.12.90",
40-
"vimeo/psalm": "^4.8"
51+
"vimeo/psalm": "^4.8",
52+
"guzzlehttp/guzzle": "^7.2",
53+
"http-interop/http-factory-guzzle": "^1.0"
4154
}
4255
}

0 commit comments

Comments
 (0)