├── .gitignore ├── LICENSE ├── README.md ├── composer.json ├── composer.lock ├── generator.php └── src ├── ASECryptoStream.php ├── Api ├── AplusContent.php ├── Authorization.php ├── CatalogItems.php ├── Easy.php ├── FbaInboundEligibility.php ├── FbaInventory.php ├── FbaSmallAndLight.php ├── Feeds.php ├── Finances.php ├── FulfillmentInbound.php ├── FulfillmentOutbound.php ├── ListingsItems.php ├── ListingsRestrictions.php ├── MerchantFulfillment.php ├── Messaging.php ├── Notifications.php ├── Orders.php ├── ProductFees.php ├── ProductPricing.php ├── ProductTypeDefinitions.php ├── Reports.php ├── Sales.php ├── Sellers.php ├── Services.php ├── ShipmentInvoicing.php ├── Shipping.php ├── Solicitations.php ├── Tokens.php ├── Uploads.php ├── VendorDirectFulfillmentInventory.php ├── VendorDirectFulfillmentOrders.php ├── VendorDirectFulfillmentPayments.php ├── VendorDirectFulfillmentSandboxTestData.php ├── VendorDirectFulfillmentShipping.php ├── VendorDirectFulfillmentTransactions.php ├── VendorInvoices.php ├── VendorOrders.php ├── VendorShipments.php └── VendorTransactionStatus.php ├── Client.php ├── Credentials.php ├── Helper └── Feeder.php ├── HttpClientFactoryTrait.php ├── IncorrectResponseException.php ├── Signer.php ├── SignerException.php ├── SimpleTokenStorage.php └── TokenStorageInterface.php /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | codelab/ 3 | codegen/ 4 | test.php 5 | aws-tokens 6 | .idea 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 double-break 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SPAPI 2 | 3 | spapi-php is a http client for Amazon's Selling Partner API 4 | 5 | Author: Lyubomir Slavilov 6 | 7 | ## Before you start 8 | 9 | Spapi is released as Composer package `double-break/spapi-php` with **no warranties or promises**. 10 | 11 | There are couple classes (such as `Signer`, `Credentials`) which are essential for the API calls to work. Most of the issues will live here. 12 | 13 | All of the actual API clients are autogenerated and given the disclaimer above - not heavily tested. 14 | 15 | ### Requirements 16 | 17 | - php 7.3 (never tested on lower version) 18 | - composer 19 | - a lot of time reading Amazon SP API documentation 20 | 21 | ## Install and update 22 | 23 | Now you are ready to do 24 | 25 | ```bash 26 | composer require double-break/spapi-php 27 | ``` 28 | 29 | ### Package updates 30 | 31 | Once you have successfully installed the package, the updates are simple as normal Composer package updates. Just execute: 32 | 33 | ```bash 34 | composer update double-break/spapi-php 35 | ``` 36 | 37 | ## Configuration 38 | 39 | | Name | Description | Type | 40 | | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- | 41 | | `http` | Contains all the `Guzzle` configuration | GuzzleConfiguration | 42 | | **LWA configuration** | | 43 | | `refresh_token` | Value of the refresh token issued by the Seller authorizing the application | string | 44 | | `client_id` | The client id which is generated in the Seller Apps console | string | 45 | | `client_secret` | The client secret with which the client will identify itself | string | 46 | | `access_token_longevity` | The longevity in seconds of the token. It is basically the time period in which the token will be kept in the `TokenStorage` | integer
Default: 3600 | 47 | | **STS configuration** | | 48 | | `access_key` | The IAM role access key | string | 49 | | `secret_key` | The IAM role secret key | string | 50 | | `role_arn` | The ARN of the IAM role | string | 51 | | `sts_session _longevity` | The longevity of the STS session which will be created | integer
Default: 3600 | 52 | | **API configuration** | | 53 | | `region` | The region identifier for the region you are going to execute your calls against | string
Example: `eu-west-1` | 54 | | `host` | The region specific host of the Selling Partner API | string
Example: `sellingpartnerapi-eu.amazon.com` | 55 | 56 | ## Examples 57 | 58 | ### Simple use 59 | 60 | ```php 61 | [ 70 | 'verify' => false, //<--- NOT SAFE FOR PRODUCTION 71 | 'debug' => true //<--- NOT SAFE FOR PRODUCTION 72 | ], 73 | 74 | //LWA: Keys needed to obtain access token from Login With Amazon Service 75 | 'refresh_token' => '', 76 | 'client_id' => '', 77 | 'client_secret' => '', 78 | 79 | //STS: Keys of the IAM role which are needed to generate Secure Session 80 | // (a.k.a Secure token) for accessing and assuming the IAM role 81 | 'access_key' => '', 82 | 'secret_key' => '', 83 | 'role_arn' => '' , 84 | 85 | //API: Actual configuration related to the SP API :) 86 | 'region' => 'eu-west-1', 87 | 'host' => 'sellingpartnerapi-eu.amazon.com' 88 | ]; 89 | 90 | //Create token storage which will store the temporary tokens 91 | $tokenStorage = new DoubleBreak\Spapi\SimpleTokenStorage('./aws-tokens'); 92 | 93 | //Create the request signer which will be automatically used to sign all of the 94 | //requests to the API 95 | $signer = new DoubleBreak\Spapi\Signer(); 96 | 97 | //Create Credentials service and call getCredentials() to obtain 98 | //all the tokens needed under the hood 99 | 100 | $credentials = new DoubleBreak\Spapi\Credentials($tokenStorage, $signer, $config); 101 | $cred = $credentials->getCredentials(); 102 | 103 | 104 | 105 | /** The application logic implementation **/ 106 | 107 | 108 | //Create SP API Catalog client and execute one ot its REST methods. 109 | $catalogClient = new DoubleBreak\Spapi\Api\CatalogItems($cred, $config); 110 | 111 | //Check the catalog info for B074Z9QH5F ASIN 112 | $result = $catalogClient->getCatalogItem('B074Z9QH5F', [ 113 | 'marketplaceIds' => 'A1PA6795UKMFR9', 114 | ]); 115 | 116 | 117 | print_r($result); 118 | ``` 119 | 120 | ### Feed API usage 121 | 122 | For Feed API, user can follow [Feeds API Use Case Guide](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/use-case-guides/feeds-api-use-case-guide-2020-09-04.md). 123 | 124 | And in this guide for step 2. Encrypt and upload the feed data: user can use below example: 125 | 126 | ```php 127 | createFeedDocument(["contentType" => $contentType]); 135 | $payload = $response['payload']; 136 | 137 | $feedContentFilePath = './testFeedDoc.xml'; 138 | 139 | $result = (new \DoubleBreak\Spapi\Helper\Feeder())->uploadFeedDocument($payload,$contentType,$feedContentFilePath); 140 | print_r($result); 141 | ``` 142 | 143 | And for Step 6. Download and decrypt the feed processing report: user can use below example: 144 | 145 | ```php 146 | getFeedDocument($resultFeedDocumentId); 152 | $payload = $response['payload']; 153 | 154 | $result = (new \DoubleBreak\Spapi\Helper\Feeder())->downloadFeedProcessingReport($payload); 155 | print_r($result); 156 | ``` 157 | 158 | ### Debugging responses 159 | 160 | ```php 161 | getCatalogItem('B074Z9QH5F', [ 167 | 'MarketplaceId' => 'A1PA6795UKMFR9', 168 | ])['payload']; 169 | //do your business here 170 | } catch (\GuzzleHttp\Exception\ClientException $e) { 171 | $httpCode = $e->getResponse()->getStatusCode(); 172 | $errorBody = $e->getResponse()->getBody(); 173 | 174 | echo "Amazon SP API responded with HTTP {$httpCode}\n {$errorBody}"; 175 | 176 | } catch(\Exception $e) { 177 | echo "Unexpected exception: " . $e->getMessage(); 178 | } 179 | ``` 180 | 181 | ### Accessing response headers 182 | 183 | 📝Accessing headers by using client's `getLastHttpResponse()` is available since v1.0.5 184 | 185 | ```php 186 | getCatalogItem('B074Z9QH5F', [ 194 | 'MarketplaceId' => 'A1PA6795UKMFR9', 195 | ])['payload']; 196 | 197 | $headers = $catalogClinet->getLastHttpResponse()->getHeaders(); 198 | foreach ($headers as $headerName => $values) { 199 | echo "{$headerName}: " . implode(','. $values); 200 | } 201 | ``` 202 | 203 | ### Debugging 4xx and 5xx response headers 204 | 205 | 📝Accessing headers by using client's `getLastHttpResponse()` is available since v1.0.5 206 | 207 | ```php 208 | getCatalogItem('B074Z9QH5F', [ 214 | 'MarketplaceId' => 'A1PA6795UKMFR9', 215 | ])['payload']; 216 | //do your business here 217 | } catch (\GuzzleHttp\Exception\ClientException $e) { 218 | $headers = $e->getResponse()->getHeaders(); 219 | print_r($headers); 220 | } 221 | 222 | // OR 223 | 224 | try { 225 | $result = $catalogClinet->getCatalogItem('B074Z9QH5F', [ 226 | 'MarketplaceId' => 'A1PA6795UKMFR9', 227 | ])['payload']; 228 | //do your business here 229 | 230 | } catch (\GuzzleHttp\Exception\ClientException $e) { 231 | $headers = $catalogClinet->getLastHttpResponse()->getHeaders(); 232 | print_r($headers); 233 | } 234 | 235 | ``` 236 | 237 | ### Migrating authorization from Amazon Marketplace Web Service to Selling Partner Api 238 | 239 | [Please, see more details in Selling Partner Api docs](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/developer-guide/SellingPartnerApiDeveloperGuide.md#migrating-authorization-from-amazon-marketplace-web-service) 240 | 241 | ```php 242 | [ 250 | 'verify' => false, 251 | 'debug' => true 252 | ], 253 | 254 | //LWA: Keys needed to obtain access token from Login With Amazon Service 255 | 'refresh_token' => '', 256 | 'client_id' => '', 257 | 'client_secret' => '', 258 | 259 | //STS: Keys of the IAM role which are needed to generate Secure Session 260 | // (a.k.a Secure token) for accessing and assuming the IAM role 261 | 'access_key' => '', 262 | 'secret_key' => '', 263 | 'role_arn' => '' , 264 | 265 | //API: Actual configuration related to the SP API :) 266 | 'region' => 'eu-west-1', 267 | 'host' => 'sellingpartnerapi-eu.amazon.com' 268 | ]; 269 | 270 | //Create token storage which will store the temporary tokens 271 | $tokenStorage = new DoubleBreak\Spapi\SimpleTokenStorage('./aws-tokens'); 272 | 273 | //Create the request signer which will be automatically used to sign all of the 274 | //requests to the API 275 | $signer = new DoubleBreak\Spapi\Signer(); 276 | 277 | //Create Credentials service and call getCredentials() to obtain 278 | //all the tokens needed under the hood 279 | $credentials = new DoubleBreak\Spapi\Credentials($tokenStorage, $signer, $config); 280 | //get credentials with migration token, it's needed for /authorization/v1/authorizationCode request 281 | $cred = $credentials->getCredentials(true); 282 | 283 | /** The application logic implementation **/ 284 | 285 | //Create SP API Catalog client and execute one ot its REST methods. 286 | $authorizationClient = new DoubleBreak\Spapi\Api\Authorization($cred, $config); 287 | 288 | //Get Authorization code 289 | $result = $authorizationClient->getAuthorizationCode([ 290 | 'developerId' => '', 291 | 'mwsAuthToken' => '', 292 | 'sellingPartnerId' => '' 293 | ])['payload']; 294 | 295 | //Authorization code should be changed to Access and Refresh token 296 | print_r($credentials->exchangesAuthorizationCodeForRefreshToken($result['authorizationCode'])); 297 | ``` 298 | 299 | ### Authorization for Grantless Operations in Selling Partner API 300 | 301 | [Please, see more details in Selling Partner Api docs](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/developer-guide/SellingPartnerApiDeveloperGuide.md#grantless-operations-1) 302 | 303 | ```php 304 | [ 312 | 'verify' => false, 313 | 'debug' => true 314 | ], 315 | 316 | //LWA: Keys needed to obtain access token from Login With Amazon Service 317 | 'refresh_token' => '', 318 | 'client_id' => '', 319 | 'client_secret' => '', 320 | 321 | //STS: Keys of the IAM role which are needed to generate Secure Session 322 | // (a.k.a Secure token) for accessing and assuming the IAM role 323 | 'access_key' => '', 324 | 'secret_key' => '', 325 | 'role_arn' => '' , 326 | 327 | //API: Actual configuration related to the SP API :) 328 | 'region' => 'eu-west-1', 329 | 'host' => 'sellingpartnerapi-eu.amazon.com' 330 | ]; 331 | 332 | //Create token storage which will store the temporary tokens 333 | $tokenStorage = new DoubleBreak\Spapi\SimpleTokenStorage('./aws-tokens'); 334 | 335 | //Create the request signer which will be automatically used to sign all of the 336 | //requests to the API 337 | $signer = new DoubleBreak\Spapi\Signer(); 338 | 339 | //Create Credentials service and call getCredentials() to obtain 340 | //all the tokens needed under the hood 341 | $credentials = new DoubleBreak\Spapi\Credentials($tokenStorage, $signer, $config); 342 | //get credentials with Grantless auth token, it's needed for grantless operations request 343 | $cred = $credentials->getCredentials('grantless'); 344 | 345 | /** The application logic implementation **/ 346 | 347 | //Create SP API Notification client and execute one ot its REST methods. 348 | $notificationClient = new DoubleBreak\Spapi\Api\Notifications($cred, $config); 349 | 350 | //Get notification destinations 351 | $result = $notificationClient->getDestinations(); 352 | print_r($result['payload']); 353 | ``` 354 | 355 | ### Working with Restricted Data APIs 356 | 357 | ```php 358 | getRdtCredentials([ 380 | 'restrictedResources' => [ 381 | [ 382 | 'method' => 'GET', 383 | 'path' => '/orders/v0/orders/{orderId}/buyerInfo' 384 | ], 385 | [ 386 | 'method' => 'GET', 387 | 'path' => '/mfn/v0/shipments/{shipmentId}' 388 | ] 389 | ] 390 | ]); 391 | 392 | 393 | 394 | /** The application logic implementation **/ 395 | 396 | 397 | //Create SP API Orders client and execute one ot its REST methods. 398 | $orderClient = new DoubleBreak\Spapi\Api\Orders($cred, $config); 399 | 400 | //Get order's buyer info 401 | $result = $catalogClient->getOrderBuyerInfo('902-3159896-1390916')['payload']; 402 | print_r($result); 403 | 404 | //... 405 | ``` 406 | 407 | For more information see the Amazons's use case documentation about this topic: https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/use-case-guides/tokens-api-use-case-guide/tokens-API-use-case-guide-2021-03-01.md 408 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "double-break/spapi-php", 3 | "description": "Amazon Selling Partner API Client", 4 | "type": "library", 5 | "authors": [ 6 | { 7 | "name": "Lyubo Slavilov", 8 | "email": "lyubo.slavilov@gmail.com" 9 | } 10 | ], 11 | "require": { 12 | "ext-simplexml": "*", 13 | "ext-json": "*", 14 | "ext-zlib": "*", 15 | "guzzlehttp/guzzle": "^7.4", 16 | "guzzlehttp/psr7": "^2.4" 17 | }, 18 | "autoload": { 19 | "psr-4": { "DoubleBreak\\Spapi\\" : "src/" } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /generator.php: -------------------------------------------------------------------------------- 1 | model specs will be checkout in ./tmp/selling-partner-api-models 18 | * -> Client class files will be generated in ./autogen/ 19 | */ 20 | 21 | 22 | include __DIR__ . '/vendor/autoload.php'; 23 | 24 | class SpapiGenerator { 25 | public $className; 26 | 27 | private $specURL; 28 | 29 | private $swaggerSpec; 30 | private $parsedSpec; 31 | private $jsonFileName; 32 | 33 | public function __construct($specURL, $model, $jsonFileName) 34 | { 35 | $this->specURL = $specURL; 36 | 37 | $this->className = implode('', array_map( 38 | function($p){ return ucfirst($p); }, 39 | array_slice(explode('-', $model), 0, -2) 40 | )); //duuh.. it's just a salammi-case to BorlandCase transformation; 41 | 42 | $this->model = $model; 43 | $this->jsonFileName = $jsonFileName; 44 | 45 | } 46 | 47 | public function loadSpec() 48 | { 49 | $client = new GuzzleHttp\Client(['verify'=>false]); 50 | 51 | $contents = file_get_contents($this->specURL); 52 | $this->swaggerSpec = json_decode($contents, true); 53 | } 54 | 55 | public function parseSpec() 56 | { 57 | $parsedSpec = []; 58 | $superGlobals = $this->swaggerSpec['parameters'] ?? []; 59 | 60 | foreach ($this->swaggerSpec['paths'] as $path => $spec) { 61 | $globalParams = $spec['parameters'] ?? []; 62 | unset($spec['parameters']); 63 | 64 | foreach ($spec as $httpMethod => $methodSpec) { 65 | $parameters = array_merge($globalParams,$methodSpec['parameters'] ?? []); 66 | $parsedParams = $this->parsePathParameters($parameters, $superGlobals); 67 | $parsedSpec[] = [ 68 | 'pathTemplate' => $path, 69 | 'httpMethod' => $httpMethod, 70 | 'classMethod' => $methodSpec['operationId'], 71 | 'queryParams' => $parsedParams['query'], 72 | 'pathParams' => $parsedParams['path'], 73 | 'bodyParams' => $parsedParams['body'] 74 | ]; 75 | } 76 | } 77 | $this->parsedSpec = $parsedSpec; 78 | } 79 | 80 | public function generateCode() 81 | { 82 | $source = $this->generateHeader(''); 83 | $source .= $this->generateMethods(' '); 84 | $source .= $this->line('', '}'); //close the class block 85 | 86 | $sign = md5($source); 87 | $source = str_replace('', $sign, $source); 88 | return $source; 89 | } 90 | 91 | //Parsing helpers 92 | private function toCamel($varname) 93 | { 94 | $words = explode('_', $varname); 95 | 96 | $first = lcfirst(array_shift($words)); 97 | 98 | $words = array_map(fn($word) => ucfirst($word), $words); 99 | 100 | array_unshift($words, $first); 101 | return join('', $words); 102 | } 103 | 104 | private function remapParameter($param) 105 | { 106 | return [ 107 | 'name' => $param['name'], 108 | 'type' => $param['type'] ?? '', 109 | 'desc' => $param['description'] ?? '' 110 | ]; 111 | } 112 | 113 | private function parsePathParameters($specParameters, $superGlobals) 114 | { 115 | $parsedParams = [ 116 | 'query' => [], 117 | 'path' => [], 118 | 'body' => [] 119 | ]; 120 | foreach ($specParameters as $param) { 121 | if (isset($param['$ref']) && strpos($param['$ref'], '#/parameters/') === 0) { 122 | $p = $superGlobals[str_replace('#/parameters/', '', $param['$ref'])]; 123 | $parsedParams[$p['in']][] = $this->remapParameter($p); 124 | } else { 125 | $parsedParams[$param['in']][] = $this->remapParameter($param); 126 | } 127 | } 128 | return $parsedParams; 129 | } 130 | 131 | 132 | //Code generation helpers 133 | private function line($idn = '', $str = '') 134 | { 135 | return $idn . $str . "\n"; 136 | } 137 | 138 | private function generateHeader($idn = '') 139 | { 140 | 141 | $header = $this->line($idn, "line($idn, "/**"); 144 | $header .= $this->line($idn, "* This class is autogenerated by the Spapi class generator"); 145 | $header .= $this->line($idn, "* Date of generation: " . date('Y-m-d', time())); 146 | $header .= $this->line($idn, "* Specification: https://github.com/amzn/selling-partner-api-models/blob/main/models/{$this->model}/{$this->jsonFileName}"); 147 | $header .= $this->line($idn, "* Source MD5 signature: "); 148 | $header .= $this->line($idn, "*"); 149 | $header .= $this->line($idn, "*"); 150 | $header .= $this->line($idn, "* {$this->swaggerSpec['info']['title']}"); 151 | $header .= $this->line($idn, "* {$this->swaggerSpec['info']['description']}"); 152 | $header .= $this->line($idn, "*/"); 153 | 154 | $header .= $this->line($idn, "namespace DoubleBreak\\Spapi\\Api;"); 155 | $header .= $this->line($idn, "use DoubleBreak\\Spapi\\Client;"); 156 | $header .= $this->line(); 157 | $header .= $this->line($idn, "class {$this->className} extends Client {"); 158 | 159 | return $header; 160 | } 161 | 162 | private function generateMethods($idn = '') 163 | { 164 | $methods = ''; 165 | foreach ($this->parsedSpec as $spec) { 166 | $methods .= $this->generateDocComment($spec, $idn); 167 | $methods .= $this->generateMethod($spec, $idn); 168 | } 169 | return $methods; 170 | } 171 | 172 | private function generateDocComment($spec, $idn) 173 | { 174 | $docComment = $this->line(); 175 | $docComment .= $this->line($idn, "/**"); 176 | $docComment .= $this->line($idn, "* Operation {$spec['classMethod']}"); 177 | 178 | if (count($spec['pathParams']) > 0) { 179 | $docComment .= $this->line($idn, '*'); 180 | } 181 | foreach ($spec['pathParams'] as $param) { 182 | $n = $this->toCamel($param['name']); 183 | $d = str_replace("\n", "\n" . $idn . "*", $param['desc']); 184 | $docComment .= $this->line($idn, "* @param {$param['type']} \${$n} {$d}"); 185 | } 186 | 187 | if (count($spec['queryParams'])>0) { 188 | $docComment .= $this->line($idn, '*'); 189 | $docComment .= $this->line($idn, "* @param array \$queryParams"); 190 | foreach ($spec['queryParams'] as $param) { 191 | $n = $this->toCamel($param['name']); 192 | $d = str_replace("\n", "\n" . $idn . "*", $param['desc']); 193 | $docComment .= $this->line($idn, "* - *{$n}* {$param['type']} - {$d}"); 194 | } 195 | } 196 | $docComment .= $this->line($idn, "*"); 197 | $docComment .= $this->line($idn, "*/"); 198 | 199 | return $docComment; 200 | } 201 | 202 | private function generateMethod($spec, $idn) 203 | { 204 | $methodSource = $this->generateMethodSignature($spec, $idn); 205 | $methodSource .= $this->line($idn, "{"); 206 | $methodSource .= $this->generateMethodImplementation($spec, $idn . ' '); 207 | $methodSource .= $this->line($idn, '}'); 208 | 209 | $methodSource .= $this->line(); 210 | 211 | //Async Version 212 | $methodSource .= $this->generateMethodSignature($spec, $idn, true); 213 | $methodSource .= $this->line($idn, "{"); 214 | $methodSource .= $this->generateMethodImplementation($spec, $idn . ' ', true); 215 | $methodSource .= $this->line($idn, '}'); 216 | 217 | return $methodSource; 218 | } 219 | 220 | private function generateMethodSignature($spec, $idn, $isAsync = false) 221 | { 222 | $arguments = ''; 223 | $c = ''; 224 | 225 | foreach ($spec['pathParams'] as $param) { 226 | $arguments .= $c . '$' . $this->toCamel($param['name']); 227 | $c = ', '; 228 | } 229 | if (count($spec['queryParams']) > 0) { 230 | $arguments .= $c . '$queryParams = []'; 231 | $c = ', '; 232 | } 233 | if (count($spec['bodyParams']) > 0) { 234 | $arguments .= $c . '$body = []'; 235 | } 236 | $methodName = $spec['classMethod'] . ($isAsync ? 'Async' : ''); 237 | $signature = $this->line($idn, "public function {$methodName}({$arguments})"); 238 | return $signature; 239 | } 240 | 241 | private function generateMethodImplementation($spec, $idn, $isAsync = false) 242 | { 243 | $path = $spec['pathTemplate']; 244 | $httpMethod = strtoupper($spec['httpMethod']); 245 | foreach ($spec['pathParams'] as $p) { 246 | $n = $this->toCamel($p['name']); 247 | $path = str_replace('{'.$p['name'].'}', '{$'.$n.'}', $path); 248 | } 249 | if ($isAsync) { 250 | $implementation = $this->line($idn, "return \$this->sendAsync(\"{$path}\", ["); 251 | } else { 252 | $implementation = $this->line($idn, "return \$this->send(\"{$path}\", ["); 253 | } 254 | $implementation .= $this->line($idn, " 'method' => '{$httpMethod}',"); 255 | 256 | if (count($spec['queryParams']) > 0) { 257 | $implementation .= $this->line($idn, " 'query' => \$queryParams,"); 258 | } 259 | 260 | if (count($spec['bodyParams']) > 0) { 261 | $implementation .= $this->line($idn, " 'json' => \$body"); 262 | } 263 | 264 | $implementation .= $this->line($idn, "]);"); 265 | return $implementation; 266 | } 267 | 268 | } 269 | 270 | 271 | 272 | $specDir = $argv[1]; 273 | //checkout all the models 274 | `git clone https://github.com/amzn/selling-partner-api-models.git {$specDir}/selling-partner-api-models`; 275 | 276 | $modelsDir = $specDir . '/selling-partner-api-models/models'; 277 | $allModels = scandir($modelsDir); 278 | 279 | $allModels = array_slice($allModels, 2); //remove . and .. 280 | 281 | 282 | foreach ($allModels as $model) { 283 | 284 | $modelFiles = scandir($modelsDir . '/' . $model); 285 | $modelFiles = array_slice($modelFiles, 2); //remove . and .. 286 | 287 | if (count($modelFiles) > 1) { 288 | $message = "\nMore than one file is found for {$model}."; 289 | $index = 0; 290 | foreach($modelFiles as $i => $f) { 291 | $message .= "\n" . $i . " " . $f; 292 | } 293 | 294 | $choiceIsOk = false; 295 | while(!$choiceIsOk) { 296 | echo $message . "\n"; 297 | $result = readline("Please choose: "); 298 | if (!isset($modelFiles[$result])) { 299 | echo "\nThe number is not valid!\n"; 300 | } else { 301 | $choiceIsOk = true; 302 | $fileName = $modelFiles[$result]; 303 | } 304 | } 305 | 306 | } else { 307 | $fileName = $modelFiles[0]; 308 | } 309 | 310 | 311 | 312 | $generator = new SpapiGenerator( 313 | $modelsDir . '/' . $model . '/' . $fileName, 314 | $model, 315 | $fileName 316 | ); 317 | 318 | $generator->loadSpec(); 319 | $generator->parseSpec(); 320 | 321 | $source = $generator->generateCode(); 322 | 323 | echo "Generating file " . __DIR__ . "/{$argv[2]}/{$generator->className}.php", PHP_EOL; 324 | file_put_contents(__DIR__ . "/{$argv[2]}/{$generator->className}.php", $source); 325 | } 326 | 327 | `rm -Rf {$specDir}/selling-partner-api-models`; 328 | -------------------------------------------------------------------------------- /src/ASECryptoStream.php: -------------------------------------------------------------------------------- 1 | send("/aplus/2020-11-01/contentDocuments", [ 28 | 'method' => 'GET', 29 | 'query' => $queryParams, 30 | ]); 31 | } 32 | 33 | public function searchContentDocumentsAsync($queryParams = []) 34 | { 35 | return $this->sendAsync("/aplus/2020-11-01/contentDocuments", [ 36 | 'method' => 'GET', 37 | 'query' => $queryParams, 38 | ]); 39 | } 40 | 41 | /** 42 | * Operation createContentDocument 43 | * 44 | * @param array $queryParams 45 | * - *marketplaceId* string - The identifier for the marketplace where the A+ Content is published. 46 | * 47 | */ 48 | public function createContentDocument($queryParams = [], $body = []) 49 | { 50 | return $this->send("/aplus/2020-11-01/contentDocuments", [ 51 | 'method' => 'POST', 52 | 'query' => $queryParams, 53 | 'json' => $body 54 | ]); 55 | } 56 | 57 | public function createContentDocumentAsync($queryParams = [], $body = []) 58 | { 59 | return $this->sendAsync("/aplus/2020-11-01/contentDocuments", [ 60 | 'method' => 'POST', 61 | 'query' => $queryParams, 62 | 'json' => $body 63 | ]); 64 | } 65 | 66 | /** 67 | * Operation getContentDocument 68 | * 69 | * @param string $contentReferenceKey The unique reference key for the A+ Content document. A content reference key cannot form a permalink and may change in the future. A content reference key is not guaranteed to match any A+ Content identifier. 70 | * 71 | * @param array $queryParams 72 | * - *marketplaceId* string - The identifier for the marketplace where the A+ Content is published. 73 | * - *includedDataSet* array - The set of A+ Content data types to include in the response. 74 | * 75 | */ 76 | public function getContentDocument($contentReferenceKey, $queryParams = []) 77 | { 78 | return $this->send("/aplus/2020-11-01/contentDocuments/{$contentReferenceKey}", [ 79 | 'method' => 'GET', 80 | 'query' => $queryParams, 81 | ]); 82 | } 83 | 84 | public function getContentDocumentAsync($contentReferenceKey, $queryParams = []) 85 | { 86 | return $this->sendAsync("/aplus/2020-11-01/contentDocuments/{$contentReferenceKey}", [ 87 | 'method' => 'GET', 88 | 'query' => $queryParams, 89 | ]); 90 | } 91 | 92 | /** 93 | * Operation updateContentDocument 94 | * 95 | * @param string $contentReferenceKey The unique reference key for the A+ Content document. A content reference key cannot form a permalink and may change in the future. A content reference key is not guaranteed to match any A+ Content identifier. 96 | * 97 | * @param array $queryParams 98 | * - *marketplaceId* string - The identifier for the marketplace where the A+ Content is published. 99 | * 100 | */ 101 | public function updateContentDocument($contentReferenceKey, $queryParams = [], $body = []) 102 | { 103 | return $this->send("/aplus/2020-11-01/contentDocuments/{$contentReferenceKey}", [ 104 | 'method' => 'POST', 105 | 'query' => $queryParams, 106 | 'json' => $body 107 | ]); 108 | } 109 | 110 | public function updateContentDocumentAsync($contentReferenceKey, $queryParams = [], $body = []) 111 | { 112 | return $this->sendAsync("/aplus/2020-11-01/contentDocuments/{$contentReferenceKey}", [ 113 | 'method' => 'POST', 114 | 'query' => $queryParams, 115 | 'json' => $body 116 | ]); 117 | } 118 | 119 | /** 120 | * Operation listContentDocumentAsinRelations 121 | * 122 | * @param string $contentReferenceKey The unique reference key for the A+ Content document. A content reference key cannot form a permalink and may change in the future. A content reference key is not guaranteed to match any A+ Content identifier. 123 | * 124 | * @param array $queryParams 125 | * - *marketplaceId* string - The identifier for the marketplace where the A+ Content is published. 126 | * - *includedDataSet* array - The set of A+ Content data types to include in the response. If you do not include this parameter, the operation returns the related ASINs without metadata. 127 | * - *asinSet* array - The set of ASINs. 128 | * - *pageToken* string - A page token from the nextPageToken response element returned by your previous call to this operation. nextPageToken is returned when the results of a call exceed the page size. To get the next page of results, call the operation and include pageToken as the only parameter. Specifying pageToken with any other parameter will cause the request to fail. When no nextPageToken value is returned there are no more pages to return. A pageToken value is not usable across different operations. 129 | * 130 | */ 131 | public function listContentDocumentAsinRelations($contentReferenceKey, $queryParams = []) 132 | { 133 | return $this->send("/aplus/2020-11-01/contentDocuments/{$contentReferenceKey}/asins", [ 134 | 'method' => 'GET', 135 | 'query' => $queryParams, 136 | ]); 137 | } 138 | 139 | public function listContentDocumentAsinRelationsAsync($contentReferenceKey, $queryParams = []) 140 | { 141 | return $this->sendAsync("/aplus/2020-11-01/contentDocuments/{$contentReferenceKey}/asins", [ 142 | 'method' => 'GET', 143 | 'query' => $queryParams, 144 | ]); 145 | } 146 | 147 | /** 148 | * Operation postContentDocumentAsinRelations 149 | * 150 | * @param string $contentReferenceKey The unique reference key for the A+ Content document. A content reference key cannot form a permalink and may change in the future. A content reference key is not guaranteed to match any A+ content identifier. 151 | * 152 | * @param array $queryParams 153 | * - *marketplaceId* string - The identifier for the marketplace where the A+ Content is published. 154 | * 155 | */ 156 | public function postContentDocumentAsinRelations($contentReferenceKey, $queryParams = [], $body = []) 157 | { 158 | return $this->send("/aplus/2020-11-01/contentDocuments/{$contentReferenceKey}/asins", [ 159 | 'method' => 'POST', 160 | 'query' => $queryParams, 161 | 'json' => $body 162 | ]); 163 | } 164 | 165 | public function postContentDocumentAsinRelationsAsync($contentReferenceKey, $queryParams = [], $body = []) 166 | { 167 | return $this->sendAsync("/aplus/2020-11-01/contentDocuments/{$contentReferenceKey}/asins", [ 168 | 'method' => 'POST', 169 | 'query' => $queryParams, 170 | 'json' => $body 171 | ]); 172 | } 173 | 174 | /** 175 | * Operation validateContentDocumentAsinRelations 176 | * 177 | * @param array $queryParams 178 | * - *marketplaceId* string - The identifier for the marketplace where the A+ Content is published. 179 | * - *asinSet* array - The set of ASINs. 180 | * 181 | */ 182 | public function validateContentDocumentAsinRelations($queryParams = [], $body = []) 183 | { 184 | return $this->send("/aplus/2020-11-01/contentAsinValidations", [ 185 | 'method' => 'POST', 186 | 'query' => $queryParams, 187 | 'json' => $body 188 | ]); 189 | } 190 | 191 | public function validateContentDocumentAsinRelationsAsync($queryParams = [], $body = []) 192 | { 193 | return $this->sendAsync("/aplus/2020-11-01/contentAsinValidations", [ 194 | 'method' => 'POST', 195 | 'query' => $queryParams, 196 | 'json' => $body 197 | ]); 198 | } 199 | 200 | /** 201 | * Operation searchContentPublishRecords 202 | * 203 | * @param array $queryParams 204 | * - *marketplaceId* string - The identifier for the marketplace where the A+ Content is published. 205 | * - *asin* string - The Amazon Standard Identification Number (ASIN). 206 | * - *pageToken* string - A page token from the nextPageToken response element returned by your previous call to this operation. nextPageToken is returned when the results of a call exceed the page size. To get the next page of results, call the operation and include pageToken as the only parameter. Specifying pageToken with any other parameter will cause the request to fail. When no nextPageToken value is returned there are no more pages to return. A pageToken value is not usable across different operations. 207 | * 208 | */ 209 | public function searchContentPublishRecords($queryParams = []) 210 | { 211 | return $this->send("/aplus/2020-11-01/contentPublishRecords", [ 212 | 'method' => 'GET', 213 | 'query' => $queryParams, 214 | ]); 215 | } 216 | 217 | public function searchContentPublishRecordsAsync($queryParams = []) 218 | { 219 | return $this->sendAsync("/aplus/2020-11-01/contentPublishRecords", [ 220 | 'method' => 'GET', 221 | 'query' => $queryParams, 222 | ]); 223 | } 224 | 225 | /** 226 | * Operation postContentDocumentApprovalSubmission 227 | * 228 | * @param string $contentReferenceKey The unique reference key for the A+ Content document. A content reference key cannot form a permalink and may change in the future. A content reference key is not guaranteed to match any A+ content identifier. 229 | * 230 | * @param array $queryParams 231 | * - *marketplaceId* string - The identifier for the marketplace where the A+ Content is published. 232 | * 233 | */ 234 | public function postContentDocumentApprovalSubmission($contentReferenceKey, $queryParams = []) 235 | { 236 | return $this->send("/aplus/2020-11-01/contentDocuments/{$contentReferenceKey}/approvalSubmissions", [ 237 | 'method' => 'POST', 238 | 'query' => $queryParams, 239 | ]); 240 | } 241 | 242 | public function postContentDocumentApprovalSubmissionAsync($contentReferenceKey, $queryParams = []) 243 | { 244 | return $this->sendAsync("/aplus/2020-11-01/contentDocuments/{$contentReferenceKey}/approvalSubmissions", [ 245 | 'method' => 'POST', 246 | 'query' => $queryParams, 247 | ]); 248 | } 249 | 250 | /** 251 | * Operation postContentDocumentSuspendSubmission 252 | * 253 | * @param string $contentReferenceKey The unique reference key for the A+ Content document. A content reference key cannot form a permalink and may change in the future. A content reference key is not guaranteed to match any A+ content identifier. 254 | * 255 | * @param array $queryParams 256 | * - *marketplaceId* string - The identifier for the marketplace where the A+ Content is published. 257 | * 258 | */ 259 | public function postContentDocumentSuspendSubmission($contentReferenceKey, $queryParams = []) 260 | { 261 | return $this->send("/aplus/2020-11-01/contentDocuments/{$contentReferenceKey}/suspendSubmissions", [ 262 | 'method' => 'POST', 263 | 'query' => $queryParams, 264 | ]); 265 | } 266 | 267 | public function postContentDocumentSuspendSubmissionAsync($contentReferenceKey, $queryParams = []) 268 | { 269 | return $this->sendAsync("/aplus/2020-11-01/contentDocuments/{$contentReferenceKey}/suspendSubmissions", [ 270 | 'method' => 'POST', 271 | 'query' => $queryParams, 272 | ]); 273 | } 274 | } 275 | -------------------------------------------------------------------------------- /src/Api/Authorization.php: -------------------------------------------------------------------------------- 1 | send("/authorization/v1/authorizationCode", [ 29 | 'method' => 'GET', 30 | 'query' => $queryParams, 31 | ]); 32 | } 33 | 34 | public function getAuthorizationCodeAsync($queryParams = []) 35 | { 36 | return $this->sendAsync("/authorization/v1/authorizationCode", [ 37 | 'method' => 'GET', 38 | 'query' => $queryParams, 39 | ]); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Api/CatalogItems.php: -------------------------------------------------------------------------------- 1 | send("/catalog/2022-04-01/items", [ 40 | 'method' => 'GET', 41 | 'query' => $queryParams, 42 | ]); 43 | } 44 | 45 | public function searchCatalogItemsAsync($queryParams = []) 46 | { 47 | return $this->sendAsync("/catalog/2022-04-01/items", [ 48 | 'method' => 'GET', 49 | 'query' => $queryParams, 50 | ]); 51 | } 52 | 53 | /** 54 | * Operation getCatalogItem 55 | * 56 | * @param string $asin The Amazon Standard Identification Number (ASIN) of the item. 57 | * 58 | * @param array $queryParams 59 | * - *marketplaceIds* array - A comma-delimited list of Amazon marketplace identifiers. Data sets in the response contain data only for the specified marketplaces. 60 | * - *includedData* array - A comma-delimited list of data sets to include in the response. Default: `summaries`. 61 | * - *locale* string - Locale for retrieving localized summaries. Defaults to the primary locale of the marketplace. 62 | * 63 | */ 64 | public function getCatalogItem($asin, $queryParams = []) 65 | { 66 | return $this->send("/catalog/2022-04-01/items/{$asin}", [ 67 | 'method' => 'GET', 68 | 'query' => $queryParams, 69 | ]); 70 | } 71 | 72 | public function getCatalogItemAsync($asin, $queryParams = []) 73 | { 74 | return $this->sendAsync("/catalog/2022-04-01/items/{$asin}", [ 75 | 'method' => 'GET', 76 | 'query' => $queryParams, 77 | ]); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/Api/Easy.php: -------------------------------------------------------------------------------- 1 | send("/easyShip/2022-03-23/timeSlot", [ 34 | 'method' => 'POST', 35 | 'json' => $body 36 | ]); 37 | } 38 | 39 | public function listHandoverSlotsAsync($body = []) 40 | { 41 | return $this->sendAsync("/easyShip/2022-03-23/timeSlot", [ 42 | 'method' => 'POST', 43 | 'json' => $body 44 | ]); 45 | } 46 | 47 | /** 48 | * Operation getScheduledPackage 49 | * 50 | * @param array $queryParams 51 | * - *amazonOrderId* string - An Amazon-defined order identifier. Identifies the order that the seller wants to deliver using Amazon Easy Ship. 52 | * - *marketplaceId* string - An identifier for the marketplace in which the seller is selling. 53 | * 54 | */ 55 | public function getScheduledPackage($queryParams = []) 56 | { 57 | return $this->send("/easyShip/2022-03-23/package", [ 58 | 'method' => 'GET', 59 | 'query' => $queryParams, 60 | ]); 61 | } 62 | 63 | public function getScheduledPackageAsync($queryParams = []) 64 | { 65 | return $this->sendAsync("/easyShip/2022-03-23/package", [ 66 | 'method' => 'GET', 67 | 'query' => $queryParams, 68 | ]); 69 | } 70 | 71 | /** 72 | * Operation createScheduledPackage 73 | * 74 | */ 75 | public function createScheduledPackage($body = []) 76 | { 77 | return $this->send("/easyShip/2022-03-23/package", [ 78 | 'method' => 'POST', 79 | 'json' => $body 80 | ]); 81 | } 82 | 83 | public function createScheduledPackageAsync($body = []) 84 | { 85 | return $this->sendAsync("/easyShip/2022-03-23/package", [ 86 | 'method' => 'POST', 87 | 'json' => $body 88 | ]); 89 | } 90 | 91 | /** 92 | * Operation updateScheduledPackages 93 | * 94 | */ 95 | public function updateScheduledPackages($body = []) 96 | { 97 | return $this->send("/easyShip/2022-03-23/package", [ 98 | 'method' => 'PATCH', 99 | 'json' => $body 100 | ]); 101 | } 102 | 103 | public function updateScheduledPackagesAsync($body = []) 104 | { 105 | return $this->sendAsync("/easyShip/2022-03-23/package", [ 106 | 'method' => 'PATCH', 107 | 'json' => $body 108 | ]); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/Api/FbaInboundEligibility.php: -------------------------------------------------------------------------------- 1 | send("/fba/inbound/v1/eligibility/itemPreview", [ 29 | 'method' => 'GET', 30 | 'query' => $queryParams, 31 | ]); 32 | } 33 | 34 | public function getItemEligibilityPreviewAsync($queryParams = []) 35 | { 36 | return $this->sendAsync("/fba/inbound/v1/eligibility/itemPreview", [ 37 | 'method' => 'GET', 38 | 'query' => $queryParams, 39 | ]); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Api/FbaInventory.php: -------------------------------------------------------------------------------- 1 | send("/fba/inventory/v1/summaries", [ 33 | 'method' => 'GET', 34 | 'query' => $queryParams, 35 | ]); 36 | } 37 | 38 | public function getInventorySummariesAsync($queryParams = []) 39 | { 40 | return $this->sendAsync("/fba/inventory/v1/summaries", [ 41 | 'method' => 'GET', 42 | 'query' => $queryParams, 43 | ]); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Api/FbaSmallAndLight.php: -------------------------------------------------------------------------------- 1 | send("/fba/smallAndLight/v1/enrollments/{$sellerSKU}", [ 29 | 'method' => 'GET', 30 | 'query' => $queryParams, 31 | ]); 32 | } 33 | 34 | public function getSmallAndLightEnrollmentBySellerSKUAsync($sellerSKU, $queryParams = []) 35 | { 36 | return $this->sendAsync("/fba/smallAndLight/v1/enrollments/{$sellerSKU}", [ 37 | 'method' => 'GET', 38 | 'query' => $queryParams, 39 | ]); 40 | } 41 | 42 | /** 43 | * Operation putSmallAndLightEnrollmentBySellerSKU 44 | * 45 | * @param string $sellerSKU The seller SKU that identifies the item. 46 | * 47 | * @param array $queryParams 48 | * - *marketplaceIds* array - The marketplace in which to enroll the item. Note: Accepts a single marketplace only. 49 | * 50 | */ 51 | public function putSmallAndLightEnrollmentBySellerSKU($sellerSKU, $queryParams = []) 52 | { 53 | return $this->send("/fba/smallAndLight/v1/enrollments/{$sellerSKU}", [ 54 | 'method' => 'PUT', 55 | 'query' => $queryParams, 56 | ]); 57 | } 58 | 59 | public function putSmallAndLightEnrollmentBySellerSKUAsync($sellerSKU, $queryParams = []) 60 | { 61 | return $this->sendAsync("/fba/smallAndLight/v1/enrollments/{$sellerSKU}", [ 62 | 'method' => 'PUT', 63 | 'query' => $queryParams, 64 | ]); 65 | } 66 | 67 | /** 68 | * Operation deleteSmallAndLightEnrollmentBySellerSKU 69 | * 70 | * @param string $sellerSKU The seller SKU that identifies the item. 71 | * 72 | * @param array $queryParams 73 | * - *marketplaceIds* array - The marketplace in which to remove the item from the Small and Light program. Note: Accepts a single marketplace only. 74 | * 75 | */ 76 | public function deleteSmallAndLightEnrollmentBySellerSKU($sellerSKU, $queryParams = []) 77 | { 78 | return $this->send("/fba/smallAndLight/v1/enrollments/{$sellerSKU}", [ 79 | 'method' => 'DELETE', 80 | 'query' => $queryParams, 81 | ]); 82 | } 83 | 84 | public function deleteSmallAndLightEnrollmentBySellerSKUAsync($sellerSKU, $queryParams = []) 85 | { 86 | return $this->sendAsync("/fba/smallAndLight/v1/enrollments/{$sellerSKU}", [ 87 | 'method' => 'DELETE', 88 | 'query' => $queryParams, 89 | ]); 90 | } 91 | 92 | /** 93 | * Operation getSmallAndLightEligibilityBySellerSKU 94 | * 95 | * @param string $sellerSKU The seller SKU that identifies the item. 96 | * 97 | * @param array $queryParams 98 | * - *marketplaceIds* array - The marketplace for which the eligibility status is retrieved. NOTE: Accepts a single marketplace only. 99 | * 100 | */ 101 | public function getSmallAndLightEligibilityBySellerSKU($sellerSKU, $queryParams = []) 102 | { 103 | return $this->send("/fba/smallAndLight/v1/eligibilities/{$sellerSKU}", [ 104 | 'method' => 'GET', 105 | 'query' => $queryParams, 106 | ]); 107 | } 108 | 109 | public function getSmallAndLightEligibilityBySellerSKUAsync($sellerSKU, $queryParams = []) 110 | { 111 | return $this->sendAsync("/fba/smallAndLight/v1/eligibilities/{$sellerSKU}", [ 112 | 'method' => 'GET', 113 | 'query' => $queryParams, 114 | ]); 115 | } 116 | 117 | /** 118 | * Operation getSmallAndLightFeePreview 119 | * 120 | */ 121 | public function getSmallAndLightFeePreview($body = []) 122 | { 123 | return $this->send("/fba/smallAndLight/v1/feePreviews", [ 124 | 'method' => 'POST', 125 | 'json' => $body 126 | ]); 127 | } 128 | 129 | public function getSmallAndLightFeePreviewAsync($body = []) 130 | { 131 | return $this->sendAsync("/fba/smallAndLight/v1/feePreviews", [ 132 | 'method' => 'POST', 133 | 'json' => $body 134 | ]); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /src/Api/Feeds.php: -------------------------------------------------------------------------------- 1 | send("/feeds/2021-06-30/feeds", [ 33 | 'method' => 'GET', 34 | 'query' => $queryParams, 35 | ]); 36 | } 37 | 38 | public function getFeedsAsync($queryParams = []) 39 | { 40 | return $this->sendAsync("/feeds/2021-06-30/feeds", [ 41 | 'method' => 'GET', 42 | 'query' => $queryParams, 43 | ]); 44 | } 45 | 46 | /** 47 | * Operation createFeed 48 | * 49 | */ 50 | public function createFeed($body = []) 51 | { 52 | return $this->send("/feeds/2021-06-30/feeds", [ 53 | 'method' => 'POST', 54 | 'json' => $body 55 | ]); 56 | } 57 | 58 | public function createFeedAsync($body = []) 59 | { 60 | return $this->sendAsync("/feeds/2021-06-30/feeds", [ 61 | 'method' => 'POST', 62 | 'json' => $body 63 | ]); 64 | } 65 | 66 | /** 67 | * Operation cancelFeed 68 | * 69 | * @param string $feedId The identifier for the feed. This identifier is unique only in combination with a seller ID. 70 | * 71 | */ 72 | public function cancelFeed($feedId) 73 | { 74 | return $this->send("/feeds/2021-06-30/feeds/{$feedId}", [ 75 | 'method' => 'DELETE', 76 | ]); 77 | } 78 | 79 | public function cancelFeedAsync($feedId) 80 | { 81 | return $this->sendAsync("/feeds/2021-06-30/feeds/{$feedId}", [ 82 | 'method' => 'DELETE', 83 | ]); 84 | } 85 | 86 | /** 87 | * Operation getFeed 88 | * 89 | * @param string $feedId The identifier for the feed. This identifier is unique only in combination with a seller ID. 90 | * 91 | */ 92 | public function getFeed($feedId) 93 | { 94 | return $this->send("/feeds/2021-06-30/feeds/{$feedId}", [ 95 | 'method' => 'GET', 96 | ]); 97 | } 98 | 99 | public function getFeedAsync($feedId) 100 | { 101 | return $this->sendAsync("/feeds/2021-06-30/feeds/{$feedId}", [ 102 | 'method' => 'GET', 103 | ]); 104 | } 105 | 106 | /** 107 | * Operation createFeedDocument 108 | * 109 | */ 110 | public function createFeedDocument($body = []) 111 | { 112 | return $this->send("/feeds/2021-06-30/documents", [ 113 | 'method' => 'POST', 114 | 'json' => $body 115 | ]); 116 | } 117 | 118 | public function createFeedDocumentAsync($body = []) 119 | { 120 | return $this->sendAsync("/feeds/2021-06-30/documents", [ 121 | 'method' => 'POST', 122 | 'json' => $body 123 | ]); 124 | } 125 | 126 | /** 127 | * Operation getFeedDocument 128 | * 129 | * @param string $feedDocumentId The identifier of the feed document. 130 | * 131 | */ 132 | public function getFeedDocument($feedDocumentId) 133 | { 134 | return $this->send("/feeds/2021-06-30/documents/{$feedDocumentId}", [ 135 | 'method' => 'GET', 136 | ]); 137 | } 138 | 139 | public function getFeedDocumentAsync($feedDocumentId) 140 | { 141 | return $this->sendAsync("/feeds/2021-06-30/documents/{$feedDocumentId}", [ 142 | 'method' => 'GET', 143 | ]); 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /src/Api/Finances.php: -------------------------------------------------------------------------------- 1 | send("/finances/v0/financialEventGroups", [ 30 | 'method' => 'GET', 31 | 'query' => $queryParams, 32 | ]); 33 | } 34 | 35 | public function listFinancialEventGroupsAsync($queryParams = []) 36 | { 37 | return $this->sendAsync("/finances/v0/financialEventGroups", [ 38 | 'method' => 'GET', 39 | 'query' => $queryParams, 40 | ]); 41 | } 42 | 43 | /** 44 | * Operation listFinancialEventsByGroupId 45 | * 46 | * @param string $eventGroupId The identifier of the financial event group to which the events belong. 47 | * 48 | * @param array $queryParams 49 | * - *maxResultsPerPage* integer - The maximum number of results to return per page. 50 | * - *nextToken* string - A string token returned in the response of your previous request. 51 | * 52 | */ 53 | public function listFinancialEventsByGroupId($eventGroupId, $queryParams = []) 54 | { 55 | return $this->send("/finances/v0/financialEventGroups/{$eventGroupId}/financialEvents", [ 56 | 'method' => 'GET', 57 | 'query' => $queryParams, 58 | ]); 59 | } 60 | 61 | public function listFinancialEventsByGroupIdAsync($eventGroupId, $queryParams = []) 62 | { 63 | return $this->sendAsync("/finances/v0/financialEventGroups/{$eventGroupId}/financialEvents", [ 64 | 'method' => 'GET', 65 | 'query' => $queryParams, 66 | ]); 67 | } 68 | 69 | /** 70 | * Operation listFinancialEventsByOrderId 71 | * 72 | * @param string $orderId An Amazon-defined order identifier, in 3-7-7 format. 73 | * 74 | * @param array $queryParams 75 | * - *maxResultsPerPage* integer - The maximum number of results to return per page. 76 | * - *nextToken* string - A string token returned in the response of your previous request. 77 | * 78 | */ 79 | public function listFinancialEventsByOrderId($orderId, $queryParams = []) 80 | { 81 | return $this->send("/finances/v0/orders/{$orderId}/financialEvents", [ 82 | 'method' => 'GET', 83 | 'query' => $queryParams, 84 | ]); 85 | } 86 | 87 | public function listFinancialEventsByOrderIdAsync($orderId, $queryParams = []) 88 | { 89 | return $this->sendAsync("/finances/v0/orders/{$orderId}/financialEvents", [ 90 | 'method' => 'GET', 91 | 'query' => $queryParams, 92 | ]); 93 | } 94 | 95 | /** 96 | * Operation listFinancialEvents 97 | * 98 | * @param array $queryParams 99 | * - *maxResultsPerPage* integer - The maximum number of results to return per page. 100 | * - *postedAfter* string - A date used for selecting financial events posted after (or at) a specified time. The date-time must be no later than two minutes before the request was submitted, in ISO 8601 date time format. 101 | * - *postedBefore* string - A date used for selecting financial events posted before (but not at) a specified time. The date-time must be later than PostedAfter and no later than two minutes before the request was submitted, in ISO 8601 date time format. If PostedAfter and PostedBefore are more than 180 days apart, no financial events are returned. You must specify the PostedAfter parameter if you specify the PostedBefore parameter. Default: Now minus two minutes. 102 | * - *nextToken* string - A string token returned in the response of your previous request. 103 | * 104 | */ 105 | public function listFinancialEvents($queryParams = []) 106 | { 107 | return $this->send("/finances/v0/financialEvents", [ 108 | 'method' => 'GET', 109 | 'query' => $queryParams, 110 | ]); 111 | } 112 | 113 | public function listFinancialEventsAsync($queryParams = []) 114 | { 115 | return $this->sendAsync("/finances/v0/financialEvents", [ 116 | 'method' => 'GET', 117 | 'query' => $queryParams, 118 | ]); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/Api/FulfillmentOutbound.php: -------------------------------------------------------------------------------- 1 | send("/fba/outbound/2020-07-01/fulfillmentOrders/preview", [ 24 | 'method' => 'POST', 25 | 'json' => $body 26 | ]); 27 | } 28 | 29 | public function getFulfillmentPreviewAsync($body = []) 30 | { 31 | return $this->sendAsync("/fba/outbound/2020-07-01/fulfillmentOrders/preview", [ 32 | 'method' => 'POST', 33 | 'json' => $body 34 | ]); 35 | } 36 | 37 | /** 38 | * Operation listAllFulfillmentOrders 39 | * 40 | * @param array $queryParams 41 | * - *queryStartDate* string - A date used to select fulfillment orders that were last updated after (or at) a specified time. An update is defined as any change in fulfillment order status, including the creation of a new fulfillment order. 42 | * - *nextToken* string - A string token returned in the response to your previous request. 43 | * 44 | */ 45 | public function listAllFulfillmentOrders($queryParams = []) 46 | { 47 | return $this->send("/fba/outbound/2020-07-01/fulfillmentOrders", [ 48 | 'method' => 'GET', 49 | 'query' => $queryParams, 50 | ]); 51 | } 52 | 53 | public function listAllFulfillmentOrdersAsync($queryParams = []) 54 | { 55 | return $this->sendAsync("/fba/outbound/2020-07-01/fulfillmentOrders", [ 56 | 'method' => 'GET', 57 | 'query' => $queryParams, 58 | ]); 59 | } 60 | 61 | /** 62 | * Operation createFulfillmentOrder 63 | * 64 | */ 65 | public function createFulfillmentOrder($body = []) 66 | { 67 | return $this->send("/fba/outbound/2020-07-01/fulfillmentOrders", [ 68 | 'method' => 'POST', 69 | 'json' => $body 70 | ]); 71 | } 72 | 73 | public function createFulfillmentOrderAsync($body = []) 74 | { 75 | return $this->sendAsync("/fba/outbound/2020-07-01/fulfillmentOrders", [ 76 | 'method' => 'POST', 77 | 'json' => $body 78 | ]); 79 | } 80 | 81 | /** 82 | * Operation getPackageTrackingDetails 83 | * 84 | * @param array $queryParams 85 | * - *packageNumber* integer - The unencrypted package identifier returned by the getFulfillmentOrder operation. 86 | * 87 | */ 88 | public function getPackageTrackingDetails($queryParams = []) 89 | { 90 | return $this->send("/fba/outbound/2020-07-01/tracking", [ 91 | 'method' => 'GET', 92 | 'query' => $queryParams, 93 | ]); 94 | } 95 | 96 | public function getPackageTrackingDetailsAsync($queryParams = []) 97 | { 98 | return $this->sendAsync("/fba/outbound/2020-07-01/tracking", [ 99 | 'method' => 'GET', 100 | 'query' => $queryParams, 101 | ]); 102 | } 103 | 104 | /** 105 | * Operation listReturnReasonCodes 106 | * 107 | * @param array $queryParams 108 | * - *sellerSku* string - The seller SKU for which return reason codes are required. 109 | * - *marketplaceId* string - The marketplace for which the seller wants return reason codes. 110 | * - *sellerFulfillmentOrderId* string - The identifier assigned to the item by the seller when the fulfillment order was created. The service uses this value to determine the marketplace for which the seller wants return reason codes. 111 | * - *language* string - The language that the TranslatedDescription property of the ReasonCodeDetails response object should be translated into. 112 | * 113 | */ 114 | public function listReturnReasonCodes($queryParams = []) 115 | { 116 | return $this->send("/fba/outbound/2020-07-01/returnReasonCodes", [ 117 | 'method' => 'GET', 118 | 'query' => $queryParams, 119 | ]); 120 | } 121 | 122 | public function listReturnReasonCodesAsync($queryParams = []) 123 | { 124 | return $this->sendAsync("/fba/outbound/2020-07-01/returnReasonCodes", [ 125 | 'method' => 'GET', 126 | 'query' => $queryParams, 127 | ]); 128 | } 129 | 130 | /** 131 | * Operation createFulfillmentReturn 132 | * 133 | * @param string $sellerFulfillmentOrderId An identifier assigned by the seller to the fulfillment order at the time it was created. The seller uses their own records to find the correct SellerFulfillmentOrderId value based on the buyer's request to return items. 134 | * 135 | */ 136 | public function createFulfillmentReturn($sellerFulfillmentOrderId, $body = []) 137 | { 138 | return $this->send("/fba/outbound/2020-07-01/fulfillmentOrders/{$sellerFulfillmentOrderId}/return", [ 139 | 'method' => 'PUT', 140 | 'json' => $body 141 | ]); 142 | } 143 | 144 | public function createFulfillmentReturnAsync($sellerFulfillmentOrderId, $body = []) 145 | { 146 | return $this->sendAsync("/fba/outbound/2020-07-01/fulfillmentOrders/{$sellerFulfillmentOrderId}/return", [ 147 | 'method' => 'PUT', 148 | 'json' => $body 149 | ]); 150 | } 151 | 152 | /** 153 | * Operation getFulfillmentOrder 154 | * 155 | * @param string $sellerFulfillmentOrderId The identifier assigned to the item by the seller when the fulfillment order was created. 156 | * 157 | */ 158 | public function getFulfillmentOrder($sellerFulfillmentOrderId) 159 | { 160 | return $this->send("/fba/outbound/2020-07-01/fulfillmentOrders/{$sellerFulfillmentOrderId}", [ 161 | 'method' => 'GET', 162 | ]); 163 | } 164 | 165 | public function getFulfillmentOrderAsync($sellerFulfillmentOrderId) 166 | { 167 | return $this->sendAsync("/fba/outbound/2020-07-01/fulfillmentOrders/{$sellerFulfillmentOrderId}", [ 168 | 'method' => 'GET', 169 | ]); 170 | } 171 | 172 | /** 173 | * Operation updateFulfillmentOrder 174 | * 175 | * @param string $sellerFulfillmentOrderId The identifier assigned to the item by the seller when the fulfillment order was created. 176 | * 177 | */ 178 | public function updateFulfillmentOrder($sellerFulfillmentOrderId, $body = []) 179 | { 180 | return $this->send("/fba/outbound/2020-07-01/fulfillmentOrders/{$sellerFulfillmentOrderId}", [ 181 | 'method' => 'PUT', 182 | 'json' => $body 183 | ]); 184 | } 185 | 186 | public function updateFulfillmentOrderAsync($sellerFulfillmentOrderId, $body = []) 187 | { 188 | return $this->sendAsync("/fba/outbound/2020-07-01/fulfillmentOrders/{$sellerFulfillmentOrderId}", [ 189 | 'method' => 'PUT', 190 | 'json' => $body 191 | ]); 192 | } 193 | 194 | /** 195 | * Operation cancelFulfillmentOrder 196 | * 197 | * @param string $sellerFulfillmentOrderId The identifier assigned to the item by the seller when the fulfillment order was created. 198 | * 199 | */ 200 | public function cancelFulfillmentOrder($sellerFulfillmentOrderId) 201 | { 202 | return $this->send("/fba/outbound/2020-07-01/fulfillmentOrders/{$sellerFulfillmentOrderId}/cancel", [ 203 | 'method' => 'PUT', 204 | ]); 205 | } 206 | 207 | public function cancelFulfillmentOrderAsync($sellerFulfillmentOrderId) 208 | { 209 | return $this->sendAsync("/fba/outbound/2020-07-01/fulfillmentOrders/{$sellerFulfillmentOrderId}/cancel", [ 210 | 'method' => 'PUT', 211 | ]); 212 | } 213 | 214 | /** 215 | * Operation getFeatures 216 | * 217 | * @param array $queryParams 218 | * - *marketplaceId* string - The marketplace for which to return the list of features. 219 | * 220 | */ 221 | public function getFeatures($queryParams = []) 222 | { 223 | return $this->send("/fba/outbound/2020-07-01/features", [ 224 | 'method' => 'GET', 225 | 'query' => $queryParams, 226 | ]); 227 | } 228 | 229 | public function getFeaturesAsync($queryParams = []) 230 | { 231 | return $this->sendAsync("/fba/outbound/2020-07-01/features", [ 232 | 'method' => 'GET', 233 | 'query' => $queryParams, 234 | ]); 235 | } 236 | 237 | /** 238 | * Operation getFeatureInventory 239 | * 240 | * @param string $featureName The name of the feature for which to return a list of eligible inventory. 241 | * 242 | * @param array $queryParams 243 | * - *marketplaceId* string - The marketplace for which to return a list of the inventory that is eligible for the specified feature. 244 | * - *nextToken* string - A string token returned in the response to your previous request that is used to return the next response page. A value of null will return the first page. 245 | * 246 | */ 247 | public function getFeatureInventory($featureName, $queryParams = []) 248 | { 249 | return $this->send("/fba/outbound/2020-07-01/features/inventory/{$featureName}", [ 250 | 'method' => 'GET', 251 | 'query' => $queryParams, 252 | ]); 253 | } 254 | 255 | public function getFeatureInventoryAsync($featureName, $queryParams = []) 256 | { 257 | return $this->sendAsync("/fba/outbound/2020-07-01/features/inventory/{$featureName}", [ 258 | 'method' => 'GET', 259 | 'query' => $queryParams, 260 | ]); 261 | } 262 | 263 | /** 264 | * Operation getFeatureSKU 265 | * 266 | * @param string $featureName The name of the feature. 267 | * @param string $sellerSku Used to identify an item in the given marketplace. SellerSKU is qualified by the seller's SellerId, which is included with every operation that you submit. 268 | * 269 | * @param array $queryParams 270 | * - *marketplaceId* string - The marketplace for which to return the count. 271 | * 272 | */ 273 | public function getFeatureSKU($featureName, $sellerSku, $queryParams = []) 274 | { 275 | return $this->send("/fba/outbound/2020-07-01/features/inventory/{$featureName}/{$sellerSku}", [ 276 | 'method' => 'GET', 277 | 'query' => $queryParams, 278 | ]); 279 | } 280 | 281 | public function getFeatureSKUAsync($featureName, $sellerSku, $queryParams = []) 282 | { 283 | return $this->sendAsync("/fba/outbound/2020-07-01/features/inventory/{$featureName}/{$sellerSku}", [ 284 | 'method' => 'GET', 285 | 'query' => $queryParams, 286 | ]); 287 | } 288 | } 289 | -------------------------------------------------------------------------------- /src/Api/ListingsItems.php: -------------------------------------------------------------------------------- 1 | send("/listings/2021-08-01/items/{$sellerId}/{$sku}", [ 33 | 'method' => 'DELETE', 34 | 'query' => $queryParams, 35 | ]); 36 | } 37 | 38 | public function deleteListingsItemAsync($sellerId, $sku, $queryParams = []) 39 | { 40 | return $this->sendAsync("/listings/2021-08-01/items/{$sellerId}/{$sku}", [ 41 | 'method' => 'DELETE', 42 | 'query' => $queryParams, 43 | ]); 44 | } 45 | 46 | /** 47 | * Operation getListingsItem 48 | * 49 | * @param string $sellerId A selling partner identifier, such as a merchant account or vendor code. 50 | * @param string $sku A selling partner provided identifier for an Amazon listing. 51 | * 52 | * @param array $queryParams 53 | * - *marketplaceIds* array - A comma-delimited list of Amazon marketplace identifiers for the request. 54 | * - *issueLocale* string - A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: "en_US", "fr_CA", "fr_FR". Localized messages default to "en_US" when a localization is not available in the specified locale. 55 | * - *includedData* array - A comma-delimited list of data sets to include in the response. Default: summaries. 56 | * 57 | */ 58 | public function getListingsItem($sellerId, $sku, $queryParams = []) 59 | { 60 | return $this->send("/listings/2021-08-01/items/{$sellerId}/{$sku}", [ 61 | 'method' => 'GET', 62 | 'query' => $queryParams, 63 | ]); 64 | } 65 | 66 | public function getListingsItemAsync($sellerId, $sku, $queryParams = []) 67 | { 68 | return $this->sendAsync("/listings/2021-08-01/items/{$sellerId}/{$sku}", [ 69 | 'method' => 'GET', 70 | 'query' => $queryParams, 71 | ]); 72 | } 73 | 74 | /** 75 | * Operation patchListingsItem 76 | * 77 | * @param string $sellerId A selling partner identifier, such as a merchant account or vendor code. 78 | * @param string $sku A selling partner provided identifier for an Amazon listing. 79 | * 80 | * @param array $queryParams 81 | * - *marketplaceIds* array - A comma-delimited list of Amazon marketplace identifiers for the request. 82 | * - *issueLocale* string - A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: "en_US", "fr_CA", "fr_FR". Localized messages default to "en_US" when a localization is not available in the specified locale. 83 | * 84 | */ 85 | public function patchListingsItem($sellerId, $sku, $queryParams = [], $body = []) 86 | { 87 | return $this->send("/listings/2021-08-01/items/{$sellerId}/{$sku}", [ 88 | 'method' => 'PATCH', 89 | 'query' => $queryParams, 90 | 'json' => $body 91 | ]); 92 | } 93 | 94 | public function patchListingsItemAsync($sellerId, $sku, $queryParams = [], $body = []) 95 | { 96 | return $this->sendAsync("/listings/2021-08-01/items/{$sellerId}/{$sku}", [ 97 | 'method' => 'PATCH', 98 | 'query' => $queryParams, 99 | 'json' => $body 100 | ]); 101 | } 102 | 103 | /** 104 | * Operation putListingsItem 105 | * 106 | * @param string $sellerId A selling partner identifier, such as a merchant account or vendor code. 107 | * @param string $sku A selling partner provided identifier for an Amazon listing. 108 | * 109 | * @param array $queryParams 110 | * - *marketplaceIds* array - A comma-delimited list of Amazon marketplace identifiers for the request. 111 | * - *issueLocale* string - A locale for localization of issues. When not provided, the default language code of the first marketplace is used. Examples: "en_US", "fr_CA", "fr_FR". Localized messages default to "en_US" when a localization is not available in the specified locale. 112 | * 113 | */ 114 | public function putListingsItem($sellerId, $sku, $queryParams = [], $body = []) 115 | { 116 | return $this->send("/listings/2021-08-01/items/{$sellerId}/{$sku}", [ 117 | 'method' => 'PUT', 118 | 'query' => $queryParams, 119 | 'json' => $body 120 | ]); 121 | } 122 | 123 | public function putListingsItemAsync($sellerId, $sku, $queryParams = [], $body = []) 124 | { 125 | return $this->sendAsync("/listings/2021-08-01/items/{$sellerId}/{$sku}", [ 126 | 'method' => 'PUT', 127 | 'query' => $queryParams, 128 | 'json' => $body 129 | ]); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /src/Api/ListingsRestrictions.php: -------------------------------------------------------------------------------- 1 | send("/listings/2021-08-01/restrictions", [ 33 | 'method' => 'GET', 34 | 'query' => $queryParams, 35 | ]); 36 | } 37 | 38 | public function getListingsRestrictionsAsync($queryParams = []) 39 | { 40 | return $this->sendAsync("/listings/2021-08-01/restrictions", [ 41 | 'method' => 'GET', 42 | 'query' => $queryParams, 43 | ]); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Api/MerchantFulfillment.php: -------------------------------------------------------------------------------- 1 | send("/mfn/v0/eligibleServices", [ 24 | 'method' => 'POST', 25 | 'json' => $body 26 | ]); 27 | } 28 | 29 | public function getEligibleShipmentServicesOldAsync($body = []) 30 | { 31 | return $this->sendAsync("/mfn/v0/eligibleServices", [ 32 | 'method' => 'POST', 33 | 'json' => $body 34 | ]); 35 | } 36 | 37 | /** 38 | * Operation getEligibleShipmentServices 39 | * 40 | */ 41 | public function getEligibleShipmentServices($body = []) 42 | { 43 | return $this->send("/mfn/v0/eligibleShippingServices", [ 44 | 'method' => 'POST', 45 | 'json' => $body 46 | ]); 47 | } 48 | 49 | public function getEligibleShipmentServicesAsync($body = []) 50 | { 51 | return $this->sendAsync("/mfn/v0/eligibleShippingServices", [ 52 | 'method' => 'POST', 53 | 'json' => $body 54 | ]); 55 | } 56 | 57 | /** 58 | * Operation getShipment 59 | * 60 | * @param string $shipmentId The Amazon-defined shipment identifier for the shipment. 61 | * 62 | */ 63 | public function getShipment($shipmentId) 64 | { 65 | return $this->send("/mfn/v0/shipments/{$shipmentId}", [ 66 | 'method' => 'GET', 67 | ]); 68 | } 69 | 70 | public function getShipmentAsync($shipmentId) 71 | { 72 | return $this->sendAsync("/mfn/v0/shipments/{$shipmentId}", [ 73 | 'method' => 'GET', 74 | ]); 75 | } 76 | 77 | /** 78 | * Operation cancelShipment 79 | * 80 | * @param string $shipmentId The Amazon-defined shipment identifier for the shipment to cancel. 81 | * 82 | */ 83 | public function cancelShipment($shipmentId) 84 | { 85 | return $this->send("/mfn/v0/shipments/{$shipmentId}", [ 86 | 'method' => 'DELETE', 87 | ]); 88 | } 89 | 90 | public function cancelShipmentAsync($shipmentId) 91 | { 92 | return $this->sendAsync("/mfn/v0/shipments/{$shipmentId}", [ 93 | 'method' => 'DELETE', 94 | ]); 95 | } 96 | 97 | /** 98 | * Operation cancelShipmentOld 99 | * 100 | * @param string $shipmentId The Amazon-defined shipment identifier for the shipment to cancel. 101 | * 102 | */ 103 | public function cancelShipmentOld($shipmentId) 104 | { 105 | return $this->send("/mfn/v0/shipments/{$shipmentId}/cancel", [ 106 | 'method' => 'PUT', 107 | ]); 108 | } 109 | 110 | public function cancelShipmentOldAsync($shipmentId) 111 | { 112 | return $this->sendAsync("/mfn/v0/shipments/{$shipmentId}/cancel", [ 113 | 'method' => 'PUT', 114 | ]); 115 | } 116 | 117 | /** 118 | * Operation createShipment 119 | * 120 | */ 121 | public function createShipment($body = []) 122 | { 123 | return $this->send("/mfn/v0/shipments", [ 124 | 'method' => 'POST', 125 | 'json' => $body 126 | ]); 127 | } 128 | 129 | public function createShipmentAsync($body = []) 130 | { 131 | return $this->sendAsync("/mfn/v0/shipments", [ 132 | 'method' => 'POST', 133 | 'json' => $body 134 | ]); 135 | } 136 | 137 | /** 138 | * Operation getAdditionalSellerInputsOld 139 | * 140 | */ 141 | public function getAdditionalSellerInputsOld($body = []) 142 | { 143 | return $this->send("/mfn/v0/sellerInputs", [ 144 | 'method' => 'POST', 145 | 'json' => $body 146 | ]); 147 | } 148 | 149 | public function getAdditionalSellerInputsOldAsync($body = []) 150 | { 151 | return $this->sendAsync("/mfn/v0/sellerInputs", [ 152 | 'method' => 'POST', 153 | 'json' => $body 154 | ]); 155 | } 156 | 157 | /** 158 | * Operation getAdditionalSellerInputs 159 | * 160 | */ 161 | public function getAdditionalSellerInputs($body = []) 162 | { 163 | return $this->send("/mfn/v0/additionalSellerInputs", [ 164 | 'method' => 'POST', 165 | 'json' => $body 166 | ]); 167 | } 168 | 169 | public function getAdditionalSellerInputsAsync($body = []) 170 | { 171 | return $this->sendAsync("/mfn/v0/additionalSellerInputs", [ 172 | 'method' => 'POST', 173 | 'json' => $body 174 | ]); 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /src/Api/Messaging.php: -------------------------------------------------------------------------------- 1 | JSON Hypertext Application Language (HAL) standard. 11 | */ 12 | namespace DoubleBreak\Spapi\Api; 13 | use DoubleBreak\Spapi\Client; 14 | 15 | class Messaging extends Client { 16 | 17 | /** 18 | * Operation getMessagingActionsForOrder 19 | * 20 | * @param string $amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available message types. 21 | * 22 | * @param array $queryParams 23 | * - *marketplaceIds* array - A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. 24 | * 25 | */ 26 | public function getMessagingActionsForOrder($amazonOrderId, $queryParams = []) 27 | { 28 | return $this->send("/messaging/v1/orders/{$amazonOrderId}", [ 29 | 'method' => 'GET', 30 | 'query' => $queryParams, 31 | ]); 32 | } 33 | 34 | public function getMessagingActionsForOrderAsync($amazonOrderId, $queryParams = []) 35 | { 36 | return $this->sendAsync("/messaging/v1/orders/{$amazonOrderId}", [ 37 | 'method' => 'GET', 38 | 'query' => $queryParams, 39 | ]); 40 | } 41 | 42 | /** 43 | * Operation confirmCustomizationDetails 44 | * 45 | * @param string $amazonOrderId An Amazon order identifier. This specifies the order for which a message is sent. 46 | * 47 | * @param array $queryParams 48 | * - *marketplaceIds* array - A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. 49 | * 50 | */ 51 | public function confirmCustomizationDetails($amazonOrderId, $queryParams = [], $body = []) 52 | { 53 | return $this->send("/messaging/v1/orders/{$amazonOrderId}/messages/confirmCustomizationDetails", [ 54 | 'method' => 'POST', 55 | 'query' => $queryParams, 56 | 'json' => $body 57 | ]); 58 | } 59 | 60 | public function confirmCustomizationDetailsAsync($amazonOrderId, $queryParams = [], $body = []) 61 | { 62 | return $this->sendAsync("/messaging/v1/orders/{$amazonOrderId}/messages/confirmCustomizationDetails", [ 63 | 'method' => 'POST', 64 | 'query' => $queryParams, 65 | 'json' => $body 66 | ]); 67 | } 68 | 69 | /** 70 | * Operation createConfirmDeliveryDetails 71 | * 72 | * @param string $amazonOrderId An Amazon order identifier. This specifies the order for which a message is sent. 73 | * 74 | * @param array $queryParams 75 | * - *marketplaceIds* array - A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. 76 | * 77 | */ 78 | public function createConfirmDeliveryDetails($amazonOrderId, $queryParams = [], $body = []) 79 | { 80 | return $this->send("/messaging/v1/orders/{$amazonOrderId}/messages/confirmDeliveryDetails", [ 81 | 'method' => 'POST', 82 | 'query' => $queryParams, 83 | 'json' => $body 84 | ]); 85 | } 86 | 87 | public function createConfirmDeliveryDetailsAsync($amazonOrderId, $queryParams = [], $body = []) 88 | { 89 | return $this->sendAsync("/messaging/v1/orders/{$amazonOrderId}/messages/confirmDeliveryDetails", [ 90 | 'method' => 'POST', 91 | 'query' => $queryParams, 92 | 'json' => $body 93 | ]); 94 | } 95 | 96 | /** 97 | * Operation createLegalDisclosure 98 | * 99 | * @param string $amazonOrderId An Amazon order identifier. This specifies the order for which a message is sent. 100 | * 101 | * @param array $queryParams 102 | * - *marketplaceIds* array - A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. 103 | * 104 | */ 105 | public function createLegalDisclosure($amazonOrderId, $queryParams = [], $body = []) 106 | { 107 | return $this->send("/messaging/v1/orders/{$amazonOrderId}/messages/legalDisclosure", [ 108 | 'method' => 'POST', 109 | 'query' => $queryParams, 110 | 'json' => $body 111 | ]); 112 | } 113 | 114 | public function createLegalDisclosureAsync($amazonOrderId, $queryParams = [], $body = []) 115 | { 116 | return $this->sendAsync("/messaging/v1/orders/{$amazonOrderId}/messages/legalDisclosure", [ 117 | 'method' => 'POST', 118 | 'query' => $queryParams, 119 | 'json' => $body 120 | ]); 121 | } 122 | 123 | /** 124 | * Operation createNegativeFeedbackRemoval 125 | * 126 | * @param string $amazonOrderId An Amazon order identifier. This specifies the order for which a message is sent. 127 | * 128 | * @param array $queryParams 129 | * - *marketplaceIds* array - A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. 130 | * 131 | */ 132 | public function createNegativeFeedbackRemoval($amazonOrderId, $queryParams = []) 133 | { 134 | return $this->send("/messaging/v1/orders/{$amazonOrderId}/messages/negativeFeedbackRemoval", [ 135 | 'method' => 'POST', 136 | 'query' => $queryParams, 137 | ]); 138 | } 139 | 140 | public function createNegativeFeedbackRemovalAsync($amazonOrderId, $queryParams = []) 141 | { 142 | return $this->sendAsync("/messaging/v1/orders/{$amazonOrderId}/messages/negativeFeedbackRemoval", [ 143 | 'method' => 'POST', 144 | 'query' => $queryParams, 145 | ]); 146 | } 147 | 148 | /** 149 | * Operation createConfirmOrderDetails 150 | * 151 | * @param string $amazonOrderId An Amazon order identifier. This specifies the order for which a message is sent. 152 | * 153 | * @param array $queryParams 154 | * - *marketplaceIds* array - A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. 155 | * 156 | */ 157 | public function createConfirmOrderDetails($amazonOrderId, $queryParams = [], $body = []) 158 | { 159 | return $this->send("/messaging/v1/orders/{$amazonOrderId}/messages/confirmOrderDetails", [ 160 | 'method' => 'POST', 161 | 'query' => $queryParams, 162 | 'json' => $body 163 | ]); 164 | } 165 | 166 | public function createConfirmOrderDetailsAsync($amazonOrderId, $queryParams = [], $body = []) 167 | { 168 | return $this->sendAsync("/messaging/v1/orders/{$amazonOrderId}/messages/confirmOrderDetails", [ 169 | 'method' => 'POST', 170 | 'query' => $queryParams, 171 | 'json' => $body 172 | ]); 173 | } 174 | 175 | /** 176 | * Operation createConfirmServiceDetails 177 | * 178 | * @param string $amazonOrderId An Amazon order identifier. This specifies the order for which a message is sent. 179 | * 180 | * @param array $queryParams 181 | * - *marketplaceIds* array - A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. 182 | * 183 | */ 184 | public function createConfirmServiceDetails($amazonOrderId, $queryParams = [], $body = []) 185 | { 186 | return $this->send("/messaging/v1/orders/{$amazonOrderId}/messages/confirmServiceDetails", [ 187 | 'method' => 'POST', 188 | 'query' => $queryParams, 189 | 'json' => $body 190 | ]); 191 | } 192 | 193 | public function createConfirmServiceDetailsAsync($amazonOrderId, $queryParams = [], $body = []) 194 | { 195 | return $this->sendAsync("/messaging/v1/orders/{$amazonOrderId}/messages/confirmServiceDetails", [ 196 | 'method' => 'POST', 197 | 'query' => $queryParams, 198 | 'json' => $body 199 | ]); 200 | } 201 | 202 | /** 203 | * Operation CreateAmazonMotors 204 | * 205 | * @param string $amazonOrderId An Amazon order identifier. This specifies the order for which a message is sent. 206 | * 207 | * @param array $queryParams 208 | * - *marketplaceIds* array - A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. 209 | * 210 | */ 211 | public function CreateAmazonMotors($amazonOrderId, $queryParams = [], $body = []) 212 | { 213 | return $this->send("/messaging/v1/orders/{$amazonOrderId}/messages/amazonMotors", [ 214 | 'method' => 'POST', 215 | 'query' => $queryParams, 216 | 'json' => $body 217 | ]); 218 | } 219 | 220 | public function CreateAmazonMotorsAsync($amazonOrderId, $queryParams = [], $body = []) 221 | { 222 | return $this->sendAsync("/messaging/v1/orders/{$amazonOrderId}/messages/amazonMotors", [ 223 | 'method' => 'POST', 224 | 'query' => $queryParams, 225 | 'json' => $body 226 | ]); 227 | } 228 | 229 | /** 230 | * Operation CreateWarranty 231 | * 232 | * @param string $amazonOrderId An Amazon order identifier. This specifies the order for which a message is sent. 233 | * 234 | * @param array $queryParams 235 | * - *marketplaceIds* array - A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. 236 | * 237 | */ 238 | public function CreateWarranty($amazonOrderId, $queryParams = [], $body = []) 239 | { 240 | return $this->send("/messaging/v1/orders/{$amazonOrderId}/messages/warranty", [ 241 | 'method' => 'POST', 242 | 'query' => $queryParams, 243 | 'json' => $body 244 | ]); 245 | } 246 | 247 | public function CreateWarrantyAsync($amazonOrderId, $queryParams = [], $body = []) 248 | { 249 | return $this->sendAsync("/messaging/v1/orders/{$amazonOrderId}/messages/warranty", [ 250 | 'method' => 'POST', 251 | 'query' => $queryParams, 252 | 'json' => $body 253 | ]); 254 | } 255 | 256 | /** 257 | * Operation GetAttributes 258 | * 259 | * @param string $amazonOrderId An Amazon order identifier. This specifies the order for which a message is sent. 260 | * 261 | * @param array $queryParams 262 | * - *marketplaceIds* array - A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. 263 | * 264 | */ 265 | public function GetAttributes($amazonOrderId, $queryParams = []) 266 | { 267 | return $this->send("/messaging/v1/orders/{$amazonOrderId}/attributes", [ 268 | 'method' => 'GET', 269 | 'query' => $queryParams, 270 | ]); 271 | } 272 | 273 | public function GetAttributesAsync($amazonOrderId, $queryParams = []) 274 | { 275 | return $this->sendAsync("/messaging/v1/orders/{$amazonOrderId}/attributes", [ 276 | 'method' => 'GET', 277 | 'query' => $queryParams, 278 | ]); 279 | } 280 | 281 | /** 282 | * Operation createDigitalAccessKey 283 | * 284 | * @param string $amazonOrderId An Amazon order identifier. This specifies the order for which a message is sent. 285 | * 286 | * @param array $queryParams 287 | * - *marketplaceIds* array - A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. 288 | * 289 | */ 290 | public function createDigitalAccessKey($amazonOrderId, $queryParams = [], $body = []) 291 | { 292 | return $this->send("/messaging/v1/orders/{$amazonOrderId}/messages/digitalAccessKey", [ 293 | 'method' => 'POST', 294 | 'query' => $queryParams, 295 | 'json' => $body 296 | ]); 297 | } 298 | 299 | public function createDigitalAccessKeyAsync($amazonOrderId, $queryParams = [], $body = []) 300 | { 301 | return $this->sendAsync("/messaging/v1/orders/{$amazonOrderId}/messages/digitalAccessKey", [ 302 | 'method' => 'POST', 303 | 'query' => $queryParams, 304 | 'json' => $body 305 | ]); 306 | } 307 | 308 | /** 309 | * Operation createUnexpectedProblem 310 | * 311 | * @param string $amazonOrderId An Amazon order identifier. This specifies the order for which a message is sent. 312 | * 313 | * @param array $queryParams 314 | * - *marketplaceIds* array - A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. 315 | * 316 | */ 317 | public function createUnexpectedProblem($amazonOrderId, $queryParams = [], $body = []) 318 | { 319 | return $this->send("/messaging/v1/orders/{$amazonOrderId}/messages/unexpectedProblem", [ 320 | 'method' => 'POST', 321 | 'query' => $queryParams, 322 | 'json' => $body 323 | ]); 324 | } 325 | 326 | public function createUnexpectedProblemAsync($amazonOrderId, $queryParams = [], $body = []) 327 | { 328 | return $this->sendAsync("/messaging/v1/orders/{$amazonOrderId}/messages/unexpectedProblem", [ 329 | 'method' => 'POST', 330 | 'query' => $queryParams, 331 | 'json' => $body 332 | ]); 333 | } 334 | } 335 | -------------------------------------------------------------------------------- /src/Api/Notifications.php: -------------------------------------------------------------------------------- 1 | send("/notifications/v1/subscriptions/{$notificationType}", [ 30 | 'method' => 'GET', 31 | ]); 32 | } 33 | 34 | public function getSubscriptionAsync($notificationType) 35 | { 36 | return $this->sendAsync("/notifications/v1/subscriptions/{$notificationType}", [ 37 | 'method' => 'GET', 38 | ]); 39 | } 40 | 41 | /** 42 | * Operation createSubscription 43 | * 44 | * @param string $notificationType The type of notification. 45 | * 46 | * For more information about notification types, see [the Notifications API Use Case Guide](doc:notifications-api-v1-use-case-guide). 47 | * 48 | */ 49 | public function createSubscription($notificationType, $body = []) 50 | { 51 | return $this->send("/notifications/v1/subscriptions/{$notificationType}", [ 52 | 'method' => 'POST', 53 | 'json' => $body 54 | ]); 55 | } 56 | 57 | public function createSubscriptionAsync($notificationType, $body = []) 58 | { 59 | return $this->sendAsync("/notifications/v1/subscriptions/{$notificationType}", [ 60 | 'method' => 'POST', 61 | 'json' => $body 62 | ]); 63 | } 64 | 65 | /** 66 | * Operation getSubscriptionById 67 | * 68 | * @param string $subscriptionId The identifier for the subscription that you want to get. 69 | * @param string $notificationType The type of notification. 70 | * 71 | * For more information about notification types, see [the Notifications API Use Case Guide](doc:notifications-api-v1-use-case-guide). 72 | * 73 | */ 74 | public function getSubscriptionById($subscriptionId, $notificationType) 75 | { 76 | return $this->send("/notifications/v1/subscriptions/{$notificationType}/{$subscriptionId}", [ 77 | 'method' => 'GET', 78 | ]); 79 | } 80 | 81 | public function getSubscriptionByIdAsync($subscriptionId, $notificationType) 82 | { 83 | return $this->sendAsync("/notifications/v1/subscriptions/{$notificationType}/{$subscriptionId}", [ 84 | 'method' => 'GET', 85 | ]); 86 | } 87 | 88 | /** 89 | * Operation deleteSubscriptionById 90 | * 91 | * @param string $subscriptionId The identifier for the subscription that you want to delete. 92 | * @param string $notificationType The type of notification. 93 | * 94 | * For more information about notification types, see [the Notifications API Use Case Guide](doc:notifications-api-v1-use-case-guide). 95 | * 96 | */ 97 | public function deleteSubscriptionById($subscriptionId, $notificationType) 98 | { 99 | return $this->send("/notifications/v1/subscriptions/{$notificationType}/{$subscriptionId}", [ 100 | 'method' => 'DELETE', 101 | ]); 102 | } 103 | 104 | public function deleteSubscriptionByIdAsync($subscriptionId, $notificationType) 105 | { 106 | return $this->sendAsync("/notifications/v1/subscriptions/{$notificationType}/{$subscriptionId}", [ 107 | 'method' => 'DELETE', 108 | ]); 109 | } 110 | 111 | /** 112 | * Operation getDestinations 113 | * 114 | */ 115 | public function getDestinations() 116 | { 117 | return $this->send("/notifications/v1/destinations", [ 118 | 'method' => 'GET', 119 | ]); 120 | } 121 | 122 | public function getDestinationsAsync() 123 | { 124 | return $this->sendAsync("/notifications/v1/destinations", [ 125 | 'method' => 'GET', 126 | ]); 127 | } 128 | 129 | /** 130 | * Operation createDestination 131 | * 132 | */ 133 | public function createDestination($body = []) 134 | { 135 | return $this->send("/notifications/v1/destinations", [ 136 | 'method' => 'POST', 137 | 'json' => $body 138 | ]); 139 | } 140 | 141 | public function createDestinationAsync($body = []) 142 | { 143 | return $this->sendAsync("/notifications/v1/destinations", [ 144 | 'method' => 'POST', 145 | 'json' => $body 146 | ]); 147 | } 148 | 149 | /** 150 | * Operation getDestination 151 | * 152 | * @param string $destinationId The identifier generated when you created the destination. 153 | * 154 | */ 155 | public function getDestination($destinationId) 156 | { 157 | return $this->send("/notifications/v1/destinations/{$destinationId}", [ 158 | 'method' => 'GET', 159 | ]); 160 | } 161 | 162 | public function getDestinationAsync($destinationId) 163 | { 164 | return $this->sendAsync("/notifications/v1/destinations/{$destinationId}", [ 165 | 'method' => 'GET', 166 | ]); 167 | } 168 | 169 | /** 170 | * Operation deleteDestination 171 | * 172 | * @param string $destinationId The identifier for the destination that you want to delete. 173 | * 174 | */ 175 | public function deleteDestination($destinationId) 176 | { 177 | return $this->send("/notifications/v1/destinations/{$destinationId}", [ 178 | 'method' => 'DELETE', 179 | ]); 180 | } 181 | 182 | public function deleteDestinationAsync($destinationId) 183 | { 184 | return $this->sendAsync("/notifications/v1/destinations/{$destinationId}", [ 185 | 'method' => 'DELETE', 186 | ]); 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /src/Api/Orders.php: -------------------------------------------------------------------------------- 1 | send("/orders/v0/orders", [ 45 | 'method' => 'GET', 46 | 'query' => $queryParams, 47 | ]); 48 | } 49 | 50 | public function getOrdersAsync($queryParams = []) 51 | { 52 | return $this->sendAsync("/orders/v0/orders", [ 53 | 'method' => 'GET', 54 | 'query' => $queryParams, 55 | ]); 56 | } 57 | 58 | /** 59 | * Operation getOrder 60 | * 61 | * @param string $orderId An Amazon-defined order identifier, in 3-7-7 format. 62 | * 63 | */ 64 | public function getOrder($orderId) 65 | { 66 | return $this->send("/orders/v0/orders/{$orderId}", [ 67 | 'method' => 'GET', 68 | ]); 69 | } 70 | 71 | public function getOrderAsync($orderId) 72 | { 73 | return $this->sendAsync("/orders/v0/orders/{$orderId}", [ 74 | 'method' => 'GET', 75 | ]); 76 | } 77 | 78 | /** 79 | * Operation getOrderBuyerInfo 80 | * 81 | * @param string $orderId An orderId is an Amazon-defined order identifier, in 3-7-7 format. 82 | * 83 | */ 84 | public function getOrderBuyerInfo($orderId) 85 | { 86 | return $this->send("/orders/v0/orders/{$orderId}/buyerInfo", [ 87 | 'method' => 'GET', 88 | ]); 89 | } 90 | 91 | public function getOrderBuyerInfoAsync($orderId) 92 | { 93 | return $this->sendAsync("/orders/v0/orders/{$orderId}/buyerInfo", [ 94 | 'method' => 'GET', 95 | ]); 96 | } 97 | 98 | /** 99 | * Operation getOrderAddress 100 | * 101 | * @param string $orderId An orderId is an Amazon-defined order identifier, in 3-7-7 format. 102 | * 103 | */ 104 | public function getOrderAddress($orderId) 105 | { 106 | return $this->send("/orders/v0/orders/{$orderId}/address", [ 107 | 'method' => 'GET', 108 | ]); 109 | } 110 | 111 | public function getOrderAddressAsync($orderId) 112 | { 113 | return $this->sendAsync("/orders/v0/orders/{$orderId}/address", [ 114 | 'method' => 'GET', 115 | ]); 116 | } 117 | 118 | /** 119 | * Operation getOrderItems 120 | * 121 | * @param string $orderId An Amazon-defined order identifier, in 3-7-7 format. 122 | * 123 | * @param array $queryParams 124 | * - *nextToken* string - A string token returned in the response of your previous request. 125 | * 126 | */ 127 | public function getOrderItems($orderId, $queryParams = []) 128 | { 129 | return $this->send("/orders/v0/orders/{$orderId}/orderItems", [ 130 | 'method' => 'GET', 131 | 'query' => $queryParams, 132 | ]); 133 | } 134 | 135 | public function getOrderItemsAsync($orderId, $queryParams = []) 136 | { 137 | return $this->sendAsync("/orders/v0/orders/{$orderId}/orderItems", [ 138 | 'method' => 'GET', 139 | 'query' => $queryParams, 140 | ]); 141 | } 142 | 143 | /** 144 | * Operation getOrderItemsBuyerInfo 145 | * 146 | * @param string $orderId An Amazon-defined order identifier, in 3-7-7 format. 147 | * 148 | * @param array $queryParams 149 | * - *nextToken* string - A string token returned in the response of your previous request. 150 | * 151 | */ 152 | public function getOrderItemsBuyerInfo($orderId, $queryParams = []) 153 | { 154 | return $this->send("/orders/v0/orders/{$orderId}/orderItems/buyerInfo", [ 155 | 'method' => 'GET', 156 | 'query' => $queryParams, 157 | ]); 158 | } 159 | 160 | public function getOrderItemsBuyerInfoAsync($orderId, $queryParams = []) 161 | { 162 | return $this->sendAsync("/orders/v0/orders/{$orderId}/orderItems/buyerInfo", [ 163 | 'method' => 'GET', 164 | 'query' => $queryParams, 165 | ]); 166 | } 167 | 168 | /** 169 | * Operation updateShipmentStatus 170 | * 171 | * @param string $orderId An Amazon-defined order identifier, in 3-7-7 format. 172 | * 173 | */ 174 | public function updateShipmentStatus($orderId, $body = []) 175 | { 176 | return $this->send("/orders/v0/orders/{$orderId}/shipment", [ 177 | 'method' => 'POST', 178 | 'json' => $body 179 | ]); 180 | } 181 | 182 | public function updateShipmentStatusAsync($orderId, $body = []) 183 | { 184 | return $this->sendAsync("/orders/v0/orders/{$orderId}/shipment", [ 185 | 'method' => 'POST', 186 | 'json' => $body 187 | ]); 188 | } 189 | 190 | /** 191 | * Operation getOrderRegulatedInfo 192 | * 193 | * @param string $orderId An orderId is an Amazon-defined order identifier, in 3-7-7 format. 194 | * 195 | */ 196 | public function getOrderRegulatedInfo($orderId) 197 | { 198 | return $this->send("/orders/v0/orders/{$orderId}/regulatedInfo", [ 199 | 'method' => 'GET', 200 | ]); 201 | } 202 | 203 | public function getOrderRegulatedInfoAsync($orderId) 204 | { 205 | return $this->sendAsync("/orders/v0/orders/{$orderId}/regulatedInfo", [ 206 | 'method' => 'GET', 207 | ]); 208 | } 209 | 210 | /** 211 | * Operation updateVerificationStatus 212 | * 213 | * @param string $orderId An orderId is an Amazon-defined order identifier, in 3-7-7 format. 214 | * 215 | */ 216 | public function updateVerificationStatus($orderId, $body = []) 217 | { 218 | return $this->send("/orders/v0/orders/{$orderId}/regulatedInfo", [ 219 | 'method' => 'PATCH', 220 | 'json' => $body 221 | ]); 222 | } 223 | 224 | public function updateVerificationStatusAsync($orderId, $body = []) 225 | { 226 | return $this->sendAsync("/orders/v0/orders/{$orderId}/regulatedInfo", [ 227 | 'method' => 'PATCH', 228 | 'json' => $body 229 | ]); 230 | } 231 | } 232 | -------------------------------------------------------------------------------- /src/Api/ProductFees.php: -------------------------------------------------------------------------------- 1 | send("/products/fees/v0/listings/{$sellerSKU}/feesEstimate", [ 26 | 'method' => 'POST', 27 | 'json' => $body 28 | ]); 29 | } 30 | 31 | public function getMyFeesEstimateForSKUAsync($sellerSKU, $body = []) 32 | { 33 | return $this->sendAsync("/products/fees/v0/listings/{$sellerSKU}/feesEstimate", [ 34 | 'method' => 'POST', 35 | 'json' => $body 36 | ]); 37 | } 38 | 39 | /** 40 | * Operation getMyFeesEstimateForASIN 41 | * 42 | * @param string $asin The Amazon Standard Identification Number (ASIN) of the item. 43 | * 44 | */ 45 | public function getMyFeesEstimateForASIN($asin, $body = []) 46 | { 47 | return $this->send("/products/fees/v0/items/{$asin}/feesEstimate", [ 48 | 'method' => 'POST', 49 | 'json' => $body 50 | ]); 51 | } 52 | 53 | public function getMyFeesEstimateForASINAsync($asin, $body = []) 54 | { 55 | return $this->sendAsync("/products/fees/v0/items/{$asin}/feesEstimate", [ 56 | 'method' => 'POST', 57 | 'json' => $body 58 | ]); 59 | } 60 | 61 | /** 62 | * Operation getMyFeesEstimates 63 | * 64 | */ 65 | public function getMyFeesEstimates($body = []) 66 | { 67 | return $this->send("/products/fees/v0/feesEstimate", [ 68 | 'method' => 'POST', 69 | 'json' => $body 70 | ]); 71 | } 72 | 73 | public function getMyFeesEstimatesAsync($body = []) 74 | { 75 | return $this->sendAsync("/products/fees/v0/feesEstimate", [ 76 | 'method' => 'POST', 77 | 'json' => $body 78 | ]); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/Api/ProductPricing.php: -------------------------------------------------------------------------------- 1 | send("/products/pricing/v0/price", [ 32 | 'method' => 'GET', 33 | 'query' => $queryParams, 34 | ]); 35 | } 36 | 37 | public function getPricingAsync($queryParams = []) 38 | { 39 | return $this->sendAsync("/products/pricing/v0/price", [ 40 | 'method' => 'GET', 41 | 'query' => $queryParams, 42 | ]); 43 | } 44 | 45 | /** 46 | * Operation getCompetitivePricing 47 | * 48 | * @param array $queryParams 49 | * - *marketplaceId* string - A marketplace identifier. Specifies the marketplace for which prices are returned. 50 | * - *asins* array - A list of up to twenty Amazon Standard Identification Number (ASIN) values used to identify items in the given marketplace. 51 | * - *skus* array - A list of up to twenty seller SKU values used to identify items in the given marketplace. 52 | * - *itemType* string - Indicates whether ASIN values or seller SKU values are used to identify items. If you specify Asin, the information in the response will be dependent on the list of Asins you provide in the Asins parameter. If you specify Sku, the information in the response will be dependent on the list of Skus you provide in the Skus parameter. Possible values: Asin, Sku. 53 | * - *customerType* string - Indicates whether to request pricing information from the point of view of Consumer or Business buyers. Default is Consumer. 54 | * 55 | */ 56 | public function getCompetitivePricing($queryParams = []) 57 | { 58 | return $this->send("/products/pricing/v0/competitivePrice", [ 59 | 'method' => 'GET', 60 | 'query' => $queryParams, 61 | ]); 62 | } 63 | 64 | public function getCompetitivePricingAsync($queryParams = []) 65 | { 66 | return $this->sendAsync("/products/pricing/v0/competitivePrice", [ 67 | 'method' => 'GET', 68 | 'query' => $queryParams, 69 | ]); 70 | } 71 | 72 | /** 73 | * Operation getListingOffers 74 | * 75 | * @param string $sellerSKU Identifies an item in the given marketplace. SellerSKU is qualified by the seller's SellerId, which is included with every operation that you submit. 76 | * 77 | * @param array $queryParams 78 | * - *marketplaceId* string - A marketplace identifier. Specifies the marketplace for which prices are returned. 79 | * - *itemCondition* string - Filters the offer listings based on item condition. Possible values: New, Used, Collectible, Refurbished, Club. 80 | * - *customerType* string - Indicates whether to request Consumer or Business offers. Default is Consumer. 81 | * 82 | */ 83 | public function getListingOffers($sellerSKU, $queryParams = []) 84 | { 85 | return $this->send("/products/pricing/v0/listings/{$sellerSKU}/offers", [ 86 | 'method' => 'GET', 87 | 'query' => $queryParams, 88 | ]); 89 | } 90 | 91 | public function getListingOffersAsync($sellerSKU, $queryParams = []) 92 | { 93 | return $this->sendAsync("/products/pricing/v0/listings/{$sellerSKU}/offers", [ 94 | 'method' => 'GET', 95 | 'query' => $queryParams, 96 | ]); 97 | } 98 | 99 | /** 100 | * Operation getItemOffers 101 | * 102 | * @param string $asin The Amazon Standard Identification Number (ASIN) of the item. 103 | * 104 | * @param array $queryParams 105 | * - *marketplaceId* string - A marketplace identifier. Specifies the marketplace for which prices are returned. 106 | * - *itemCondition* string - Filters the offer listings to be considered based on item condition. Possible values: New, Used, Collectible, Refurbished, Club. 107 | * - *customerType* string - Indicates whether to request Consumer or Business offers. Default is Consumer. 108 | * 109 | */ 110 | public function getItemOffers($asin, $queryParams = []) 111 | { 112 | return $this->send("/products/pricing/v0/items/{$asin}/offers", [ 113 | 'method' => 'GET', 114 | 'query' => $queryParams, 115 | ]); 116 | } 117 | 118 | public function getItemOffersAsync($asin, $queryParams = []) 119 | { 120 | return $this->sendAsync("/products/pricing/v0/items/{$asin}/offers", [ 121 | 'method' => 'GET', 122 | 'query' => $queryParams, 123 | ]); 124 | } 125 | 126 | /** 127 | * Operation getItemOffersBatch 128 | * 129 | */ 130 | public function getItemOffersBatch($body = []) 131 | { 132 | return $this->send("/batches/products/pricing/v0/itemOffers", [ 133 | 'method' => 'POST', 134 | 'json' => $body 135 | ]); 136 | } 137 | 138 | public function getItemOffersBatchAsync($body = []) 139 | { 140 | return $this->sendAsync("/batches/products/pricing/v0/itemOffers", [ 141 | 'method' => 'POST', 142 | 'json' => $body 143 | ]); 144 | } 145 | 146 | /** 147 | * Operation getListingOffersBatch 148 | * 149 | */ 150 | public function getListingOffersBatch($body = []) 151 | { 152 | return $this->send("/batches/products/pricing/v0/listingOffers", [ 153 | 'method' => 'POST', 154 | 'json' => $body 155 | ]); 156 | } 157 | 158 | public function getListingOffersBatchAsync($body = []) 159 | { 160 | return $this->sendAsync("/batches/products/pricing/v0/listingOffers", [ 161 | 'method' => 'POST', 162 | 'json' => $body 163 | ]); 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /src/Api/ProductTypeDefinitions.php: -------------------------------------------------------------------------------- 1 | send("/definitions/2020-09-01/productTypes", [ 30 | 'method' => 'GET', 31 | 'query' => $queryParams, 32 | ]); 33 | } 34 | 35 | public function searchDefinitionsProductTypesAsync($queryParams = []) 36 | { 37 | return $this->sendAsync("/definitions/2020-09-01/productTypes", [ 38 | 'method' => 'GET', 39 | 'query' => $queryParams, 40 | ]); 41 | } 42 | 43 | /** 44 | * Operation getDefinitionsProductType 45 | * 46 | * @param string $productType The Amazon product type name. 47 | * 48 | * @param array $queryParams 49 | * - *sellerId* string - A selling partner identifier. When provided, seller-specific requirements and values are populated within the product type definition schema, such as brand names associated with the selling partner. 50 | * - *marketplaceIds* array - A comma-delimited list of Amazon marketplace identifiers for the request. 51 | *Note: This parameter is limited to one marketplaceId at this time. 52 | * - *productTypeVersion* string - The version of the Amazon product type to retrieve. Defaults to "LATEST",. Prerelease versions of product type definitions may be retrieved with "RELEASE_CANDIDATE". If no prerelease version is currently available, the "LATEST" live version will be provided. 53 | * - *requirements* string - The name of the requirements set to retrieve requirements for. 54 | * - *requirementsEnforced* string - Identifies if the required attributes for a requirements set are enforced by the product type definition schema. Non-enforced requirements enable structural validation of individual attributes without all the required attributes being present (such as for partial updates). 55 | * - *locale* string - Locale for retrieving display labels and other presentation details. Defaults to the default language of the first marketplace in the request. 56 | * 57 | */ 58 | public function getDefinitionsProductType($productType, $queryParams = []) 59 | { 60 | return $this->send("/definitions/2020-09-01/productTypes/{$productType}", [ 61 | 'method' => 'GET', 62 | 'query' => $queryParams, 63 | ]); 64 | } 65 | 66 | public function getDefinitionsProductTypeAsync($productType, $queryParams = []) 67 | { 68 | return $this->sendAsync("/definitions/2020-09-01/productTypes/{$productType}", [ 69 | 'method' => 'GET', 70 | 'query' => $queryParams, 71 | ]); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/Api/Reports.php: -------------------------------------------------------------------------------- 1 | send("/reports/2021-06-30/reports", [ 33 | 'method' => 'GET', 34 | 'query' => $queryParams, 35 | ]); 36 | } 37 | 38 | public function getReportsAsync($queryParams = []) 39 | { 40 | return $this->sendAsync("/reports/2021-06-30/reports", [ 41 | 'method' => 'GET', 42 | 'query' => $queryParams, 43 | ]); 44 | } 45 | 46 | /** 47 | * Operation createReport 48 | * 49 | */ 50 | public function createReport($body = []) 51 | { 52 | return $this->send("/reports/2021-06-30/reports", [ 53 | 'method' => 'POST', 54 | 'json' => $body 55 | ]); 56 | } 57 | 58 | public function createReportAsync($body = []) 59 | { 60 | return $this->sendAsync("/reports/2021-06-30/reports", [ 61 | 'method' => 'POST', 62 | 'json' => $body 63 | ]); 64 | } 65 | 66 | /** 67 | * Operation cancelReport 68 | * 69 | * @param string $reportId The identifier for the report. This identifier is unique only in combination with a seller ID. 70 | * 71 | */ 72 | public function cancelReport($reportId) 73 | { 74 | return $this->send("/reports/2021-06-30/reports/{$reportId}", [ 75 | 'method' => 'DELETE', 76 | ]); 77 | } 78 | 79 | public function cancelReportAsync($reportId) 80 | { 81 | return $this->sendAsync("/reports/2021-06-30/reports/{$reportId}", [ 82 | 'method' => 'DELETE', 83 | ]); 84 | } 85 | 86 | /** 87 | * Operation getReport 88 | * 89 | * @param string $reportId The identifier for the report. This identifier is unique only in combination with a seller ID. 90 | * 91 | */ 92 | public function getReport($reportId) 93 | { 94 | return $this->send("/reports/2021-06-30/reports/{$reportId}", [ 95 | 'method' => 'GET', 96 | ]); 97 | } 98 | 99 | public function getReportAsync($reportId) 100 | { 101 | return $this->sendAsync("/reports/2021-06-30/reports/{$reportId}", [ 102 | 'method' => 'GET', 103 | ]); 104 | } 105 | 106 | /** 107 | * Operation getReportSchedules 108 | * 109 | * @param array $queryParams 110 | * - *reportTypes* array - A list of report types used to filter report schedules. 111 | * 112 | */ 113 | public function getReportSchedules($queryParams = []) 114 | { 115 | return $this->send("/reports/2021-06-30/schedules", [ 116 | 'method' => 'GET', 117 | 'query' => $queryParams, 118 | ]); 119 | } 120 | 121 | public function getReportSchedulesAsync($queryParams = []) 122 | { 123 | return $this->sendAsync("/reports/2021-06-30/schedules", [ 124 | 'method' => 'GET', 125 | 'query' => $queryParams, 126 | ]); 127 | } 128 | 129 | /** 130 | * Operation createReportSchedule 131 | * 132 | */ 133 | public function createReportSchedule($body = []) 134 | { 135 | return $this->send("/reports/2021-06-30/schedules", [ 136 | 'method' => 'POST', 137 | 'json' => $body 138 | ]); 139 | } 140 | 141 | public function createReportScheduleAsync($body = []) 142 | { 143 | return $this->sendAsync("/reports/2021-06-30/schedules", [ 144 | 'method' => 'POST', 145 | 'json' => $body 146 | ]); 147 | } 148 | 149 | /** 150 | * Operation cancelReportSchedule 151 | * 152 | * @param string $reportScheduleId The identifier for the report schedule. This identifier is unique only in combination with a seller ID. 153 | * 154 | */ 155 | public function cancelReportSchedule($reportScheduleId) 156 | { 157 | return $this->send("/reports/2021-06-30/schedules/{$reportScheduleId}", [ 158 | 'method' => 'DELETE', 159 | ]); 160 | } 161 | 162 | public function cancelReportScheduleAsync($reportScheduleId) 163 | { 164 | return $this->sendAsync("/reports/2021-06-30/schedules/{$reportScheduleId}", [ 165 | 'method' => 'DELETE', 166 | ]); 167 | } 168 | 169 | /** 170 | * Operation getReportSchedule 171 | * 172 | * @param string $reportScheduleId The identifier for the report schedule. This identifier is unique only in combination with a seller ID. 173 | * 174 | */ 175 | public function getReportSchedule($reportScheduleId) 176 | { 177 | return $this->send("/reports/2021-06-30/schedules/{$reportScheduleId}", [ 178 | 'method' => 'GET', 179 | ]); 180 | } 181 | 182 | public function getReportScheduleAsync($reportScheduleId) 183 | { 184 | return $this->sendAsync("/reports/2021-06-30/schedules/{$reportScheduleId}", [ 185 | 'method' => 'GET', 186 | ]); 187 | } 188 | 189 | /** 190 | * Operation getReportDocument 191 | * 192 | * @param string $reportDocumentId The identifier for the report document. 193 | * 194 | */ 195 | public function getReportDocument($reportDocumentId) 196 | { 197 | return $this->send("/reports/2021-06-30/documents/{$reportDocumentId}", [ 198 | 'method' => 'GET', 199 | ]); 200 | } 201 | 202 | public function getReportDocumentAsync($reportDocumentId) 203 | { 204 | return $this->sendAsync("/reports/2021-06-30/documents/{$reportDocumentId}", [ 205 | 'method' => 'GET', 206 | ]); 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /src/Api/Sales.php: -------------------------------------------------------------------------------- 1 | send("/sales/v1/orderMetrics", [ 35 | 'method' => 'GET', 36 | 'query' => $queryParams, 37 | ]); 38 | } 39 | 40 | public function getOrderMetricsAsync($queryParams = []) 41 | { 42 | return $this->sendAsync("/sales/v1/orderMetrics", [ 43 | 'method' => 'GET', 44 | 'query' => $queryParams, 45 | ]); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Api/Sellers.php: -------------------------------------------------------------------------------- 1 | send("/sellers/v1/marketplaceParticipations", [ 24 | 'method' => 'GET', 25 | ]); 26 | } 27 | 28 | public function getMarketplaceParticipationsAsync() 29 | { 30 | return $this->sendAsync("/sellers/v1/marketplaceParticipations", [ 31 | 'method' => 'GET', 32 | ]); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Api/Services.php: -------------------------------------------------------------------------------- 1 | send("/service/v1/serviceJobs/{$serviceJobId}", [ 26 | 'method' => 'GET', 27 | ]); 28 | } 29 | 30 | public function getServiceJobByServiceJobIdAsync($serviceJobId) 31 | { 32 | return $this->sendAsync("/service/v1/serviceJobs/{$serviceJobId}", [ 33 | 'method' => 'GET', 34 | ]); 35 | } 36 | 37 | /** 38 | * Operation cancelServiceJobByServiceJobId 39 | * 40 | * @param string $serviceJobId An Amazon defined service job identifier. 41 | * 42 | * @param array $queryParams 43 | * - *cancellationReasonCode* string - A cancel reason code that specifies the reason for cancelling a service job. 44 | * 45 | */ 46 | public function cancelServiceJobByServiceJobId($serviceJobId, $queryParams = []) 47 | { 48 | return $this->send("/service/v1/serviceJobs/{$serviceJobId}/cancellations", [ 49 | 'method' => 'PUT', 50 | 'query' => $queryParams, 51 | ]); 52 | } 53 | 54 | public function cancelServiceJobByServiceJobIdAsync($serviceJobId, $queryParams = []) 55 | { 56 | return $this->sendAsync("/service/v1/serviceJobs/{$serviceJobId}/cancellations", [ 57 | 'method' => 'PUT', 58 | 'query' => $queryParams, 59 | ]); 60 | } 61 | 62 | /** 63 | * Operation completeServiceJobByServiceJobId 64 | * 65 | * @param string $serviceJobId An Amazon defined service job identifier. 66 | * 67 | */ 68 | public function completeServiceJobByServiceJobId($serviceJobId) 69 | { 70 | return $this->send("/service/v1/serviceJobs/{$serviceJobId}/completions", [ 71 | 'method' => 'PUT', 72 | ]); 73 | } 74 | 75 | public function completeServiceJobByServiceJobIdAsync($serviceJobId) 76 | { 77 | return $this->sendAsync("/service/v1/serviceJobs/{$serviceJobId}/completions", [ 78 | 'method' => 'PUT', 79 | ]); 80 | } 81 | 82 | /** 83 | * Operation getServiceJobs 84 | * 85 | * @param array $queryParams 86 | * - *serviceOrderIds* array - List of service order ids for the query you want to perform.Max values supported 20. 87 | * - *serviceJobStatus* array - A list of one or more job status by which to filter the list of jobs. 88 | * - *pageToken* string - String returned in the response of your previous request. 89 | * - *pageSize* integer - A non-negative integer that indicates the maximum number of jobs to return in the list, Value must be 1 - 20. Default 20. 90 | * - *sortField* string - Sort fields on which you want to sort the output. 91 | * - *sortOrder* string - Sort order for the query you want to perform. 92 | * - *createdAfter* string - A date used for selecting jobs created after (or at) a specified time must be in ISO 8601 format. Required if LastUpdatedAfter is not specified.Specifying both CreatedAfter and LastUpdatedAfter returns an error. 93 | * - *createdBefore* string - A date used for selecting jobs created before (or at) a specified time must be in ISO 8601 format. 94 | * - *lastUpdatedAfter* string - A date used for selecting jobs updated after (or at) a specified time must be in ISO 8601 format. Required if createdAfter is not specified.Specifying both CreatedAfter and LastUpdatedAfter returns an error. 95 | * - *lastUpdatedBefore* string - A date used for selecting jobs updated before (or at) a specified time must be in ISO 8601 format. 96 | * - *scheduleStartDate* string - A date used for filtering jobs schedule after (or at) a specified time must be in ISO 8601 format. schedule end date should not be earlier than schedule start date. 97 | * - *scheduleEndDate* string - A date used for filtering jobs schedule before (or at) a specified time must be in ISO 8601 format. schedule end date should not be earlier than schedule start date. 98 | * - *marketplaceIds* array - Used to select jobs that were placed in the specified marketplaces. 99 | * 100 | */ 101 | public function getServiceJobs($queryParams = []) 102 | { 103 | return $this->send("/service/v1/serviceJobs", [ 104 | 'method' => 'GET', 105 | 'query' => $queryParams, 106 | ]); 107 | } 108 | 109 | public function getServiceJobsAsync($queryParams = []) 110 | { 111 | return $this->sendAsync("/service/v1/serviceJobs", [ 112 | 'method' => 'GET', 113 | 'query' => $queryParams, 114 | ]); 115 | } 116 | 117 | /** 118 | * Operation addAppointmentForServiceJobByServiceJobId 119 | * 120 | * @param string $serviceJobId An Amazon defined service job identifier. 121 | * 122 | */ 123 | public function addAppointmentForServiceJobByServiceJobId($serviceJobId, $body = []) 124 | { 125 | return $this->send("/service/v1/serviceJobs/{$serviceJobId}/appointments", [ 126 | 'method' => 'POST', 127 | 'json' => $body 128 | ]); 129 | } 130 | 131 | public function addAppointmentForServiceJobByServiceJobIdAsync($serviceJobId, $body = []) 132 | { 133 | return $this->sendAsync("/service/v1/serviceJobs/{$serviceJobId}/appointments", [ 134 | 'method' => 'POST', 135 | 'json' => $body 136 | ]); 137 | } 138 | 139 | /** 140 | * Operation rescheduleAppointmentForServiceJobByServiceJobId 141 | * 142 | * @param string $serviceJobId An Amazon defined service job identifier. 143 | * @param string $appointmentId An existing appointment identifier for the Service Job. 144 | * 145 | */ 146 | public function rescheduleAppointmentForServiceJobByServiceJobId($serviceJobId, $appointmentId, $body = []) 147 | { 148 | return $this->send("/service/v1/serviceJobs/{$serviceJobId}/appointments/{$appointmentId}", [ 149 | 'method' => 'POST', 150 | 'json' => $body 151 | ]); 152 | } 153 | 154 | public function rescheduleAppointmentForServiceJobByServiceJobIdAsync($serviceJobId, $appointmentId, $body = []) 155 | { 156 | return $this->sendAsync("/service/v1/serviceJobs/{$serviceJobId}/appointments/{$appointmentId}", [ 157 | 'method' => 'POST', 158 | 'json' => $body 159 | ]); 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /src/Api/ShipmentInvoicing.php: -------------------------------------------------------------------------------- 1 | send("/fba/outbound/brazil/v0/shipments/{$shipmentId}", [ 26 | 'method' => 'GET', 27 | ]); 28 | } 29 | 30 | public function getShipmentDetailsAsync($shipmentId) 31 | { 32 | return $this->sendAsync("/fba/outbound/brazil/v0/shipments/{$shipmentId}", [ 33 | 'method' => 'GET', 34 | ]); 35 | } 36 | 37 | /** 38 | * Operation submitInvoice 39 | * 40 | * @param string $shipmentId The identifier for the shipment. 41 | * 42 | */ 43 | public function submitInvoice($shipmentId, $body = []) 44 | { 45 | return $this->send("/fba/outbound/brazil/v0/shipments/{$shipmentId}/invoice", [ 46 | 'method' => 'POST', 47 | 'json' => $body 48 | ]); 49 | } 50 | 51 | public function submitInvoiceAsync($shipmentId, $body = []) 52 | { 53 | return $this->sendAsync("/fba/outbound/brazil/v0/shipments/{$shipmentId}/invoice", [ 54 | 'method' => 'POST', 55 | 'json' => $body 56 | ]); 57 | } 58 | 59 | /** 60 | * Operation getInvoiceStatus 61 | * 62 | * @param string $shipmentId The shipment identifier for the shipment. 63 | * 64 | */ 65 | public function getInvoiceStatus($shipmentId) 66 | { 67 | return $this->send("/fba/outbound/brazil/v0/shipments/{$shipmentId}/invoice/status", [ 68 | 'method' => 'GET', 69 | ]); 70 | } 71 | 72 | public function getInvoiceStatusAsync($shipmentId) 73 | { 74 | return $this->sendAsync("/fba/outbound/brazil/v0/shipments/{$shipmentId}/invoice/status", [ 75 | 'method' => 'GET', 76 | ]); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/Api/Shipping.php: -------------------------------------------------------------------------------- 1 | send("/shipping/v1/shipments", [ 24 | 'method' => 'POST', 25 | 'json' => $body 26 | ]); 27 | } 28 | 29 | public function createShipmentAsync($body = []) 30 | { 31 | return $this->sendAsync("/shipping/v1/shipments", [ 32 | 'method' => 'POST', 33 | 'json' => $body 34 | ]); 35 | } 36 | 37 | /** 38 | * Operation getShipment 39 | * 40 | * @param string $shipmentId 41 | * 42 | */ 43 | public function getShipment($shipmentId) 44 | { 45 | return $this->send("/shipping/v1/shipments/{$shipmentId}", [ 46 | 'method' => 'GET', 47 | ]); 48 | } 49 | 50 | public function getShipmentAsync($shipmentId) 51 | { 52 | return $this->sendAsync("/shipping/v1/shipments/{$shipmentId}", [ 53 | 'method' => 'GET', 54 | ]); 55 | } 56 | 57 | /** 58 | * Operation cancelShipment 59 | * 60 | * @param string $shipmentId 61 | * 62 | */ 63 | public function cancelShipment($shipmentId) 64 | { 65 | return $this->send("/shipping/v1/shipments/{$shipmentId}/cancel", [ 66 | 'method' => 'POST', 67 | ]); 68 | } 69 | 70 | public function cancelShipmentAsync($shipmentId) 71 | { 72 | return $this->sendAsync("/shipping/v1/shipments/{$shipmentId}/cancel", [ 73 | 'method' => 'POST', 74 | ]); 75 | } 76 | 77 | /** 78 | * Operation purchaseLabels 79 | * 80 | * @param string $shipmentId 81 | * 82 | */ 83 | public function purchaseLabels($shipmentId, $body = []) 84 | { 85 | return $this->send("/shipping/v1/shipments/{$shipmentId}/purchaseLabels", [ 86 | 'method' => 'POST', 87 | 'json' => $body 88 | ]); 89 | } 90 | 91 | public function purchaseLabelsAsync($shipmentId, $body = []) 92 | { 93 | return $this->sendAsync("/shipping/v1/shipments/{$shipmentId}/purchaseLabels", [ 94 | 'method' => 'POST', 95 | 'json' => $body 96 | ]); 97 | } 98 | 99 | /** 100 | * Operation retrieveShippingLabel 101 | * 102 | * @param string $shipmentId 103 | * @param string $trackingId 104 | * 105 | */ 106 | public function retrieveShippingLabel($shipmentId, $trackingId, $body = []) 107 | { 108 | return $this->send("/shipping/v1/shipments/{$shipmentId}/containers/{$trackingId}/label", [ 109 | 'method' => 'POST', 110 | 'json' => $body 111 | ]); 112 | } 113 | 114 | public function retrieveShippingLabelAsync($shipmentId, $trackingId, $body = []) 115 | { 116 | return $this->sendAsync("/shipping/v1/shipments/{$shipmentId}/containers/{$trackingId}/label", [ 117 | 'method' => 'POST', 118 | 'json' => $body 119 | ]); 120 | } 121 | 122 | /** 123 | * Operation purchaseShipment 124 | * 125 | */ 126 | public function purchaseShipment($body = []) 127 | { 128 | return $this->send("/shipping/v1/purchaseShipment", [ 129 | 'method' => 'POST', 130 | 'json' => $body 131 | ]); 132 | } 133 | 134 | public function purchaseShipmentAsync($body = []) 135 | { 136 | return $this->sendAsync("/shipping/v1/purchaseShipment", [ 137 | 'method' => 'POST', 138 | 'json' => $body 139 | ]); 140 | } 141 | 142 | /** 143 | * Operation getRates 144 | * 145 | */ 146 | public function getRates($body = []) 147 | { 148 | return $this->send("/shipping/v1/rates", [ 149 | 'method' => 'POST', 150 | 'json' => $body 151 | ]); 152 | } 153 | 154 | public function getRatesAsync($body = []) 155 | { 156 | return $this->sendAsync("/shipping/v1/rates", [ 157 | 'method' => 'POST', 158 | 'json' => $body 159 | ]); 160 | } 161 | 162 | /** 163 | * Operation getAccount 164 | * 165 | */ 166 | public function getAccount() 167 | { 168 | return $this->send("/shipping/v1/account", [ 169 | 'method' => 'GET', 170 | ]); 171 | } 172 | 173 | public function getAccountAsync() 174 | { 175 | return $this->sendAsync("/shipping/v1/account", [ 176 | 'method' => 'GET', 177 | ]); 178 | } 179 | 180 | /** 181 | * Operation getTrackingInformation 182 | * 183 | * @param string $trackingId 184 | * 185 | */ 186 | public function getTrackingInformation($trackingId) 187 | { 188 | return $this->send("/shipping/v1/tracking/{$trackingId}", [ 189 | 'method' => 'GET', 190 | ]); 191 | } 192 | 193 | public function getTrackingInformationAsync($trackingId) 194 | { 195 | return $this->sendAsync("/shipping/v1/tracking/{$trackingId}", [ 196 | 'method' => 'GET', 197 | ]); 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /src/Api/Solicitations.php: -------------------------------------------------------------------------------- 1 | JSON Hypertext Application Language (HAL) standard. 11 | */ 12 | namespace DoubleBreak\Spapi\Api; 13 | use DoubleBreak\Spapi\Client; 14 | 15 | class Solicitations extends Client { 16 | 17 | /** 18 | * Operation getSolicitationActionsForOrder 19 | * 20 | * @param string $amazonOrderId An Amazon order identifier. This specifies the order for which you want a list of available solicitation types. 21 | * 22 | * @param array $queryParams 23 | * - *marketplaceIds* array - A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. 24 | * 25 | */ 26 | public function getSolicitationActionsForOrder($amazonOrderId, $queryParams = []) 27 | { 28 | return $this->send("/solicitations/v1/orders/{$amazonOrderId}", [ 29 | 'method' => 'GET', 30 | 'query' => $queryParams, 31 | ]); 32 | } 33 | 34 | public function getSolicitationActionsForOrderAsync($amazonOrderId, $queryParams = []) 35 | { 36 | return $this->sendAsync("/solicitations/v1/orders/{$amazonOrderId}", [ 37 | 'method' => 'GET', 38 | 'query' => $queryParams, 39 | ]); 40 | } 41 | 42 | /** 43 | * Operation createProductReviewAndSellerFeedbackSolicitation 44 | * 45 | * @param string $amazonOrderId An Amazon order identifier. This specifies the order for which a solicitation is sent. 46 | * 47 | * @param array $queryParams 48 | * - *marketplaceIds* array - A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. 49 | * 50 | */ 51 | public function createProductReviewAndSellerFeedbackSolicitation($amazonOrderId, $queryParams = []) 52 | { 53 | return $this->send("/solicitations/v1/orders/{$amazonOrderId}/solicitations/productReviewAndSellerFeedback", [ 54 | 'method' => 'POST', 55 | 'query' => $queryParams, 56 | ]); 57 | } 58 | 59 | public function createProductReviewAndSellerFeedbackSolicitationAsync($amazonOrderId, $queryParams = []) 60 | { 61 | return $this->sendAsync("/solicitations/v1/orders/{$amazonOrderId}/solicitations/productReviewAndSellerFeedback", [ 62 | 'method' => 'POST', 63 | 'query' => $queryParams, 64 | ]); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Api/Tokens.php: -------------------------------------------------------------------------------- 1 | send("/tokens/2021-03-01/restrictedDataToken", [ 26 | 'method' => 'POST', 27 | 'json' => $body 28 | ]); 29 | } 30 | 31 | public function createRestrictedDataTokenAsync($body = []) 32 | { 33 | return $this->sendAsync("/tokens/2021-03-01/restrictedDataToken", [ 34 | 'method' => 'POST', 35 | 'json' => $body 36 | ]); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Api/Uploads.php: -------------------------------------------------------------------------------- 1 | send("/uploads/2020-11-01/uploadDestinations/{$resource}", [ 31 | 'method' => 'POST', 32 | 'query' => $queryParams, 33 | ]); 34 | } 35 | 36 | public function createUploadDestinationForResourceAsync($resource, $queryParams = []) 37 | { 38 | return $this->sendAsync("/uploads/2020-11-01/uploadDestinations/{$resource}", [ 39 | 'method' => 'POST', 40 | 'query' => $queryParams, 41 | ]); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Api/VendorDirectFulfillmentInventory.php: -------------------------------------------------------------------------------- 1 | send("/vendor/directFulfillment/inventory/v1/warehouses/{$warehouseId}/items", [ 26 | 'method' => 'POST', 27 | 'json' => $body 28 | ]); 29 | } 30 | 31 | public function submitInventoryUpdateAsync($warehouseId, $body = []) 32 | { 33 | return $this->sendAsync("/vendor/directFulfillment/inventory/v1/warehouses/{$warehouseId}/items", [ 34 | 'method' => 'POST', 35 | 'json' => $body 36 | ]); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Api/VendorDirectFulfillmentOrders.php: -------------------------------------------------------------------------------- 1 | send("/vendor/directFulfillment/orders/2021-12-28/purchaseOrders", [ 34 | 'method' => 'GET', 35 | 'query' => $queryParams, 36 | ]); 37 | } 38 | 39 | public function getOrdersAsync($queryParams = []) 40 | { 41 | return $this->sendAsync("/vendor/directFulfillment/orders/2021-12-28/purchaseOrders", [ 42 | 'method' => 'GET', 43 | 'query' => $queryParams, 44 | ]); 45 | } 46 | 47 | /** 48 | * Operation getOrder 49 | * 50 | * @param string $purchaseOrderNumber The order identifier for the purchase order that you want. Formatting Notes: alpha-numeric code. 51 | * 52 | */ 53 | public function getOrder($purchaseOrderNumber) 54 | { 55 | return $this->send("/vendor/directFulfillment/orders/2021-12-28/purchaseOrders/{$purchaseOrderNumber}", [ 56 | 'method' => 'GET', 57 | ]); 58 | } 59 | 60 | public function getOrderAsync($purchaseOrderNumber) 61 | { 62 | return $this->sendAsync("/vendor/directFulfillment/orders/2021-12-28/purchaseOrders/{$purchaseOrderNumber}", [ 63 | 'method' => 'GET', 64 | ]); 65 | } 66 | 67 | /** 68 | * Operation submitAcknowledgement 69 | * 70 | */ 71 | public function submitAcknowledgement($body = []) 72 | { 73 | return $this->send("/vendor/directFulfillment/orders/2021-12-28/acknowledgements", [ 74 | 'method' => 'POST', 75 | 'json' => $body 76 | ]); 77 | } 78 | 79 | public function submitAcknowledgementAsync($body = []) 80 | { 81 | return $this->sendAsync("/vendor/directFulfillment/orders/2021-12-28/acknowledgements", [ 82 | 'method' => 'POST', 83 | 'json' => $body 84 | ]); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/Api/VendorDirectFulfillmentPayments.php: -------------------------------------------------------------------------------- 1 | send("/vendor/directFulfillment/payments/v1/invoices", [ 24 | 'method' => 'POST', 25 | 'json' => $body 26 | ]); 27 | } 28 | 29 | public function submitInvoiceAsync($body = []) 30 | { 31 | return $this->sendAsync("/vendor/directFulfillment/payments/v1/invoices", [ 32 | 'method' => 'POST', 33 | 'json' => $body 34 | ]); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Api/VendorDirectFulfillmentSandboxTestData.php: -------------------------------------------------------------------------------- 1 | send("/vendor/directFulfillment/sandbox/2021-10-28/orders", [ 24 | 'method' => 'POST', 25 | 'json' => $body 26 | ]); 27 | } 28 | 29 | public function generateOrderScenariosAsync($body = []) 30 | { 31 | return $this->sendAsync("/vendor/directFulfillment/sandbox/2021-10-28/orders", [ 32 | 'method' => 'POST', 33 | 'json' => $body 34 | ]); 35 | } 36 | 37 | /** 38 | * Operation getOrderScenarios 39 | * 40 | * @param string $transactionId The transaction identifier returned in the response to the generateOrderScenarios operation. 41 | * 42 | */ 43 | public function getOrderScenarios($transactionId) 44 | { 45 | return $this->send("/vendor/directFulfillment/sandbox/2021-10-28/transactions/{$transactionId}", [ 46 | 'method' => 'GET', 47 | ]); 48 | } 49 | 50 | public function getOrderScenariosAsync($transactionId) 51 | { 52 | return $this->sendAsync("/vendor/directFulfillment/sandbox/2021-10-28/transactions/{$transactionId}", [ 53 | 'method' => 'GET', 54 | ]); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/Api/VendorDirectFulfillmentShipping.php: -------------------------------------------------------------------------------- 1 | send("/vendor/directFulfillment/shipping/2021-12-28/shippingLabels", [ 32 | 'method' => 'GET', 33 | 'query' => $queryParams, 34 | ]); 35 | } 36 | 37 | public function getShippingLabelsAsync($queryParams = []) 38 | { 39 | return $this->sendAsync("/vendor/directFulfillment/shipping/2021-12-28/shippingLabels", [ 40 | 'method' => 'GET', 41 | 'query' => $queryParams, 42 | ]); 43 | } 44 | 45 | /** 46 | * Operation submitShippingLabelRequest 47 | * 48 | */ 49 | public function submitShippingLabelRequest($body = []) 50 | { 51 | return $this->send("/vendor/directFulfillment/shipping/2021-12-28/shippingLabels", [ 52 | 'method' => 'POST', 53 | 'json' => $body 54 | ]); 55 | } 56 | 57 | public function submitShippingLabelRequestAsync($body = []) 58 | { 59 | return $this->sendAsync("/vendor/directFulfillment/shipping/2021-12-28/shippingLabels", [ 60 | 'method' => 'POST', 61 | 'json' => $body 62 | ]); 63 | } 64 | 65 | /** 66 | * Operation getShippingLabel 67 | * 68 | * @param string $purchaseOrderNumber The purchase order number for which you want to return the shipping label. It should be the same purchaseOrderNumber as received in the order. 69 | * 70 | */ 71 | public function getShippingLabel($purchaseOrderNumber) 72 | { 73 | return $this->send("/vendor/directFulfillment/shipping/2021-12-28/shippingLabels/{$purchaseOrderNumber}", [ 74 | 'method' => 'GET', 75 | ]); 76 | } 77 | 78 | public function getShippingLabelAsync($purchaseOrderNumber) 79 | { 80 | return $this->sendAsync("/vendor/directFulfillment/shipping/2021-12-28/shippingLabels/{$purchaseOrderNumber}", [ 81 | 'method' => 'GET', 82 | ]); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/Api/VendorDirectFulfillmentTransactions.php: -------------------------------------------------------------------------------- 1 | send("/vendor/directFulfillment/transactions/2021-12-28/transactions/{$transactionId}", [ 26 | 'method' => 'GET', 27 | ]); 28 | } 29 | 30 | public function getTransactionStatusAsync($transactionId) 31 | { 32 | return $this->sendAsync("/vendor/directFulfillment/transactions/2021-12-28/transactions/{$transactionId}", [ 33 | 'method' => 'GET', 34 | ]); 35 | } 36 | 37 | /** 38 | * Operation 39 | * 40 | */ 41 | public function () 42 | { 43 | return $this->send("/vendor/directFulfillment/transactions/2021-12-28/transactions/{transactionId}", [ 44 | 'method' => 'X-AMZN-API-SANDBOX', 45 | ]); 46 | } 47 | 48 | public function Async() 49 | { 50 | return $this->sendAsync("/vendor/directFulfillment/transactions/2021-12-28/transactions/{transactionId}", [ 51 | 'method' => 'X-AMZN-API-SANDBOX', 52 | ]); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Api/VendorInvoices.php: -------------------------------------------------------------------------------- 1 | send("/vendor/payments/v1/invoices", [ 24 | 'method' => 'POST', 25 | 'json' => $body 26 | ]); 27 | } 28 | 29 | public function submitInvoicesAsync($body = []) 30 | { 31 | return $this->sendAsync("/vendor/payments/v1/invoices", [ 32 | 'method' => 'POST', 33 | 'json' => $body 34 | ]); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Api/VendorOrders.php: -------------------------------------------------------------------------------- 1 | send("/vendor/orders/v1/purchaseOrders", [ 38 | 'method' => 'GET', 39 | 'query' => $queryParams, 40 | ]); 41 | } 42 | 43 | public function getPurchaseOrdersAsync($queryParams = []) 44 | { 45 | return $this->sendAsync("/vendor/orders/v1/purchaseOrders", [ 46 | 'method' => 'GET', 47 | 'query' => $queryParams, 48 | ]); 49 | } 50 | 51 | /** 52 | * Operation getPurchaseOrder 53 | * 54 | * @param string $purchaseOrderNumber The purchase order identifier for the order that you want. Formatting Notes: 8-character alpha-numeric code. 55 | * 56 | */ 57 | public function getPurchaseOrder($purchaseOrderNumber) 58 | { 59 | return $this->send("/vendor/orders/v1/purchaseOrders/{$purchaseOrderNumber}", [ 60 | 'method' => 'GET', 61 | ]); 62 | } 63 | 64 | public function getPurchaseOrderAsync($purchaseOrderNumber) 65 | { 66 | return $this->sendAsync("/vendor/orders/v1/purchaseOrders/{$purchaseOrderNumber}", [ 67 | 'method' => 'GET', 68 | ]); 69 | } 70 | 71 | /** 72 | * Operation submitAcknowledgement 73 | * 74 | */ 75 | public function submitAcknowledgement($body = []) 76 | { 77 | return $this->send("/vendor/orders/v1/acknowledgements", [ 78 | 'method' => 'POST', 79 | 'json' => $body 80 | ]); 81 | } 82 | 83 | public function submitAcknowledgementAsync($body = []) 84 | { 85 | return $this->sendAsync("/vendor/orders/v1/acknowledgements", [ 86 | 'method' => 'POST', 87 | 'json' => $body 88 | ]); 89 | } 90 | 91 | /** 92 | * Operation getPurchaseOrdersStatus 93 | * 94 | * @param array $queryParams 95 | * - *limit* integer - The limit to the number of records returned. Default value is 100 records. 96 | * - *sortOrder* string - Sort in ascending or descending order by purchase order creation date. 97 | * - *nextToken* string - Used for pagination when there are more purchase orders than the specified result size limit. 98 | * - *createdAfter* string - Purchase orders that became available after this timestamp will be included in the result. Must be in ISO-8601 date/time format. 99 | * - *createdBefore* string - Purchase orders that became available before this timestamp will be included in the result. Must be in ISO-8601 date/time format. 100 | * - *updatedAfter* string - Purchase orders for which the last purchase order update happened after this timestamp will be included in the result. Must be in ISO-8601 date/time format. 101 | * - *updatedBefore* string - Purchase orders for which the last purchase order update happened before this timestamp will be included in the result. Must be in ISO-8601 date/time format. 102 | * - *purchaseOrderNumber* string - Provides purchase order status for the specified purchase order number. 103 | * - *purchaseOrderStatus* string - Filters purchase orders based on the specified purchase order status. If not included in filter, this will return purchase orders for all statuses. 104 | * - *itemConfirmationStatus* string - Filters purchase orders based on their item confirmation status. If the item confirmation status is not included in the filter, purchase orders for all confirmation statuses are included. 105 | * - *itemReceiveStatus* string - Filters purchase orders based on the purchase order's item receive status. If the item receive status is not included in the filter, purchase orders for all receive statuses are included. 106 | * - *orderingVendorCode* string - Filters purchase orders based on the specified ordering vendor code. This value should be same as 'sellingParty.partyId' in the purchase order. If not included in filter, all purchase orders for all the vendor codes that exist in the vendor group used to authorize API client application are returned. 107 | * - *shipToPartyId* string - Filters purchase orders for a specific buyer's Fulfillment Center/warehouse by providing ship to location id here. This value should be same as 'shipToParty.partyId' in the purchase order. If not included in filter, this will return purchase orders for all the buyer's warehouses used for vendor group purchase orders. 108 | * 109 | */ 110 | public function getPurchaseOrdersStatus($queryParams = []) 111 | { 112 | return $this->send("/vendor/orders/v1/purchaseOrdersStatus", [ 113 | 'method' => 'GET', 114 | 'query' => $queryParams, 115 | ]); 116 | } 117 | 118 | public function getPurchaseOrdersStatusAsync($queryParams = []) 119 | { 120 | return $this->sendAsync("/vendor/orders/v1/purchaseOrdersStatus", [ 121 | 'method' => 'GET', 122 | 'query' => $queryParams, 123 | ]); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/Api/VendorShipments.php: -------------------------------------------------------------------------------- 1 | send("/vendor/shipping/v1/shipmentConfirmations", [ 24 | 'method' => 'POST', 25 | 'json' => $body 26 | ]); 27 | } 28 | 29 | public function SubmitShipmentConfirmationsAsync($body = []) 30 | { 31 | return $this->sendAsync("/vendor/shipping/v1/shipmentConfirmations", [ 32 | 'method' => 'POST', 33 | 'json' => $body 34 | ]); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Api/VendorTransactionStatus.php: -------------------------------------------------------------------------------- 1 | send("/vendor/transactions/v1/transactions/{$transactionId}", [ 26 | 'method' => 'GET', 27 | ]); 28 | } 29 | 30 | public function getTransactionAsync($transactionId) 31 | { 32 | return $this->sendAsync("/vendor/transactions/v1/transactions/{$transactionId}", [ 33 | 'method' => 'GET', 34 | ]); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Client.php: -------------------------------------------------------------------------------- 1 | credentials = $credentials; 15 | $this->config = $config; 16 | $this->signer = new Signer(); //Should be injected :( 17 | } 18 | 19 | 20 | private function normalizeHeaders($headers) 21 | { 22 | return $result = array_combine( 23 | array_map(function($header) { return strtolower($header); }, array_keys($headers)), 24 | $headers 25 | ); 26 | 27 | } 28 | 29 | private function headerValue($header) 30 | { 31 | return \GuzzleHttp\Psr7\Header::parse($header)[0]; 32 | } 33 | 34 | 35 | private function prepareRequestOptions($uri, $requestOptions) 36 | { 37 | $requestOptions['headers'] = $requestOptions['headers'] ?? []; 38 | $requestOptions['headers']['accept'] = 'application/json'; 39 | $requestOptions['headers'] = $this->normalizeHeaders($requestOptions['headers']); 40 | 41 | 42 | //Prepare for signing 43 | $signOptions = [ 44 | 'service' => 'execute-api', 45 | 'access_token' => $this->credentials['access_token'], 46 | 'access_key' => $this->credentials['sts_credentials']['access_key'], 47 | 'secret_key' => $this->credentials['sts_credentials']['secret_key'], 48 | 'security_token' => $this->credentials['sts_credentials']['session_token'], 49 | 'region' => $this->config['region'] ?? null, 50 | 'host' => $this->config['host'], 51 | 'uri' => $uri, 52 | 'method' => $requestOptions['method'] 53 | ]; 54 | 55 | if (isset($requestOptions['query'])) { 56 | $query = $requestOptions['query']; 57 | ksort($query); 58 | $signOptions['query_string'] = \GuzzleHttp\Psr7\Query::build($query); 59 | } 60 | 61 | if (isset($requestOptions['form_params'])) { 62 | ksort($requestOptions['form_params']); 63 | $signOptions['payload'] = \GuzzleHttp\Psr7\Query::build($requestOptions['form_params']); 64 | } 65 | 66 | if (isset($requestOptions['json'])) { 67 | ksort($requestOptions['json']); 68 | $signOptions['payload'] = json_encode($requestOptions['json']); 69 | } 70 | 71 | //Sign 72 | $requestOptions = $this->signer->sign($requestOptions, $signOptions); 73 | 74 | return $requestOptions; 75 | } 76 | 77 | public function send($uri, $requestOptions = []) 78 | { 79 | 80 | $requestOptions = $this->prepareRequestOptions($uri, $requestOptions); 81 | $client = $this->createHttpClient([ 82 | 'base_uri' => 'https://' . $this->config['host'] 83 | ]); 84 | 85 | try { 86 | $this->lastHttpResponse = null; 87 | $method = $requestOptions['method']; 88 | unset($requestOptions['method']); 89 | $response = $client->request($method, $uri, $requestOptions); 90 | $this->lastHttpResponse = $response; 91 | return json_decode($response->getBody(), true); 92 | } catch (\GuzzleHttp\Exception\ClientException $e) { 93 | $this->lastHttpResponse = $e->getResponse(); 94 | throw $e; 95 | } 96 | 97 | } 98 | 99 | public function sendAsync($uri, $requestOptions) 100 | { 101 | $requestOptions = $this->prepareRequestOptions($uri, $requestOptions); 102 | $client = $this->createHttpClient([ 103 | 'base_uri' => 'https://' . $this->config['host'] 104 | ]); 105 | $method = $requestOptions['method']; 106 | unset($requestOptions['method']); 107 | return $client->requestAsync($method, $uri, $requestOptions); 108 | } 109 | 110 | public function getLastHttpResponse() 111 | { 112 | return $this->lastHttpResponse; 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /src/Credentials.php: -------------------------------------------------------------------------------- 1 | config = $config; 19 | $this->tokenStorage = $tokenStorage; 20 | $this->signer = $signer; 21 | } 22 | 23 | /** 24 | * Returns credentials 25 | * use $useMigrationToken = true for /authorization/v1/authorizationCode request 26 | * @param false $useMigrationToken 27 | * @return array 28 | * @throws \Exception 29 | */ 30 | public function getCredentials($useMigrationToken = false) 31 | { 32 | $lwaAccessToken = $useMigrationToken === true ? $this->getMigrationToken() : 33 | ($useMigrationToken === 'grantless' ? $this->getGrantlessAuthToken() : $this->getLWAToken()); 34 | $stsCredentials = $this->getStsTokens(); 35 | 36 | return [ 37 | 'access_token' => $lwaAccessToken, 38 | 'sts_credentials' => $stsCredentials 39 | ]; 40 | } 41 | 42 | /** 43 | * Prepares credentials for clients which require Restricted Data Tokens 44 | * see: https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/use-case-guides/tokens-api-use-case-guide/tokens-API-use-case-guide-2021-03-01.md 45 | * 46 | * 47 | * @param array https://github.com/amzn/selling-partner-api-docs/blob/main/references/tokens-api/tokens_2021-03-01.md#createrestricteddatatokenrequest$restrictedOperations Array with items representing CreateRestrictedDataTokenRequest 48 | * see: https://github.com/amzn/selling-partner-api-docs/blob/main/references/tokens-api/tokens_2021-03-01.md#createrestricteddatatokenrequest 49 | * @return array aceess token and STS credentials 50 | */ 51 | public function getRdtCredentials(array $restrictedOperations) 52 | { 53 | $rdAccessToken = $this->getRestrictedDataAccessToken($restrictedOperations); 54 | $stsCredentials = $this->getStsTokens(); 55 | 56 | return [ 57 | 'access_token' => $rdAccessToken, 58 | 'sts_credentials' => $stsCredentials 59 | ]; 60 | } 61 | 62 | private function getRestrictedDataAccessToken($restrictedOperations = []) 63 | { 64 | $restrictedOperationsHash = md5(\json_encode($restrictedOperations)); 65 | $tokenKey = 'restricted_data_token_' . $restrictedOperationsHash; 66 | $knownToken = $this->loadTokenFromStorage($tokenKey); 67 | if (!is_null($knownToken)) { 68 | return $knownToken; 69 | } 70 | 71 | $cred = $this->getCredentials(); 72 | $tokensClient = new \DoubleBreak\Spapi\Api\Tokens($cred, $this->config); 73 | 74 | $result = $tokensClient->createRestrictedDataToken($restrictedOperations); 75 | $rdt = $result['restrictedDataToken']; 76 | $expiresOn = time() + $result['expiresIn']; 77 | 78 | $this->tokenStorage->storeToken($tokenKey, [ 79 | 'token' => $rdt, 80 | 'expiresOn' => $expiresOn 81 | ]); 82 | 83 | return $rdt; 84 | } 85 | 86 | private function getLWAToken() 87 | { 88 | 89 | $knownToken = $this->loadTokenFromStorage('lwa_access_token'); 90 | if (!is_null($knownToken)) { 91 | return $knownToken; 92 | } 93 | 94 | $client = $this->createHttpClient([ 95 | 'base_uri' => 'https://api.amazon.com' 96 | ]); 97 | 98 | try { 99 | $requestOptions = [ 100 | 'form_params' => [ 101 | 'grant_type' => 'refresh_token', 102 | 'refresh_token' => $this->config['refresh_token'], 103 | 'client_id' => $this->config['client_id'], 104 | 'client_secret' => $this->config['client_secret'] 105 | ] 106 | ]; 107 | $response = $client->post('/auth/o2/token', $requestOptions); 108 | } catch (\Exception $e) { 109 | //log something 110 | throw $e; 111 | } 112 | $json = json_decode($response->getBody(), true); 113 | $this->tokenStorage->storeToken('lwa_access_token', [ 114 | 'token' => $json['access_token'], 115 | 'expiresOn' => time() + ($this->config['access_token_longevity'] ?? 3600) 116 | ]); 117 | 118 | return $json['access_token']; 119 | 120 | } 121 | 122 | /** 123 | * Request a Login with Amazon access token 124 | * @see https://github.com/amzn/selling-partner-api-docs/blob/main/guides/developer-guide/SellingPartnerApiDeveloperGuide.md#step-1-request-a-login-with-amazon-access-token 125 | * @return mixed 126 | * @throws \Exception 127 | */ 128 | public function getMigrationToken() 129 | { 130 | $knownToken = $this->loadTokenFromStorage('migration_token'); 131 | if (!is_null($knownToken)) { 132 | return $knownToken; 133 | } 134 | 135 | $client = $this->createHttpClient([ 136 | 'base_uri' => 'https://api.amazon.com' 137 | ]); 138 | 139 | try { 140 | $requestOptions = [ 141 | 'form_params' => [ 142 | 'grant_type' => 'client_credentials', 143 | 'scope' => 'sellingpartnerapi::migration', 144 | 'client_id' => $this->config['client_id'], 145 | 'client_secret' => $this->config['client_secret'] 146 | ] 147 | ]; 148 | $response = $client->post('/auth/o2/token', $requestOptions); 149 | 150 | $json = json_decode($response->getBody(), true); 151 | 152 | } catch (\Exception $e) { 153 | //log something 154 | throw $e; 155 | } 156 | 157 | if (!array_key_exists('access_token', $json)) { 158 | throw new IncorrectResponseException('Failed to load migration token.'); 159 | } 160 | 161 | $this->tokenStorage->storeToken('migration_token', [ 162 | 'token' => $json['access_token'], 163 | 'expiresOn' => time() + $json['expires_in'] 164 | ]); 165 | 166 | return $json['access_token']; 167 | } 168 | 169 | public function getGrantlessAuthToken() 170 | { 171 | $knownToken = $this->loadTokenFromStorage('grantless_auth_token'); 172 | if (!is_null($knownToken)) { 173 | return $knownToken; 174 | } 175 | 176 | $client = $this->createHttpClient([ 177 | 'base_uri' => 'https://api.amazon.com' 178 | ]); 179 | 180 | try { 181 | $requestOptions = [ 182 | 'form_params' => [ 183 | 'grant_type' => 'client_credentials', 184 | 'scope' => 'sellingpartnerapi::notifications', 185 | 'client_id' => $this->config['client_id'], 186 | 'client_secret' => $this->config['client_secret'] 187 | ] 188 | ]; 189 | $response = $client->post('/auth/o2/token', $requestOptions); 190 | 191 | $json = json_decode($response->getBody(), true); 192 | 193 | } catch (\Exception $e) { 194 | //log something 195 | throw $e; 196 | } 197 | 198 | if (!array_key_exists('access_token', $json)) { 199 | throw new IncorrectResponseException('Failed to load grantless auth token.'); 200 | } 201 | 202 | $this->tokenStorage->storeToken('grantless_auth_token', [ 203 | 'token' => $json['access_token'], 204 | 'expiresOn' => time() + $json['expires_in'] 205 | ]); 206 | 207 | return $json['access_token']; 208 | } 209 | 210 | private function getStsTokens() 211 | { 212 | $knownToken = $this->loadTokenFromStorage('sts_credentials'); 213 | if (!is_null($knownToken)) { 214 | return $knownToken; 215 | } 216 | 217 | $requestOptions = [ 218 | 'headers' => [ 219 | 'accept' => 'application/json' 220 | ], 221 | 'form_params' => [ 222 | 'Action' => 'AssumeRole', 223 | 'DurationSeconds' => $this->config['sts_session _longevity'] ?? 3600, 224 | 'RoleArn' => $this->config['role_arn'], 225 | 'RoleSessionName' => 'session1', 226 | 'Version' => '2011-06-15', 227 | ] 228 | ]; 229 | 230 | $host = 'sts.amazonaws.com'; 231 | $uri = '/'; 232 | 233 | $requestOptions = $this->signer->sign($requestOptions, [ 234 | 'service' => 'sts', 235 | 'access_key' => $this->config['access_key'], 236 | 'secret_key' => $this->config['secret_key'], 237 | 'region' => 'us-east-1', //This should be hardcoded 238 | 'host' => $host, 239 | 'uri' => $uri, 240 | 'payload' => \GuzzleHttp\Psr7\Query::build($requestOptions['form_params']), 241 | 'method' => 'POST', 242 | ]); 243 | 244 | $client = $this->createHttpClient([ 245 | 'base_uri' => 'https://' . $host 246 | ]); 247 | 248 | try { 249 | $response = $client->post($uri, $requestOptions); 250 | 251 | $json = json_decode($response->getBody(), true); 252 | $credentials = $json['AssumeRoleResponse']['AssumeRoleResult']['Credentials'] ?? null; 253 | $tokens = [ 254 | 'access_key' => $credentials['AccessKeyId'], 255 | 'secret_key' => $credentials['SecretAccessKey'], 256 | 'session_token' => $credentials['SessionToken'] 257 | ]; 258 | $this->tokenStorage->storeToken('sts_credentials', [ 259 | 'token' => $tokens, 260 | 'expiresOn' => $credentials['Expiration'] 261 | ]); 262 | 263 | return $tokens; 264 | 265 | } catch (\Exception $e) { 266 | //log something 267 | throw $e; 268 | } 269 | 270 | } 271 | 272 | /** 273 | * Exchanges the LWA authorization code for an LWA refresh token 274 | * @see https://github.com/amzn/selling-partner-api-docs/blob/main/guides/developer-guide/SellingPartnerApiDeveloperGuide.md#step-5-your-application-exchanges-the-lwa-authorization-code-for-an-lwa-refresh-token 275 | * @param $authorizationCode 276 | * @throws \Exception 277 | */ 278 | public function exchangesAuthorizationCodeForRefreshToken($authorizationCode) 279 | { 280 | $client = $this->createHttpClient([ 281 | 'base_uri' => 'https://api.amazon.com' 282 | ]); 283 | 284 | try { 285 | $requestOptions = [ 286 | 'form_params' => [ 287 | 'grant_type' => 'authorization_code', 288 | 'code' => $authorizationCode, 289 | 'client_id' => $this->config['client_id'], 290 | 'client_secret' => $this->config['client_secret'] 291 | ] 292 | ]; 293 | $response = $client->post('/auth/o2/token', $requestOptions); 294 | 295 | return json_decode($response->getBody(), true); 296 | 297 | } catch (\Exception $e) { 298 | throw $e; 299 | } 300 | } 301 | 302 | private function loadTokenFromStorage($key) 303 | { 304 | $knownToken = $this->tokenStorage->getToken($key); 305 | if (!empty($knownToken)) { 306 | $expiresOn = $knownToken['expiresOn']; 307 | if ($expiresOn > time()) { 308 | return $knownToken['token']; 309 | } 310 | } 311 | return null; 312 | } 313 | } 314 | -------------------------------------------------------------------------------- /src/Helper/Feeder.php: -------------------------------------------------------------------------------- 1 | false]); 60 | 61 | $request = new Request( 62 | // PUT! 63 | 'PUT', 64 | // predefined url 65 | $feedUploadUrl, 66 | // content type equal to content type from response createFeedDocument-operation 67 | array('Content-Type' => $contentType), 68 | // resource File 69 | $file_content 70 | ); 71 | 72 | $response = $client->send($request); 73 | $HTTPStatusCode = $response->getStatusCode(); 74 | 75 | if ($HTTPStatusCode == 200) { 76 | return 'Done'; 77 | } else { 78 | return $response->getBody()->getContents(); 79 | } 80 | } 81 | 82 | /** 83 | * @param $payload : Response from getFeedDocument Function. e.g.: response['payload'] 84 | * @return array : Feed Processing Report. 85 | */ 86 | public function downloadFeedProcessingReport($payload) 87 | { 88 | $key = null; 89 | $initializationVector = null; 90 | $feedUploadUrl = $payload['url']; 91 | 92 | // check if decryption in required 93 | if (isset($payload['encryptionDetails'])) { 94 | $key = $payload['encryptionDetails']['key']; 95 | $initializationVector = $payload['encryptionDetails']['initializationVector']; 96 | 97 | // base64 decode before using in encryption 98 | $initializationVector = base64_decode($initializationVector, true); 99 | $key = base64_decode($key, true); 100 | } 101 | 102 | $feedDownloadUrl = $payload['url']; 103 | 104 | if (!is_null($key)) { 105 | $feed_processing_report_content = ASECryptoStream::decrypt(file_get_contents($feedDownloadUrl), $key, $initializationVector); 106 | } else { 107 | $feed_processing_report_content = file_get_contents($feedDownloadUrl); 108 | } 109 | 110 | if(isset($payload['compressionAlgorithm']) && $payload['compressionAlgorithm']=='GZIP') { 111 | $feed_processing_report_content = gzdecode($feed_processing_report_content); 112 | } 113 | 114 | // check if report content is json encoded or not 115 | if ($this->isJson($feed_processing_report_content) == true) { 116 | $json = $feed_processing_report_content; 117 | } else { 118 | $feed_processing_report_content = preg_replace('/\s+/S', " ", $feed_processing_report_content); 119 | $xml = simplexml_load_string($feed_processing_report_content); 120 | $json = json_encode($xml); 121 | } 122 | 123 | return json_decode($json, TRUE); 124 | } 125 | 126 | public function isJson($string) { 127 | json_decode($string); 128 | return json_last_error() === JSON_ERROR_NONE; 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/HttpClientFactoryTrait.php: -------------------------------------------------------------------------------- 1 | config['http'] ?? []; 8 | $httpConfig = array_merge($httpConfig, $config); 9 | $client = new \GuzzleHttp\Client($httpConfig); 10 | return $client; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/IncorrectResponseException.php: -------------------------------------------------------------------------------- 1 | $host, 61 | 'user-agent' => $userAgent, 62 | ]; 63 | if (!is_null($accessToken)) { 64 | $canonicalHeaders['x-amz-access-token'] = $accessToken; 65 | } 66 | $canonicalHeaders['x-amz-date'] = $amzdate; 67 | if (!is_null($securityToken)) { 68 | $canonicalHeaders['x-amz-security-token'] = $securityToken; 69 | } 70 | 71 | $canonicalHeadersStr = ''; 72 | foreach($canonicalHeaders as $h => $v) { 73 | $canonicalHeadersStr .= $h . ':' . $v . "\n"; 74 | } 75 | $signedHeadersStr = join(';' , array_keys($canonicalHeaders)); 76 | 77 | //Prepare credentials scope 78 | $credentialScope = $date . '/' . $region . '/' . $service . '/' . $terminationString; 79 | 80 | //prepare canonical request 81 | $canonicalRequest = $method . "\n" . $uri . "\n" . $queryString . "\n" . $canonicalHeadersStr . "\n" . $signedHeadersStr . "\n" . $hashedPayload; 82 | 83 | //Prepare the signature payload 84 | $stringToSign = $algorithm . "\n" . $amzdate . "\n" . $credentialScope . "\n" . hash('sha256', $canonicalRequest); 85 | 86 | //Prepare lockers 87 | $kSecret = "AWS4" . $secretKey; 88 | $kDate = hash_hmac('sha256', $date, $kSecret, true); 89 | $kRegion = hash_hmac('sha256', $region, $kDate, true); 90 | $kService = hash_hmac('sha256', $service, $kRegion, true); 91 | $kSigning = hash_hmac('sha256', $terminationString, $kService, true); 92 | 93 | //Compute the signature 94 | $signature = trim(hash_hmac('sha256', $stringToSign, $kSigning)); // Without fourth parameter passed as true, returns lowercase hexits as called for by docs 95 | 96 | $authorizationHeader = $algorithm . " Credential={$accessKey}/{$credentialScope}, SignedHeaders={$signedHeadersStr}, Signature={$signature}"; 97 | 98 | 99 | $headers = array_merge($canonicalHeaders, [ 100 | "Authorization" => $authorizationHeader, 101 | ]); 102 | 103 | $request['headers'] = array_merge($request['headers'], $headers); 104 | 105 | return $request; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/SignerException.php: -------------------------------------------------------------------------------- 1 | filePath = $filePath; 11 | } 12 | 13 | 14 | public function getToken($key): ?array 15 | { 16 | $content = file_get_contents($this->filePath); 17 | 18 | if ($content != '') { 19 | $json = json_decode($content, true); 20 | return $json[$key] ?? null; 21 | } 22 | return null; 23 | } 24 | 25 | 26 | public function storeToken($key, $value) 27 | { 28 | 29 | $json = []; 30 | $content = file_get_contents($this->filePath); 31 | if ($content != '') { 32 | $json = json_decode($content, true); 33 | } 34 | $json[$key] = $value; 35 | file_put_contents($this->filePath, json_encode($json)); 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/TokenStorageInterface.php: -------------------------------------------------------------------------------- 1 |