Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix: restore array parameter support in CatalogItemsV20220401Api #832

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":1,"defects":[],"times":{"SellingPartnerApi\\Tests\\AuthenticationTest::testItUsesInjectedAuthorizationSigner":0.009,"SellingPartnerApi\\Tests\\AuthenticationTest::testItUsesDefaultAuthorizationSigner":0.002,"SellingPartnerApi\\Tests\\AuthorizationSignerTest::testItSingsRequests":0,"SellingPartnerApi\\Tests\\RequestSignerTest::testItUsesInjectedRequestSigner":0.001,"SellingPartnerApi\\Tests\\RequestSignerTest::testItUsesDefaultRequestSigner":0,"SellingPartnerApi\\Tests\\RequestSignerTest::testItSingsRequestsWithDefaultRequestSigner":0}}
46 changes: 9 additions & 37 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "jlevers/selling-partner-api",
"version": "5.10.3",
"description": "PHP client for Amazon's Selling Partner API",
"keywords": [
"api",
Expand All @@ -20,54 +21,25 @@
}
],
"require": {
"php": ">=8.2",
"php": ">=7.3",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^6.0|^7.0",
"saloonphp/saloon": "^3.4",
"openspout/openspout": "^4.23",
"illuminate/support": "^11.5"
"phpoffice/phpspreadsheet": "1.25.2"
},
"require-dev": {
"composer/semver": "^3.4",
"highsidelabs/saloon-sdk-generator": "^2.1.0",
"symfony/console": "^7.0",
"psy/psysh": "^0.12.0",
"voku/simple_html_dom": "^4.8",
"laravel/pint": "^1.13",
"phpcompatibility/php-compatibility": "dev-develop",
"phpunit/phpunit": "^11.2",
"fakerphp/faker": "^1.23"
"phpunit/phpunit": "^8.0 || ^9.0",
"friendsofphp/php-cs-fixer": "^3.4"
},
"prefer-stable": true,
"autoload": {
"psr-4": {
"SellingPartnerApi\\": "src/"
},
"files": [
"src/Generator/constants.php"
]
"psr-4": { "SellingPartnerApi\\" : "lib/" }
},
"autoload-dev": {
"psr-4": {
"SellingPartnerApi\\Tests\\": "tests/"
}
"psr-4": { "SellingPartnerApi\\Tests\\" : "test/" }
},
"scripts": {
"lint": [
"@pint",
"@php-compatibility-check"
],
"pint": "php vendor/bin/pint",
"php-compatibility-check": "./vendor/bin/phpcs -p ./src ./bin --standard=PHPCompatibility --runtime-set testVersion 8.2-",
"post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility",
"post-update-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility",
"test": "vendor/bin/phpunit"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
"test": "vendor/bin/phpunit",
"lint": "vendor/bin/php-cs-fixer fix"
}
}
106 changes: 106 additions & 0 deletions lib/Api/BaseApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php

namespace SellingPartnerApi\Api;

use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\RequestOptions;
use SellingPartnerApi\Configuration;
use SellingPartnerApi\HeaderSelector;

abstract class BaseApi
{
/**
* @var ClientInterface
*/
protected $client;

/**
* @var Configuration
*/
protected $config;

/**
* @var HeaderSelector
*/
protected $headerSelector;

/**
* @param Configuration $config
* @param ClientInterface $client
* @param HeaderSelector $selector
*/
public function __construct(
Configuration $config,
ClientInterface $client = null,
HeaderSelector $selector = null
) {
$this->config = $config;
$this->client = $client ?: new Client();
$this->headerSelector = $selector ?: new HeaderSelector($this->config);
}

/**
* @return SellingPartnerApi\Configuration
*/
public function getConfig()
{
return $this->config;
}

/**
* @param SellingPartnerApi\Configuration $config
* @return $this
*/
public function setConfig(Configuration $config)
{
$this->config = $config;
$this->headerSelector = new HeaderSelector($config);
return $this;
}

/**
* Create http client option
*
* @throws \RuntimeException on file opening failure
* @return array of http client options
*/
protected function createHttpClientOption()
{
$options = [];
if ($this->config->getDebug()) {
$options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a');
if (!$options[RequestOptions::DEBUG]) {
throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile());
}
}

return $options;
}

/**
* Writes to the debug log file
*
* @param any $data
* @return void
*/
protected function writeDebug($data)
{
if ($this->config->getDebug()) {
if ($data instanceof Throwable) {
$data = "$data";
} else if ($data instanceof GuzzleHttp\Psr7\Request) {
$data = "{$data->getMethod()} {$data->getUri()}\n" . implode("\n", $data->getHeaders());
} else if ($data instanceof GuzzleHttp\Psr7\Response) {
$data = "{$data->getStatusCode()} {$data->getReasonPhrase()}\n" . implode("\n", $data->getHeaders());
} else {
$data = print_r($data, true);
}
file_put_contents(
$this->config->getDebugFile(),
'[' . date('Y-m-d H:i:s') . ']: ' . $data . "\n",
FILE_APPEND
);
}
}
}
Loading