Skip to content

Commit 326ee0d

Browse files
authored
Merge pull request #857 from 0xSekar/issue-779-ErrorList-Response
Revert error response to format reported by Amazon in ProductPricing/V0 api
2 parents 7d59d5c + d8d6fc5 commit 326ee0d

File tree

5 files changed

+45
-22
lines changed

5 files changed

+45
-22
lines changed

resources/metadata/modifications.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,34 @@
149149
"value": false
150150
}
151151
]
152+
},
153+
"product-pricing": {
154+
"0": [
155+
{
156+
"comment": "Error Response from Amazon for GetOffersResponse is an array",
157+
"action": "replace",
158+
"path": "components.schemas.ErrorList.type",
159+
"value": "array"
160+
},
161+
{
162+
"comment": "Error Response from Amazon for GetOffersResponse is an array",
163+
"action": "replace",
164+
"path": "components.schemas.ErrorList.items",
165+
"value": {
166+
"$ref": "#/components/schemas/Error"
167+
}
168+
},
169+
{
170+
"comment": "Remove unneded objects from ErrorList",
171+
"action": "delete",
172+
"path": "components.schemas.ErrorList.properties"
173+
},
174+
{
175+
"comment": "Remove unneded objects from ErrorList",
176+
"action": "delete",
177+
"path": "components.schemas.ErrorList.required"
178+
}
179+
]
152180
}
153181
}
154182
}

resources/models/seller/product-pricing/v0.json

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8090,19 +8090,10 @@
80908090
"description": "Information about the seller's feedback, including the percentage of positive feedback, and the total number of ratings received."
80918091
},
80928092
"ErrorList": {
8093-
"required": [
8094-
"errors"
8095-
],
8096-
"type": "object",
8093+
"type": "array",
80978094
"description": "A list of error responses returned when a request is unsuccessful.",
8098-
"properties": {
8099-
"errors": {
8100-
"type": "array",
8101-
"description": "A list of error responses returned when a request is unsuccessful.",
8102-
"items": {
8103-
"$ref": "#/components/schemas/Error"
8104-
}
8105-
}
8095+
"items": {
8096+
"$ref": "#/components/schemas/Error"
81068097
}
81078098
},
81088099
"DetailedShippingTimeType": {

src/Seller/ProductPricingV0/Responses/Errors.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@
1111
namespace SellingPartnerApi\Seller\ProductPricingV0\Responses;
1212

1313
use SellingPartnerApi\Response;
14-
use SellingPartnerApi\Seller\ProductPricingV0\Dto\ErrorList;
14+
use SellingPartnerApi\Seller\ProductPricingV0\Dto\Error;
1515

1616
final class Errors extends Response
1717
{
18+
protected static array $complexArrayTypes = ['errors' => Error::class];
19+
1820
/**
19-
* @param ErrorList $errors A list of error responses returned when a request is unsuccessful.
21+
* @param Error[] $errors A list of error responses returned when a request is unsuccessful.
2022
*/
2123
public function __construct(
22-
public readonly ErrorList $errors,
24+
public readonly array $errors,
2325
) {}
2426
}

src/Seller/ProductPricingV0/Responses/GetOffersResponse.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@
1111
namespace SellingPartnerApi\Seller\ProductPricingV0\Responses;
1212

1313
use SellingPartnerApi\Response;
14-
use SellingPartnerApi\Seller\ProductPricingV0\Dto\ErrorList;
14+
use SellingPartnerApi\Seller\ProductPricingV0\Dto\Error;
1515
use SellingPartnerApi\Seller\ProductPricingV0\Dto\GetOffersResult;
1616

1717
final class GetOffersResponse extends Response
1818
{
19+
protected static array $complexArrayTypes = ['errors' => Error::class];
20+
1921
/**
2022
* @param ?GetOffersResult $payload The payload for the getListingOffers and getItemOffers operations.
21-
* @param ?ErrorList $errors A list of error responses returned when a request is unsuccessful.
23+
* @param Error[]|null $errors A list of error responses returned when a request is unsuccessful.
2224
*/
2325
public function __construct(
2426
public readonly ?GetOffersResult $payload = null,
25-
public readonly ?ErrorList $errors = null,
27+
public readonly ?array $errors = null,
2628
) {}
2729
}

src/Seller/ProductPricingV0/Responses/GetPricingResponse.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
namespace SellingPartnerApi\Seller\ProductPricingV0\Responses;
1212

1313
use SellingPartnerApi\Response;
14-
use SellingPartnerApi\Seller\ProductPricingV0\Dto\ErrorList;
14+
use SellingPartnerApi\Seller\ProductPricingV0\Dto\Error;
1515
use SellingPartnerApi\Seller\ProductPricingV0\Dto\Price;
1616

1717
final class GetPricingResponse extends Response
1818
{
19-
protected static array $complexArrayTypes = ['payload' => Price::class];
19+
protected static array $complexArrayTypes = ['payload' => Price::class, 'errors' => Error::class];
2020

2121
/**
2222
* @param Price[]|null $payload The payload for the `getPricing` and `getCompetitivePricing` operations.
23-
* @param ?ErrorList $errors A list of error responses returned when a request is unsuccessful.
23+
* @param Error[]|null $errors A list of error responses returned when a request is unsuccessful.
2424
*/
2525
public function __construct(
2626
public readonly ?array $payload = null,
27-
public readonly ?ErrorList $errors = null,
27+
public readonly ?array $errors = null,
2828
) {}
2929
}

0 commit comments

Comments
 (0)