Skip to content

Commit b0a0c11

Browse files
authored
Merge pull request #93 from akeneo/refactor-client
Prefix the client with a dedicated namespace "ApiClient"
2 parents 18d8173 + 41219fe commit b0a0c11

File tree

189 files changed

+863
-739
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+863
-739
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ If you don't have any client id, let's take a look at [this page](https://api.ak
3838

3939
require_once __DIR__ . '/vendor/autoload.php';
4040

41-
$clientBuilder = new \Akeneo\Pim\AkeneoPimClientBuilder('http://localhost/');
41+
$clientBuilder = new \Akeneo\Pim\ApiClient\AkeneoPimClientBuilder('http://localhost/');
4242
$client = $clientBuilder->buildAuthenticatedByPassword('client_id', 'secret', 'admin', 'admin');
4343
```
4444

@@ -69,7 +69,7 @@ echo $product['identifier']; // display "top"
6969
#### By getting pages
7070

7171
```php
72-
$searchBuilder = new \Akeneo\Pim\Search\SearchBuilder();
72+
$searchBuilder = new \Akeneo\Pim\ApiClient\Search\SearchBuilder();
7373
$searchBuilder->addFilter('enabled', '=', true);
7474
$searchFilters = $searchBuilder->getFilters();
7575

@@ -90,7 +90,7 @@ $firstPage = $nextPage->getPreviousPage();
9090
#### By getting a cursor
9191

9292
```php
93-
$searchBuilder = new \Akeneo\Pim\Search\SearchBuilder();
93+
$searchBuilder = new \Akeneo\Pim\ApiClient\Search\SearchBuilder();
9494
$searchBuilder->addFilter('enabled', '=', true);
9595
$searchFilters = $searchBuilder->getFilters();
9696

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
],
1212
"autoload": {
1313
"psr-4": {
14-
"Akeneo\\Pim\\": "src/"
14+
"Akeneo\\Pim\\ApiClient\\": "src/"
1515
}
1616
},
1717
"autoload-dev": {
1818
"psr-4": {
19-
"Akeneo\\Pim\\tests\\": "tests/"
19+
"Akeneo\\Pim\\ApiClient\\tests\\": "tests/"
2020
}
2121
},
2222
"require": {

phpspec.yml.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## Rename this file in phpspec.yml to customize the phpspec configuration
22
suites:
33
AkeneoPimClient:
4-
namespace: Akeneo\Pim
5-
psr4_prefix: Akeneo\Pim
4+
namespace: Akeneo\Pim\ApiClient
5+
psr4_prefix: Akeneo\Pim\ApiClient

spec/AkeneoPimClientSpec.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
<?php
22

3-
namespace spec\Akeneo\Pim;
4-
5-
use Akeneo\Pim\AkeneoPimClient;
6-
use Akeneo\Pim\AkeneoPimClientInterface;
7-
use Akeneo\Pim\Api\AssociationTypeApiInterface;
8-
use Akeneo\Pim\Api\AttributeApiInterface;
9-
use Akeneo\Pim\Api\AttributeGroupApi;
10-
use Akeneo\Pim\Api\AttributeOptionApiInterface;
11-
use Akeneo\Pim\Api\CategoryApiInterface;
12-
use Akeneo\Pim\Api\ChannelApiInterface;
13-
use Akeneo\Pim\Api\CurrencyApiInterface;
14-
use Akeneo\Pim\Api\FamilyApiInterface;
15-
use Akeneo\Pim\Api\FamilyVariantApiInterface;
16-
use Akeneo\Pim\Api\LocaleApiInterface;
17-
use Akeneo\Pim\Api\MeasureFamilyApiInterface;
18-
use Akeneo\Pim\Api\MediaFileApiInterface;
19-
use Akeneo\Pim\Api\ProductApiInterface;
20-
use Akeneo\Pim\Api\ProductModelApiInterface;
21-
use Akeneo\Pim\Security\Authentication;
3+
namespace spec\Akeneo\Pim\ApiClient;
4+
5+
use Akeneo\Pim\ApiClient\AkeneoPimClient;
6+
use Akeneo\Pim\ApiClient\AkeneoPimClientInterface;
7+
use Akeneo\Pim\ApiClient\Api\AssociationTypeApiInterface;
8+
use Akeneo\Pim\ApiClient\Api\AttributeApiInterface;
9+
use Akeneo\Pim\ApiClient\Api\AttributeGroupApi;
10+
use Akeneo\Pim\ApiClient\Api\AttributeOptionApiInterface;
11+
use Akeneo\Pim\ApiClient\Api\CategoryApiInterface;
12+
use Akeneo\Pim\ApiClient\Api\ChannelApiInterface;
13+
use Akeneo\Pim\ApiClient\Api\CurrencyApiInterface;
14+
use Akeneo\Pim\ApiClient\Api\FamilyApiInterface;
15+
use Akeneo\Pim\ApiClient\Api\FamilyVariantApiInterface;
16+
use Akeneo\Pim\ApiClient\Api\LocaleApiInterface;
17+
use Akeneo\Pim\ApiClient\Api\MeasureFamilyApiInterface;
18+
use Akeneo\Pim\ApiClient\Api\MediaFileApiInterface;
19+
use Akeneo\Pim\ApiClient\Api\ProductApiInterface;
20+
use Akeneo\Pim\ApiClient\Api\ProductModelApiInterface;
21+
use Akeneo\Pim\ApiClient\Security\Authentication;
2222
use PhpSpec\ObjectBehavior;
2323

2424
class AkeneoPimClientSpec extends ObjectBehavior

spec/Api/AssociationTypeApiSpec.php

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
<?php
22

3-
namespace spec\Akeneo\Pim\Api;
4-
5-
use Akeneo\Pim\Api\AssociationTypeApi;
6-
use Akeneo\Pim\Api\AssociationTypeApiInterface;
7-
use Akeneo\Pim\Api\GettableResourceInterface;
8-
use Akeneo\Pim\Api\ListableResourceInterface;
9-
use Akeneo\Pim\Client\ResourceClientInterface;
10-
use Akeneo\Pim\Exception\InvalidArgumentException;
11-
use Akeneo\Pim\Pagination\PageFactoryInterface;
12-
use Akeneo\Pim\Pagination\PageInterface;
13-
use Akeneo\Pim\Pagination\ResourceCursorFactoryInterface;
14-
use Akeneo\Pim\Pagination\ResourceCursorInterface;
15-
use Akeneo\Pim\Stream\UpsertResourceListResponse;
3+
namespace spec\Akeneo\Pim\ApiClient\Api;
4+
5+
use Akeneo\Pim\ApiClient\Api\AssociationTypeApi;
6+
use Akeneo\Pim\ApiClient\Api\AssociationTypeApiInterface;
7+
use Akeneo\Pim\ApiClient\Api\Operation\CreatableResourceInterface;
8+
use Akeneo\Pim\ApiClient\Api\Operation\GettableResourceInterface;
9+
use Akeneo\Pim\ApiClient\Api\Operation\ListableResourceInterface;
10+
use Akeneo\Pim\ApiClient\Api\Operation\UpsertableResourceInterface;
11+
use Akeneo\Pim\ApiClient\Api\Operation\UpsertableResourceListInterface;
12+
use Akeneo\Pim\ApiClient\Client\ResourceClientInterface;
13+
use Akeneo\Pim\ApiClient\Exception\InvalidArgumentException;
14+
use Akeneo\Pim\ApiClient\Pagination\PageFactoryInterface;
15+
use Akeneo\Pim\ApiClient\Pagination\PageInterface;
16+
use Akeneo\Pim\ApiClient\Pagination\ResourceCursorFactoryInterface;
17+
use Akeneo\Pim\ApiClient\Pagination\ResourceCursorInterface;
18+
use Akeneo\Pim\ApiClient\Stream\UpsertResourceListResponse;
1619
use PhpSpec\ObjectBehavior;
1720

1821
class AssociationTypeApiSpec extends ObjectBehavior
@@ -31,6 +34,9 @@ function it_is_initializable()
3134
$this->shouldImplement(AssociationTypeApiInterface::class);
3235
$this->shouldImplement(GettableResourceInterface::class);
3336
$this->shouldImplement(ListableResourceInterface::class);
37+
$this->shouldImplement(CreatableResourceInterface::class);
38+
$this->shouldImplement(UpsertableResourceInterface::class);
39+
$this->shouldImplement(UpsertableResourceListInterface::class);
3440
}
3541

3642
function it_returns_an_association_type($resourceClient)

spec/Api/AttributeApiSpec.php

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
<?php
22

3-
namespace spec\Akeneo\Pim\Api;
4-
5-
use Akeneo\Pim\Api\AttributeApi;
6-
use Akeneo\Pim\Api\AttributeApiInterface;
7-
use Akeneo\Pim\Api\ListableResourceInterface;
8-
use Akeneo\Pim\Client\ResourceClientInterface;
9-
use Akeneo\Pim\Exception\InvalidArgumentException;
10-
use Akeneo\Pim\Pagination\PageFactoryInterface;
11-
use Akeneo\Pim\Pagination\PageInterface;
12-
use Akeneo\Pim\Pagination\ResourceCursorFactoryInterface;
13-
use Akeneo\Pim\Pagination\ResourceCursorInterface;
14-
use Akeneo\Pim\Stream\UpsertResourceListResponse;
3+
namespace spec\Akeneo\Pim\ApiClient\Api;
4+
5+
use Akeneo\Pim\ApiClient\Api\AttributeApi;
6+
use Akeneo\Pim\ApiClient\Api\AttributeApiInterface;
7+
use Akeneo\Pim\ApiClient\Api\Operation\CreatableResourceInterface;
8+
use Akeneo\Pim\ApiClient\Api\Operation\GettableResourceInterface;
9+
use Akeneo\Pim\ApiClient\Api\Operation\ListableResourceInterface;
10+
use Akeneo\Pim\ApiClient\Api\Operation\UpsertableResourceInterface;
11+
use Akeneo\Pim\ApiClient\Api\Operation\UpsertableResourceListInterface;
12+
use Akeneo\Pim\ApiClient\Client\ResourceClientInterface;
13+
use Akeneo\Pim\ApiClient\Exception\InvalidArgumentException;
14+
use Akeneo\Pim\ApiClient\Pagination\PageFactoryInterface;
15+
use Akeneo\Pim\ApiClient\Pagination\PageInterface;
16+
use Akeneo\Pim\ApiClient\Pagination\ResourceCursorFactoryInterface;
17+
use Akeneo\Pim\ApiClient\Pagination\ResourceCursorInterface;
18+
use Akeneo\Pim\ApiClient\Stream\UpsertResourceListResponse;
1519
use PhpSpec\ObjectBehavior;
1620

1721
class AttributeApiSpec extends ObjectBehavior
@@ -28,7 +32,11 @@ function it_is_initializable()
2832
{
2933
$this->shouldHaveType(AttributeApi::class);
3034
$this->shouldImplement(AttributeApiInterface::class);
35+
$this->shouldImplement(GettableResourceInterface::class);
3136
$this->shouldImplement(ListableResourceInterface::class);
37+
$this->shouldImplement(CreatableResourceInterface::class);
38+
$this->shouldImplement(UpsertableResourceInterface::class);
39+
$this->shouldImplement(UpsertableResourceListInterface::class);
3240
}
3341

3442
function it_returns_an_attribute($resourceClient)

spec/Api/AttributeGroupApiSpec.php

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
<?php
22

3-
namespace spec\Akeneo\Pim\Api;
4-
5-
use Akeneo\Pim\Api\AttributeGroupApi;
6-
use Akeneo\Pim\Api\AttributeGroupApiInterface;
7-
use Akeneo\Pim\Api\ListableResourceInterface;
8-
use Akeneo\Pim\Client\ResourceClientInterface;
9-
use Akeneo\Pim\Exception\InvalidArgumentException;
10-
use Akeneo\Pim\Pagination\PageFactoryInterface;
11-
use Akeneo\Pim\Pagination\PageInterface;
12-
use Akeneo\Pim\Pagination\ResourceCursorFactoryInterface;
13-
use Akeneo\Pim\Pagination\ResourceCursorInterface;
14-
use Akeneo\Pim\Stream\UpsertResourceListResponse;
3+
namespace spec\Akeneo\Pim\ApiClient\Api;
4+
5+
use Akeneo\Pim\ApiClient\Api\AttributeGroupApi;
6+
use Akeneo\Pim\ApiClient\Api\AttributeGroupApiInterface;
7+
use Akeneo\Pim\ApiClient\Api\Operation\CreatableResourceInterface;
8+
use Akeneo\Pim\ApiClient\Api\Operation\GettableResourceInterface;
9+
use Akeneo\Pim\ApiClient\Api\Operation\ListableResourceInterface;
10+
use Akeneo\Pim\ApiClient\Api\Operation\UpsertableResourceInterface;
11+
use Akeneo\Pim\ApiClient\Api\Operation\UpsertableResourceListInterface;
12+
use Akeneo\Pim\ApiClient\Client\ResourceClientInterface;
13+
use Akeneo\Pim\ApiClient\Exception\InvalidArgumentException;
14+
use Akeneo\Pim\ApiClient\Pagination\PageFactoryInterface;
15+
use Akeneo\Pim\ApiClient\Pagination\PageInterface;
16+
use Akeneo\Pim\ApiClient\Pagination\ResourceCursorFactoryInterface;
17+
use Akeneo\Pim\ApiClient\Pagination\ResourceCursorInterface;
18+
use Akeneo\Pim\ApiClient\Stream\UpsertResourceListResponse;
1519
use PhpSpec\ObjectBehavior;
1620

1721
class AttributeGroupApiSpec extends ObjectBehavior
@@ -28,7 +32,11 @@ function it_is_initializable()
2832
{
2933
$this->shouldHaveType(AttributeGroupApi::class);
3034
$this->shouldImplement(AttributeGroupApiInterface::class);
35+
$this->shouldImplement(GettableResourceInterface::class);
3136
$this->shouldImplement(ListableResourceInterface::class);
37+
$this->shouldImplement(CreatableResourceInterface::class);
38+
$this->shouldImplement(UpsertableResourceInterface::class);
39+
$this->shouldImplement(UpsertableResourceListInterface::class);
3240
}
3341

3442
function it_returns_an_attribute_group($resourceClient)

spec/Api/AttributeOptionApiSpec.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?php
22

3-
namespace spec\Akeneo\Pim\Api;
4-
5-
use Akeneo\Pim\Api\AttributeOptionApi;
6-
use Akeneo\Pim\Api\AttributeOptionApiInterface;
7-
use Akeneo\Pim\Client\ResourceClientInterface;
8-
use Akeneo\Pim\Exception\InvalidArgumentException;
9-
use Akeneo\Pim\Pagination\PageFactoryInterface;
10-
use Akeneo\Pim\Pagination\PageInterface;
11-
use Akeneo\Pim\Pagination\ResourceCursorFactoryInterface;
12-
use Akeneo\Pim\Pagination\ResourceCursorInterface;
3+
namespace spec\Akeneo\Pim\ApiClient\Api;
4+
5+
use Akeneo\Pim\ApiClient\Api\AttributeOptionApi;
6+
use Akeneo\Pim\ApiClient\Api\AttributeOptionApiInterface;
7+
use Akeneo\Pim\ApiClient\Client\ResourceClientInterface;
8+
use Akeneo\Pim\ApiClient\Exception\InvalidArgumentException;
9+
use Akeneo\Pim\ApiClient\Pagination\PageFactoryInterface;
10+
use Akeneo\Pim\ApiClient\Pagination\PageInterface;
11+
use Akeneo\Pim\ApiClient\Pagination\ResourceCursorFactoryInterface;
12+
use Akeneo\Pim\ApiClient\Pagination\ResourceCursorInterface;
1313
use PhpSpec\ObjectBehavior;
1414

1515
class AttributeOptionApiSpec extends ObjectBehavior

spec/Api/AuthenticationApiSpec.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
namespace spec\Akeneo\Pim\Api;
3+
namespace spec\Akeneo\Pim\ApiClient\Api;
44

5-
use Akeneo\Pim\Api\AuthenticationApi;
6-
use Akeneo\Pim\Api\AuthenticationApiInterface;
7-
use Akeneo\Pim\Client\HttpClient;
8-
use Akeneo\Pim\Routing\UriGeneratorInterface;
5+
use Akeneo\Pim\ApiClient\Api\AuthenticationApi;
6+
use Akeneo\Pim\ApiClient\Api\AuthenticationApiInterface;
7+
use Akeneo\Pim\ApiClient\Client\HttpClient;
8+
use Akeneo\Pim\ApiClient\Routing\UriGeneratorInterface;
99
use PhpSpec\ObjectBehavior;
1010
use Psr\Http\Message\ResponseInterface;
1111
use Psr\Http\Message\StreamInterface;

spec/Api/CategoryApiSpec.php

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<?php
22

3-
namespace spec\Akeneo\Pim\Api;
4-
5-
use Akeneo\Pim\Api\CategoryApi;
6-
use Akeneo\Pim\Api\CategoryApiInterface;
7-
use Akeneo\Pim\Api\CreatableResourceInterface;
8-
use Akeneo\Pim\Api\ListableResourceInterface;
9-
use Akeneo\Pim\Api\UpsertableResourceInterface;
10-
use Akeneo\Pim\Api\UpsertableResourceListInterface;
11-
use Akeneo\Pim\Client\ResourceClientInterface;
12-
use Akeneo\Pim\Exception\InvalidArgumentException;
13-
use Akeneo\Pim\Pagination\PageFactoryInterface;
14-
use Akeneo\Pim\Pagination\PageInterface;
15-
use Akeneo\Pim\Pagination\ResourceCursorFactoryInterface;
16-
use Akeneo\Pim\Pagination\ResourceCursorInterface;
17-
use Akeneo\Pim\Routing\Route;
18-
use Akeneo\Pim\Stream\UpsertResourceListResponse;
3+
namespace spec\Akeneo\Pim\ApiClient\Api;
4+
5+
use Akeneo\Pim\ApiClient\Api\CategoryApi;
6+
use Akeneo\Pim\ApiClient\Api\CategoryApiInterface;
7+
use Akeneo\Pim\ApiClient\Api\Operation\CreatableResourceInterface;
8+
use Akeneo\Pim\ApiClient\Api\Operation\GettableResourceInterface;
9+
use Akeneo\Pim\ApiClient\Api\Operation\ListableResourceInterface;
10+
use Akeneo\Pim\ApiClient\Api\Operation\UpsertableResourceInterface;
11+
use Akeneo\Pim\ApiClient\Api\Operation\UpsertableResourceListInterface;
12+
use Akeneo\Pim\ApiClient\Client\ResourceClientInterface;
13+
use Akeneo\Pim\ApiClient\Exception\InvalidArgumentException;
14+
use Akeneo\Pim\ApiClient\Pagination\PageFactoryInterface;
15+
use Akeneo\Pim\ApiClient\Pagination\PageInterface;
16+
use Akeneo\Pim\ApiClient\Pagination\ResourceCursorFactoryInterface;
17+
use Akeneo\Pim\ApiClient\Pagination\ResourceCursorInterface;
18+
use Akeneo\Pim\ApiClient\Stream\UpsertResourceListResponse;
1919
use PhpSpec\ObjectBehavior;
2020

2121
class CategoryApiSpec extends ObjectBehavior
@@ -31,9 +31,10 @@ function it_is_initializable()
3131
{
3232
$this->shouldHaveType(CategoryApi::class);
3333
$this->shouldImplement(CategoryApiInterface::class);
34+
$this->shouldImplement(GettableResourceInterface::class);
3435
$this->shouldImplement(ListableResourceInterface::class);
35-
$this->shouldImplement(UpsertableResourceInterface::class);
3636
$this->shouldImplement(CreatableResourceInterface::class);
37+
$this->shouldImplement(UpsertableResourceInterface::class);
3738
$this->shouldImplement(UpsertableResourceListInterface::class);
3839
}
3940

0 commit comments

Comments
 (0)