Skip to content

Commit 46dd46a

Browse files
committed
MET-23: Add measurement family endpoints
1 parent a17a8b3 commit 46dd46a

File tree

5 files changed

+38
-40
lines changed

5 files changed

+38
-40
lines changed

src/AkeneoPimClient.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Akeneo\Pim\ApiClient\Api\FamilyVariantApiInterface;
1414
use Akeneo\Pim\ApiClient\Api\LocaleApiInterface;
1515
use Akeneo\Pim\ApiClient\Api\MeasureFamilyApiInterface;
16+
use Akeneo\Pim\ApiClient\Api\MeasurementFamilyApiInterface;
1617
use Akeneo\Pim\ApiClient\Api\MediaFileApiInterface;
1718
use Akeneo\Pim\ApiClient\Api\ProductApiInterface;
1819
use Akeneo\Pim\ApiClient\Api\ProductModelApiInterface;
@@ -72,6 +73,9 @@ class AkeneoPimClient implements AkeneoPimClientInterface
7273
/** @var ProductModelApiInterface */
7374
protected $productModelApi;
7475

76+
/** @var MeasurementFamilyApiInterface */
77+
private $measurementFamilyApi;
78+
7579
public function __construct(
7680
Authentication $authentication,
7781
ProductApiInterface $productApi,
@@ -85,6 +89,7 @@ public function __construct(
8589
ChannelApiInterface $channelApi,
8690
CurrencyApiInterface $currencyApi,
8791
MeasureFamilyApiInterface $measureFamilyApi,
92+
MeasurementFamilyApiInterface $measurementFamilyApi,
8893
AssociationTypeApiInterface $associationTypeApi,
8994
FamilyVariantApiInterface $familyVariantApi,
9095
ProductModelApiInterface $productModelApi
@@ -101,6 +106,7 @@ public function __construct(
101106
$this->channelApi = $channelApi;
102107
$this->currencyApi = $currencyApi;
103108
$this->measureFamilyApi = $measureFamilyApi;
109+
$this->measurementFamilyApi = $measurementFamilyApi;
104110
$this->associationTypeApi = $associationTypeApi;
105111
$this->familyVariantApi = $familyVariantApi;
106112
$this->productModelApi = $productModelApi;
@@ -210,6 +216,14 @@ public function getMeasureFamilyApi(): MeasureFamilyApiInterface
210216
return $this->measureFamilyApi;
211217
}
212218

219+
/**
220+
* {@inheritdoc}
221+
*/
222+
public function getMeasurementFamilyApi(): MeasurementFamilyApiInterface
223+
{
224+
return $this->measurementFamilyApi;
225+
}
226+
213227
/**
214228
* {@inheritdoc}
215229
*/

src/AkeneoPimClientBuilder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Akeneo\Pim\ApiClient\Api\FamilyVariantApi;
1515
use Akeneo\Pim\ApiClient\Api\LocaleApi;
1616
use Akeneo\Pim\ApiClient\Api\MeasureFamilyApi;
17+
use Akeneo\Pim\ApiClient\Api\MeasurementFamilyApi;
1718
use Akeneo\Pim\ApiClient\Api\ProductApi;
1819
use Akeneo\Pim\ApiClient\Api\ProductMediaFileApi;
1920
use Akeneo\Pim\ApiClient\Api\ProductModelApi;
@@ -152,7 +153,7 @@ public function buildAuthenticatedByToken(string $clientId, string $secret, stri
152153
*/
153154
protected function buildAuthenticatedClient(Authentication $authentication): AkeneoPimClientInterface
154155
{
155-
list($resourceClient, $pageFactory, $cursorFactory, $fileSystem) = $this->setUp($authentication);
156+
[$resourceClient, $pageFactory, $cursorFactory, $fileSystem] = $this->setUp($authentication);
156157

157158
$client = new AkeneoPimClient(
158159
$authentication,
@@ -167,6 +168,7 @@ protected function buildAuthenticatedClient(Authentication $authentication): Ake
167168
new ChannelApi($resourceClient, $pageFactory, $cursorFactory),
168169
new CurrencyApi($resourceClient, $pageFactory, $cursorFactory),
169170
new MeasureFamilyApi($resourceClient, $pageFactory, $cursorFactory),
171+
new MeasurementFamilyApi($resourceClient),
170172
new AssociationTypeApi($resourceClient, $pageFactory, $cursorFactory),
171173
new FamilyVariantApi($resourceClient, $pageFactory, $cursorFactory),
172174
new ProductModelApi($resourceClient, $pageFactory, $cursorFactory)

src/AkeneoPimClientInterface.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Akeneo\Pim\ApiClient\Api\FamilyVariantApiInterface;
1414
use Akeneo\Pim\ApiClient\Api\LocaleApiInterface;
1515
use Akeneo\Pim\ApiClient\Api\MeasureFamilyApiInterface;
16+
use Akeneo\Pim\ApiClient\Api\MeasurementFamilyApiInterface;
1617
use Akeneo\Pim\ApiClient\Api\MediaFileApiInterface;
1718
use Akeneo\Pim\ApiClient\Api\ProductApiInterface;
1819
use Akeneo\Pim\ApiClient\Api\ProductModelApiInterface;
@@ -52,6 +53,8 @@ public function getCurrencyApi(): CurrencyApiInterface;
5253

5354
public function getMeasureFamilyApi(): MeasureFamilyApiInterface;
5455

56+
public function getMeasurementFamilyApi(): MeasurementFamilyApiInterface;
57+
5558
public function getAssociationTypeApi(): AssociationTypeApiInterface;
5659

5760
public function getFamilyVariantApi(): FamilyVariantApiInterface;

src/Api/MeasurementFamilyApi.php

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
namespace Akeneo\Pim\ApiClient\Api;
44

55
use Akeneo\Pim\ApiClient\Client\ResourceClientInterface;
6-
use Akeneo\Pim\ApiClient\Pagination\PageFactoryInterface;
7-
use Akeneo\Pim\ApiClient\Pagination\PageInterface;
8-
use Akeneo\Pim\ApiClient\Pagination\ResourceCursorFactoryInterface;
9-
use Akeneo\Pim\ApiClient\Pagination\ResourceCursorInterface;
106

117
/**
128
* API implementation to manage measuremeent families.
@@ -22,45 +18,20 @@ class MeasurementFamilyApi implements MeasurementFamilyApiInterface
2218
/** @var ResourceClientInterface */
2319
protected $resourceClient;
2420

25-
/** @var PageFactoryInterface */
26-
protected $pageFactory;
27-
28-
/** @var ResourceCursorFactoryInterface */
29-
protected $cursorFactory;
30-
3121
/**
32-
* @param ResourceClientInterface $resourceClient
33-
* @param PageFactoryInterface $pageFactory
34-
* @param ResourceCursorFactoryInterface $cursorFactory
22+
* @param ResourceClientInterface $resourceClient
3523
*/
36-
public function __construct(
37-
ResourceClientInterface $resourceClient,
38-
PageFactoryInterface $pageFactory,
39-
ResourceCursorFactoryInterface $cursorFactory
40-
) {
41-
$this->resourceClient = $resourceClient;
42-
$this->pageFactory = $pageFactory;
43-
$this->cursorFactory = $cursorFactory;
44-
}
45-
46-
/**
47-
* {@inheritdoc}
48-
*/
49-
public function listPerPage(int $limit = 100, bool $withCount = false, array $queryParameters = []): PageInterface
24+
public function __construct(ResourceClientInterface $resourceClient)
5025
{
51-
$data = $this->resourceClient->getResources(static::MEASUREMENT_FAMILIES_URI, [], $limit, $withCount, $queryParameters);
52-
53-
return $this->pageFactory->createPage($data);
26+
$this->resourceClient = $resourceClient;
5427
}
5528

5629
/**
5730
* {@inheritdoc}
5831
*/
59-
public function all(int $pageSize = 100, array $queryParameters = []): ResourceCursorInterface
32+
public function all(): array
6033
{
61-
$firstPage = $this->listPerPage($pageSize, false, $queryParameters);
62-
63-
return $this->cursorFactory->createCursor($pageSize, $firstPage);
34+
return $this->resourceClient->getResource(static::MEASUREMENT_FAMILIES_URI);
6435
}
6536

6637
/**

src/Api/MeasurementFamilyApiInterface.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
namespace Akeneo\Pim\ApiClient\Api;
44

5-
use Akeneo\Pim\ApiClient\Api\Operation\ListableResourceInterface;
6-
use Akeneo\Pim\ApiClient\Api\Operation\UpsertableResourceListInterface;
5+
use Akeneo\Pim\ApiClient\Exception\HttpException;
76

87
/**
98
* API to manage the measurement families.
@@ -12,16 +11,25 @@
1211
* @copyright 2020 Akeneo SAS (http://www.akeneo.com)
1312
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
1413
*/
15-
interface MeasurementFamilyApiInterface extends ListableResourceInterface
14+
interface MeasurementFamilyApiInterface
1615
{
16+
/**
17+
* Gets a cursor to iterate over all the measurement families
18+
*
19+
* @throws HttpException If the request failed.
20+
*
21+
* @return array
22+
*/
23+
public function all(): array;
24+
1725
/**
1826
* Updates or creates several resources.
1927
*
20-
* @param array|StreamInterface $resources array or StreamInterface object containing the resources to create or update
28+
* @param array $resources array object containing the measurement families to create or update
2129
*
2230
* @throws HttpException
2331
*
24-
* @return array returns an array, each entry corresponding to the response of the upserted resource
32+
* @return array returns an array, each entry corresponding to the response of the upserted measurement families
2533
*/
2634
public function upsertList($resources): array;
2735
}

0 commit comments

Comments
 (0)