Skip to content

Commit

Permalink
Fixed serializer & return types (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
owsiakl authored Sep 27, 2022
1 parent 8145645 commit ee9e6ad
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 55 deletions.
13 changes: 8 additions & 5 deletions rector-php.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use AmazonPHP\Rector\ValueObject\NullableReturnTypeDeclaration;
use AmazonPHP\SellingPartner\Api\VendorOrdersApi\VendorDirectFulfillmentOrdersSDK;
use AmazonPHP\SellingPartner\Model\CatalogItem\Item as CatalogItem;
use AmazonPHP\SellingPartner\Model\CatalogItem\ItemSearchResults;
use AmazonPHP\SellingPartner\Model\FulfillmentInbound\InboundShipmentInfo;
use AmazonPHP\SellingPartner\Model\FulfillmentInbound\NonPartneredLtlDataOutput;
use AmazonPHP\SellingPartner\Model\FulfillmentInbound\NonPartneredSmallParcelPackageOutput;
Expand Down Expand Up @@ -42,11 +43,8 @@
__DIR__ ,
]);
$config->paths([
__DIR__ . '/src',
]);
$config->skip([
__DIR__ . '/src/AmazonPHP/SellingPartner/Marketplace.php',
__DIR__ . '/src/AmazonPHP/SellingPartner/AccessToken.php',
__DIR__ . '/src/AmazonPHP/SellingPartner/Api',
__DIR__ . '/src/AmazonPHP/SellingPartner/Model',
]);
$config->cacheClass(MemoryCacheStorage::class);

Expand Down Expand Up @@ -174,6 +172,11 @@
* Listings API
*/
new NullableReturnTypeDeclaration(ItemProcurement::class, 'getCostPrice'),
/**
* Catalog Items API
*/
new NullableReturnTypeDeclaration(ItemSearchResults::class, 'getPagination'),
new NullableReturnTypeDeclaration(ItemSearchResults::class, 'getRefinements'),
]
);
};
9 changes: 3 additions & 6 deletions src/AmazonPHP/SellingPartner/Exception/ApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,17 @@ final class ApiException extends Exception
* @param null|\stdClass|string $responseBody HTTP decoded body of the server response either as \stdClass or string
* @param null|\Throwable $previousException
*/
public function __construct(string $message = '', int $code = 0, /**
* The HTTP header of the server response.
*/
protected array $responseHeaders = null, protected $responseBody = null, \Throwable $previousException = null)
public function __construct(string $message = '', int $code = 0, protected ?array $responseHeaders = null, protected $responseBody = null, \Throwable $previousException = null)
{
parent::__construct($message, $code, $previousException);
}

/**
* Gets the HTTP response header.
*
* @return string[] HTTP response header
* @return null|string[] HTTP response header
*/
public function getResponseHeaders() : array
public function getResponseHeaders() : ?array
{
return $this->responseHeaders;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public function setNumberOfResults(int $number_of_results) : self
/**
* Gets pagination.
*/
public function getPagination() : Pagination
public function getPagination() : ?Pagination
{
return $this->container['pagination'];
}
Expand All @@ -261,7 +261,7 @@ public function setPagination(Pagination $pagination) : self
/**
* Gets refinements.
*/
public function getRefinements() : Refinements
public function getRefinements() : ?Refinements
{
return $this->container['refinements'];
}
Expand Down
4 changes: 2 additions & 2 deletions src/AmazonPHP/SellingPartner/ObjectSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ public static function toFormValue(\SplFileObject|string $value) : bool|string
* If it's a datetime object, format it in ISO8601
* If it's a boolean, convert it to "true" or "false".
*
* @param bool|\DateTimeInterface|string $value the value of the parameter
* @param mixed $value the value of the parameter
*
* @return string the header string
*/
public static function toString(bool|\DateTimeInterface|string $value) : string
public static function toString(mixed $value) : string
{
if ($value instanceof \DateTimeInterface) { // datetime in ISO8601 zulu format
return $value->setTimezone(new \DateTimeZone('UTC'))->format(self::$dateTimeFormat);
Expand Down
85 changes: 55 additions & 30 deletions src/AmazonPHP/SellingPartner/SellingPartnerSDK.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,58 @@
namespace AmazonPHP\SellingPartner;

use AmazonPHP\SellingPartner\Api\AplusContentApi\APlusSDK;
use AmazonPHP\SellingPartner\Api\AplusContentApi\APlusSDKInterface;
use AmazonPHP\SellingPartner\Api\AuthorizationApi\AuthorizationSDK;
use AmazonPHP\SellingPartner\Api\AuthorizationApi\AuthorizationSDKInterface;
use AmazonPHP\SellingPartner\Api\CatalogApi\CatalogItemSDK;
use AmazonPHP\SellingPartner\Api\CatalogApi\CatalogItemSDKInterface;
use AmazonPHP\SellingPartner\Api\DefaultApi\FinancesSDK;
use AmazonPHP\SellingPartner\Api\DefaultApi\FinancesSDKInterface;
use AmazonPHP\SellingPartner\Api\DefinitionsApi\ProductTypesDefinitionsSDK;
use AmazonPHP\SellingPartner\Api\DefinitionsApi\ProductTypesDefinitionsSDKInterface;
use AmazonPHP\SellingPartner\Api\FbaInboundApi\FBAInboundSDK;
use AmazonPHP\SellingPartner\Api\FbaInboundApi\FBAInboundSDKInterface;
use AmazonPHP\SellingPartner\Api\FbaInboundApi\FulfillmentInboundSDK;
use AmazonPHP\SellingPartner\Api\FbaInboundApi\FulfillmentInboundSDKInterface;
use AmazonPHP\SellingPartner\Api\FbaInventoryApi\FBAInventorySDK;
use AmazonPHP\SellingPartner\Api\FbaInventoryApi\FBAInventorySDKInterface;
use AmazonPHP\SellingPartner\Api\FbaOutboundApi\FulfillmentOutboundSDK;
use AmazonPHP\SellingPartner\Api\FbaOutboundApi\FulfillmentOutboundSDKInterface;
use AmazonPHP\SellingPartner\Api\FeedsApi\FeedsSDK;
use AmazonPHP\SellingPartner\Api\FeedsApi\FeedsSDKInterface;
use AmazonPHP\SellingPartner\Api\FeesApi\ProductFeesSDK;
use AmazonPHP\SellingPartner\Api\FeesApi\ProductFeesSDKInterface;
use AmazonPHP\SellingPartner\Api\ListingsApi\ListingsItemsSDK;
use AmazonPHP\SellingPartner\Api\MerchantFulfillmentApi\MerchantFulfillmentSDK;
use AmazonPHP\SellingPartner\Api\MerchantFulfillmentApi\MerchantFulfillmentSDKInterface;
use AmazonPHP\SellingPartner\Api\MessagingApi\MessagingSDK;
use AmazonPHP\SellingPartner\Api\MessagingApi\MessagingSDKInterface;
use AmazonPHP\SellingPartner\Api\NotificationsApi\NotificationsSDK;
use AmazonPHP\SellingPartner\Api\NotificationsApi\NotificationsSDKInterface;
use AmazonPHP\SellingPartner\Api\OrdersV0Api;
use AmazonPHP\SellingPartner\Api\ProductPricingApi\ProductPricingSDK;
use AmazonPHP\SellingPartner\Api\ProductPricingApi\ProductPricingSDKInterface;
use AmazonPHP\SellingPartner\Api\ReportsApi\ReportsSDK;
use AmazonPHP\SellingPartner\Api\ReportsApi\ReportsSDKInterface;
use AmazonPHP\SellingPartner\Api\SalesApi\SalesSDK;
use AmazonPHP\SellingPartner\Api\SalesApi\SalesSDKInterface;
use AmazonPHP\SellingPartner\Api\SellersApi\SellersSDK;
use AmazonPHP\SellingPartner\Api\SellersApi\SellersSDKInterface;
use AmazonPHP\SellingPartner\Api\ServiceApi\ServicesSDK;
use AmazonPHP\SellingPartner\Api\ServiceApi\ServicesSDKInterface;
use AmazonPHP\SellingPartner\Api\ShipmentApi;
use AmazonPHP\SellingPartner\Api\ShipmentInvoiceApi\ShipmentInvoicingSDK;
use AmazonPHP\SellingPartner\Api\ShipmentInvoiceApi\ShipmentInvoicingSDKInterface;
use AmazonPHP\SellingPartner\Api\ShippingApi\ShippingSDK;
use AmazonPHP\SellingPartner\Api\ShippingApi\ShippingSDKInterface;
use AmazonPHP\SellingPartner\Api\SmallAndLightApi\FBASmallAndLightSDK;
use AmazonPHP\SellingPartner\Api\SmallAndLightApi\FBASmallAndLightSDKInterface;
use AmazonPHP\SellingPartner\Api\SolicitationsApi\SolicitationsSDK;
use AmazonPHP\SellingPartner\Api\SolicitationsApi\SolicitationsSDKInterface;
use AmazonPHP\SellingPartner\Api\TokensApi\TokensSDK;
use AmazonPHP\SellingPartner\Api\TokensApi\TokensSDKInterface;
use AmazonPHP\SellingPartner\Api\UploadsApi\UploadsSDK;
use AmazonPHP\SellingPartner\Api\UploadsApi\UploadsSDKInterface;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
Expand Down Expand Up @@ -73,152 +98,152 @@ public function configuration() : Configuration
return $this->configuration;
}

public function oAuth() : object|string
public function oAuth() : OAuth
{
return $this->instantiateSDK(OAuth::class);
}

public function aPlus() : object|string
public function aPlus() : APlusSDKInterface
{
return $this->instantiateSDK(APlusSDK::class);
}

public function authorization() : object|string
public function authorization() : AuthorizationSDKInterface
{
return $this->instantiateSDK(AuthorizationSDK::class);
}

public function catalogItem() : object|string
public function catalogItem() : CatalogItemSDKInterface
{
return $this->instantiateSDK(CatalogItemSDK::class);
}

public function fbaInbound() : object|string
public function fbaInbound() : FBAInboundSDKInterface
{
return $this->instantiateSDK(FBAInboundSDK::class);
}

public function fbaInventory() : object|string
public function fbaInventory() : FBAInventorySDKInterface
{
return $this->instantiateSDK(FBAInventorySDK::class);
}

public function fbaSmallAndLight() : object|string
public function fbaSmallAndLight() : FBASmallAndLightSDKInterface
{
return $this->instantiateSDK(FBASmallAndLightSDK::class);
}

public function feeds() : object|string
public function feeds() : FeedsSDKInterface
{
return $this->instantiateSDK(FeedsSDK::class);
}

public function finances() : object|string
public function finances() : FinancesSDKInterface
{
return $this->instantiateSDK(FinancesSDK::class);
}

public function fulfillmentInbound() : object|string
public function fulfillmentInbound() : FulfillmentInboundSDKInterface
{
return $this->instantiateSDK(FulfillmentInboundSDK::class);
}

public function fulfillmentOutbound() : object|string
public function fulfillmentOutbound() : FulfillmentOutboundSDKInterface
{
return $this->instantiateSDK(FulfillmentOutboundSDK::class);
}

public function listingsItems() : object|string
public function listingsItems() : ListingsItemsSDK
{
return $this->instantiateSDK(ListingsItemsSDK::class);
}

public function merchantFulfillment() : object|string
public function merchantFulfillment() : MerchantFulfillmentSDKInterface
{
return $this->instantiateSDK(MerchantFulfillmentSDK::class);
}

public function messaging() : object|string
public function messaging() : MessagingSDKInterface
{
return $this->instantiateSDK(MessagingSDK::class);
}

public function notifications() : object|string
public function notifications() : NotificationsSDKInterface
{
return $this->instantiateSDK(NotificationsSDK::class);
}

public function orders() : object|string
public function orders() : OrdersV0Api\OrdersSDKInterface
{
return $this->instantiateSDK(OrdersV0Api\OrdersSDK::class);
}

public function orderShipment() : object|string
public function orderShipment() : ShipmentApi\OrdersSDKInterface
{
return $this->instantiateSDK(ShipmentApi\OrdersSDK::class);
}

public function productFees() : object|string
public function productFees() : ProductFeesSDKInterface
{
return $this->instantiateSDK(ProductFeesSDK::class);
}

public function productPricing() : object|string
public function productPricing() : ProductPricingSDKInterface
{
return $this->instantiateSDK(ProductPricingSDK::class);
}

public function productTypesDefinitions() : object|string
public function productTypesDefinitions() : ProductTypesDefinitionsSDKInterface
{
return $this->instantiateSDK(ProductTypesDefinitionsSDK::class);
}

public function reports() : object|string
public function reports() : ReportsSDKInterface
{
return $this->instantiateSDK(ReportsSDK::class);
}

public function sales() : object|string
public function sales() : SalesSDKInterface
{
return $this->instantiateSDK(SalesSDK::class);
}

public function sellers() : object|string
public function sellers() : SellersSDKInterface
{
return $this->instantiateSDK(SellersSDK::class);
}

public function services() : object|string
public function services() : ServicesSDKInterface
{
return $this->instantiateSDK(ServicesSDK::class);
}

public function shipmentInvoicing() : object|string
public function shipmentInvoicing() : ShipmentInvoicingSDKInterface
{
return $this->instantiateSDK(ShipmentInvoicingSDK::class);
}

public function shipping() : object|string
public function shipping() : ShippingSDKInterface
{
return $this->instantiateSDK(ShippingSDK::class);
}

public function solicitations() : object|string
public function solicitations() : SolicitationsSDKInterface
{
return $this->instantiateSDK(SolicitationsSDK::class);
}

public function tokens() : object|string
public function tokens() : TokensSDKInterface
{
return $this->instantiateSDK(TokensSDK::class);
}

public function uploads() : object|string
public function uploads() : UploadsSDKInterface
{
return $this->instantiateSDK(UploadsSDK::class);
}

public function vendor() : object|string
public function vendor() : VendorSDK
{
return $this->instantiateSDK(VendorSDK::class);
}
Expand Down
Loading

0 comments on commit ee9e6ad

Please sign in to comment.