Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: restore array parameter support in CatalogItemsV20220401Api #833

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions lib/Api/CatalogItemsV20220401Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* The Selling Partner API for Catalog Items provides programmatic access to information about items in the Amazon catalog. For more information, refer to the [Catalog Items API Use Case Guide](https://developer-docs.amazon.com/sp-api/docs/catalog-items-api-v2022-04-01-use-case-guide).
*
* The version of the OpenAPI document: 2022-04-01
*
*
* Generated by: https://openapi-generator.tech
* OpenAPI Generator version: 5.0.1
*/
Expand Down Expand Up @@ -283,7 +283,7 @@ public function getCatalogItemWithHttpInfo($asin, $marketplace_ids, $included_da
/**
* Operation getCatalogItemAsync
*
*
*
*
* @param string $asin The Amazon Standard Identification Number (ASIN) of the item. (required)
* @param string[] $marketplace_ids A comma-delimited list of Amazon marketplace identifiers. Data sets in the response contain data only for the specified marketplaces. (required)
Expand All @@ -301,7 +301,7 @@ public function getCatalogItemAsync($asin, $marketplace_ids, $included_data = nu
/**
* Operation getCatalogItemAsyncWithHttpInfo
*
*
*
*
* @param string $asin The Amazon Standard Identification Number (ASIN) of the item. (required)
* @param string[] $marketplace_ids A comma-delimited list of Amazon marketplace identifiers. Data sets in the response contain data only for the specified marketplaces. (required)
Expand Down Expand Up @@ -737,7 +737,7 @@ public function searchCatalogItemsWithHttpInfo($marketplace_ids, $identifiers =
/**
* Operation searchCatalogItemsAsync
*
*
*
*
* @param string[] $marketplace_ids A comma-delimited list of Amazon marketplace identifiers for the request. (required)
* @param string[] $identifiers A comma-delimited list of product identifiers to search the Amazon catalog for. **Note:** Cannot be used with `keywords`. (optional)
Expand All @@ -763,7 +763,7 @@ public function searchCatalogItemsAsync($marketplace_ids, $identifiers = null, $
/**
* Operation searchCatalogItemsAsyncWithHttpInfo
*
*
*
*
* @param string[] $marketplace_ids A comma-delimited list of Amazon marketplace identifiers for the request. (required)
* @param string[] $identifiers A comma-delimited list of product identifiers to search the Amazon catalog for. **Note:** Cannot be used with `keywords`. (optional)
Expand Down Expand Up @@ -853,15 +853,16 @@ public function searchCatalogItemsRequest($marketplace_ids, $identifiers = null,
'Missing the required parameter $marketplace_ids when calling searchCatalogItems'
);
}
if (count( explode(",", $marketplace_ids) ) > 1) {

if ($this->getMarketplaceCount($marketplace_ids) > 1) {
throw new \InvalidArgumentException('invalid value for "$marketplace_ids" when calling CatalogItemsV20220401Api.searchCatalogItems, number of items must be less than or equal to 1.');
}

if ($identifiers !== null && count( explode(",", $identifiers) ) > 20) {
if ($identifiers !== null && $this->getMarketplaceCount($identifiers) > 20) {
throw new \InvalidArgumentException('invalid value for "$identifiers" when calling CatalogItemsV20220401Api.searchCatalogItems, number of items must be less than or equal to 20.');
}

if ($keywords !== null && count( explode(",", $keywords) ) > 20) {
if ($keywords !== null && $this->getMarketplaceCount($keywords) > 20) {
throw new \InvalidArgumentException('invalid value for "$keywords" when calling CatalogItemsV20220401Api.searchCatalogItems, number of items must be less than or equal to 20.');
}

Expand Down Expand Up @@ -1029,4 +1030,14 @@ public function searchCatalogItemsRequest($marketplace_ids, $identifiers = null,
);
}

/**
* Get the marketplace count demanded by the value type
*
* @param $value
* @return int
*/
private function getMarketplaceCount($value): int
{
return is_array($value) ? count($value) : count(explode(",", (string)$value));
}
}