diff --git a/src/HTTP/Client/LamodaB2BClient.php b/src/HTTP/Client/LamodaB2BClient.php index 8bf9c1f..ac3b7dc 100644 --- a/src/HTTP/Client/LamodaB2BClient.php +++ b/src/HTTP/Client/LamodaB2BClient.php @@ -28,6 +28,7 @@ class LamodaB2BClient const URI_API_V1_FULFILMENT_SHIPMENTS = '/api/v1/shipments/fulfilment'; const URI_API_V1_GET_STOCK_STATE = '/api/v1/stock/goods'; const URI_API_V1_ORDER_ITEMS = '/api/v1/orders/%s%s/items'; + const URI_API_V1_MAPPING_CATEGORIES = '/api/v1/mapping/categories'; const EVENT_CONFIRM = 'confirm'; const EVENT_CANCEL = 'cancel'; @@ -258,6 +259,34 @@ public function getPackTracking($trackingId) return $packTrackingResponse->getBody(); } + /** + * @param string $partnerCode + * @param array $params + * + * @return array + * @throws HttpRequestException + */ + public function getMappingCategories(string $partnerCode, array $params): array + { + $accessToken = $this->getAccessToken($partnerCode); + + $response = $this->sender->sendRequest( + self::URI_API_V1_MAPPING_CATEGORIES, + Sender::METHOD_GET, + $this->getHeaders( + [ + 'Authorization' => $this->getAuthString($accessToken), + ] + ), + null, + $params + ); + + $this->parseResponse($response); + + return $response->getBody(); + } + /** * @param string $partnerCode * @param string $path diff --git a/src/Provider/MappingCategoriesDataProvider.php b/src/Provider/MappingCategoriesDataProvider.php new file mode 100644 index 0000000..6ab8763 --- /dev/null +++ b/src/Provider/MappingCategoriesDataProvider.php @@ -0,0 +1,41 @@ +lamodaB2BClient = $lamodaB2BClient; + } + + /** + * @param string $partnerCode + * @param array $params + * + * @throws Exception + * + * @return array + */ + public function getMappingCategories(string $partnerCode, array $params): array + { + $stockStateBody = $this->lamodaB2BClient->getMappingCategories($partnerCode, $params); + if (!isset($stockStateBody['_embedded']['category_mapping']) + || !is_array($stockStateBody['_embedded']['category_mapping']) + ) { + throw new Exception(ConstantMessage::UNEXPECTED_STRUCTURE_RESPONCE); + } + + return $stockStateBody['_embedded']['category_mapping']; + } +} \ No newline at end of file