-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from lamoda/feature/LC-659-implement-get-mappi…
…ng-categories LC-659 Implement get mapping categories method
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace LamodaB2B\Provider; | ||
|
||
use Exception; | ||
use LamodaB2B\HTTP\Client\LamodaB2BClient; | ||
use LamodaB2B\HTTP\ConstantMessage; | ||
|
||
class MappingCategoriesDataProvider | ||
{ | ||
/** @var LamodaB2BClient */ | ||
private $lamodaB2BClient; | ||
|
||
/** | ||
* @param LamodaB2BClient $lamodaB2BClient | ||
*/ | ||
public function __construct(LamodaB2BClient $lamodaB2BClient) | ||
{ | ||
$this->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']; | ||
} | ||
} |