Skip to content

Commit

Permalink
Merge branch 'jlevers:main' into upload-charset-336
Browse files Browse the repository at this point in the history
  • Loading branch information
quazardous committed Jan 13, 2023
2 parents 6ed5e40 + e5b7bd3 commit 3eab82e
Show file tree
Hide file tree
Showing 134 changed files with 245 additions and 4,830 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A PHP library for connecting to Amazon's [Selling Partner API](https://github.co

| | |
| ------ | ------ |
| [![Highside Labs Logo](https://highsidelabs.co/images/favicon.ico)](https://highsidelabs.co) | **This package is developed and maintained as part of [Highside Labs](https://highsidelabs.co). If you need support integrating with Amazon's (or any other e-commerce platform's) APIs, we're happy to help! Shoot us an email at [hi@highsidelabs.co](mailto:hi@highsidelabs.co). We'd love to hear from you :)** |
| [![Highside Labs Logo](https://highsidelabs.co/static/favicons/favicon.png)](https://highsidelabs.co) | **This package is developed and maintained as part of [Highside Labs](https://highsidelabs.co). If you need support integrating with Amazon's (or any other e-commerce platform's) APIs, we're happy to help! Shoot us an email at [hi@highsidelabs.co](mailto:hi@highsidelabs.co). We'd love to hear from you :)** |

If you've found this library useful, please consider [becoming a Sponsor](https://github.com/sponsors/jlevers), or making a one-time donation via the button below. I appreciate any and all support you can provide!

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"name": "jlevers/selling-partner-api",
"version": "5.4.6",
"version": "5.5.2",
"description": "PHP client for Amazon's Selling Partner API",
"keywords": [
"api",
"selling-partner-api",
"amazon",
"ecommerce",
"sp-api",
"php",
"sdk",
"rest",
"api"
Expand Down Expand Up @@ -41,6 +40,7 @@
"psr-4": { "SellingPartnerApi\\Tests\\" : "test/" }
},
"scripts": {
"test": "vendor/bin/phpunit"
"test": "vendor/bin/phpunit",
"lint": "vendor/bin/php-cs-fixer fix"
}
}
104 changes: 1 addition & 103 deletions lib/Api/AplusContentV20201101Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,10 @@

namespace SellingPartnerApi\Api;

use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use SellingPartnerApi\ApiException;
use SellingPartnerApi\Configuration;
use SellingPartnerApi\HeaderSelector;
use SellingPartnerApi\ObjectSerializer;

/**
Expand All @@ -43,74 +38,8 @@
* @category Class
* @package SellingPartnerApi
*/
class AplusContentV20201101Api
class AplusContentV20201101Api extends BaseApi
{
/**
* @var ClientInterface
*/
protected $client;

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

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

/**
* @var int Host index
*/
protected $hostIndex;

/**
* @param Configuration $config
* @param ClientInterface $client
* @param HeaderSelector $selector
* @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
*/
public function __construct(
Configuration $config,
ClientInterface $client = null,
HeaderSelector $selector = null,
$hostIndex = 0
) {
$this->client = $client ?: new Client();
$this->config = $config;
$this->headerSelector = $selector ?: new HeaderSelector($this->config);
$this->hostIndex = $hostIndex;
}

/**
* Set the host index
*
* @param int $hostIndex Host index (required)
*/
public function setHostIndex($hostIndex)
{
$this->hostIndex = $hostIndex;
}

/**
* Get the host index
*
* @return int Host index
*/
public function getHostIndex()
{
return $this->hostIndex;
}

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

/**
* Operation createContentDocument
*
Expand Down Expand Up @@ -4377,35 +4306,4 @@ public function validateContentDocumentAsinRelationsRequest($marketplace_id, $po
);
}

/**
* 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
*/
private function writeDebug($data)
{
if ($this->config->getDebug()) {
file_put_contents($this->config->getDebugFile(), '[' . date('Y-m-d H:i:s') . ']: ' . print_r($data, true) . "\n", FILE_APPEND);
}
}
}
104 changes: 1 addition & 103 deletions lib/Api/AuthorizationV1Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,10 @@

namespace SellingPartnerApi\Api;

use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use SellingPartnerApi\ApiException;
use SellingPartnerApi\Configuration;
use SellingPartnerApi\HeaderSelector;
use SellingPartnerApi\ObjectSerializer;

/**
Expand All @@ -43,74 +38,8 @@
* @category Class
* @package SellingPartnerApi
*/
class AuthorizationV1Api
class AuthorizationV1Api extends BaseApi
{
/**
* @var ClientInterface
*/
protected $client;

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

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

/**
* @var int Host index
*/
protected $hostIndex;

/**
* @param Configuration $config
* @param ClientInterface $client
* @param HeaderSelector $selector
* @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec
*/
public function __construct(
Configuration $config,
ClientInterface $client = null,
HeaderSelector $selector = null,
$hostIndex = 0
) {
$this->client = $client ?: new Client();
$this->config = $config;
$this->headerSelector = $selector ?: new HeaderSelector($this->config);
$this->hostIndex = $hostIndex;
}

/**
* Set the host index
*
* @param int $hostIndex Host index (required)
*/
public function setHostIndex($hostIndex)
{
$this->hostIndex = $hostIndex;
}

/**
* Get the host index
*
* @return int Host index
*/
public function getHostIndex()
{
return $this->hostIndex;
}

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

/**
* Operation getAuthorizationCode
*
Expand Down Expand Up @@ -548,35 +477,4 @@ public function getAuthorizationCodeRequest($selling_partner_id, $developer_id,
);
}

/**
* 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
*/
private function writeDebug($data)
{
if ($this->config->getDebug()) {
file_put_contents($this->config->getDebugFile(), '[' . date('Y-m-d H:i:s') . ']: ' . print_r($data, true) . "\n", FILE_APPEND);
}
}
}
96 changes: 96 additions & 0 deletions lib/Api/BaseApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?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;
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()) {
file_put_contents(
$this->config->getDebugFile(),
'[' . date('Y-m-d H:i:s') . ']: ' . print_r($data, true) . "\n",
FILE_APPEND
);
}
}
}
Loading

0 comments on commit 3eab82e

Please sign in to comment.