Skip to content

Releases: jlevers/selling-partner-api

v7.0.2

23 Jun 15:46
Compare
Choose a tag to compare

Changed

  • Cache keys for RDTs include the specific refresh token and delegatee (if applicable)
  • GetAccessTokenRequest doesn't send unnecessary default headers from SellingPartnerApi::defaultHeaders()

Added

  • Endpoint enum now has ::byCountryCode() and ::byRegion() methods

Full Changelog: v7.0.1...v7.0.2

v7.0.1

21 Jun 05:39
Compare
Choose a tag to compare

Added

  • Make user agent configurable (#739)

Fixed

  • Try multiple datetime formats during deserialization before throwing an exception (#737, thanks @KhorneHoly!)
  • Serialize getMyFeesEstimates request properly (#736)

Full Changelog: v7.0.0...v7.0.1

v7.0.0

19 Jun 22:44
Compare
Choose a tag to compare

Changed

  • Minimum PHP version of 8.2
  • Instead of accessing seller/vendor connector classes with SellingPartnerApi::make(...$options)->seller() and SellingPartnerApi::make(...$options)->vendor(), they are now accessed via SellingPartnerApi::seller(...$options) and SellingPartnerApi::vendor(...$options)
  • The authenticationClient constructor argument is now typed GuzzleHttp\Client instead of GuzzleHttp\ClientInterface for better Saloon interoperation
  • DateTimeInterface is used for date parameters instead of DateTime
  • Deprecated APIs are removed, and their connector accessor methods throw exceptions
  • Non-version-specific API accessor methods (e.g., SellerConnector::orders()) are removed, since they're inevitably going to become out of date

Added

  • tokenCache constructor parameter allows the user to define a class that implements TokenCache for caching access tokens, which simplifies the end user's caching implementation compared to the old callback-based access token storage mechanism
  • Latest changes from all OpenAPI models
  • CONTRIBUTING.md to make it easier for others to get started making contributions
  • All autogenerated files have comments warning not to modify them directly
  • Some basic tests! What a concept 🙃

Fixed

  • Infinite recursion bug on FBA Inbound V2024-03-20 API accessor method
  • Boolean query parameters are serialized as 'true' or 'false' instead of 1 or 0
  • Null attributes are removed before serialization

Thanks @dpash, @KhorneHoly, and @bgarret for your contributions!

Full Changelog: v6.0.6...v7.0.0

v6.0.6

05 Jun 23:26
Compare
Choose a tag to compare

Fixed

  • DateTime deserialization (#699, thanks @mickas! fixes #698)
  • Add attributes to AutomatedShippingSettings that are missing from upstream models
  • Deserialization of integer 0 was buggy, since I used 0x0 as a default case in a deserialization match. Switched to using chr(0) so that 0 can be deserialized properly.

Changed

  • Move composer/semver and highsidelabs/saloon-sdk-generator from regular dependencies to dev dependencies. This involved moving a lot of base classes, traits, and exception classes from highsidelabs/saloon-sdk-generator into the library itself, which is reflected in the code generation process.
  • SDK is now compatible with Laravel 11

Added

  • FBA Inbound API 2024-03-20
  • Misc Orders VO API updates
  • getUserAgent() method in SellingPartnerApi class (partial fix for #679)

New Contributors

Full Changelog: v6.0.5...v6.0.6

v6.0.5

22 Apr 01:02
Compare
Choose a tag to compare

Fixed

  • Fix createFeed example in README (#677, @spire-mike)
  • Ensure restricted data tokens aren't generated for reports that don't require them (#682, fixed by #671)

--

Full Changelog: v6.0.4...v6.0.5

v6.0.4

04 Apr 19:42
Compare
Choose a tag to compare

Fixed

  • Generate query strings like a=val1,val2 instead a=val1&a=val2. Amazon often requires, and always accepts (as far as I can tell) comma-separated query string arrays, but often rejects the more standard format we were using before.
  • Look up cached access tokens and RDTs using refresh tokens as the key, not LWA client ID, because it's possible to have multiple refresh tokens for the same client ID.

Changed

  • Add JSON_UNESCAPED_SLASHES flag when outputting customized schema files in SchemaVersion

v6.0.3

27 Mar 20:19
Compare
Choose a tag to compare

Fixed

  • #668: the Address DTO for the Orders API incorrectly had the name field set as required, but if you call getOrders/getOrder without an RDT, it won't return a name with the address.

v6.0.2

26 Mar 21:48
Compare
Choose a tag to compare

Fixed

  • Moved composer/semver from require to require-dev in composer.json
  • Add illuminate/support to require in composer.json. It was installed with dev dependencies, which means that normal Composer installations weren't working properly.
  • Got optional commit flow in library:update-version working properly. Previously the changes that were supposed to be committed were lost in a stash.

v6.0.1

26 Mar 16:38
Compare
Choose a tag to compare

Fixed

  • crescat-io/saloon-sdk-generator was in composer.json instead of highsidelabs/saloon-sdk-generator, which led to missing files and incorrect dependencies. I've released highsidelabs/saloon-sdk-generator, and updated composer.json to reflect that.

v6.0.0

22 Mar 06:59
92365fc
Compare
Choose a tag to compare

Warning

This version of the library is only compatible with PHP >=8.1.

This major release is a complete overhaul of the library. There is basically no code left at all from v5.

A quick summary of the big changes:

  • The code generation process is now contained inside this repository, which should make it much easier for people to contribute. Previously, all code generation happened in a separate, private repository, because it was messy, and publishing the codegen setup in that state would have done more harm than good. Now, anyone can easily generate the code for the library from scratch.
  • The entire auth/request/response process is based on Saloon. The actual code generation uses highsidelabs/saloon-sdk-generator, which is a fork of crescat-io/saloon-sdk-generator.
  • The structure and naming conventions of the classes and attributes in this library have been made as similar to the names in Amazon's documentation as possible. As a result, I've removed the docs/ section entirely, because a) the old documentation was often incomplete and/or misleading, and b) once you have a basic grasp of how this library works now, Amazon's documentation will tell you everything you need to know.

All the functionality of v5 is still present: full API coverage, automatic RDT generation, document upload/download support. The syntax has changed somewhat, but the concepts are the same. It's now easier to access request and response internals, since all requests/responses have all the functionality of any other Saloon request or response.

Upgrade guide

  • The Configuration class has been replaced with the SellingPartnerApi class. This:

    $config = new SellingPartnerApi\Configuration([
        "lwaClientId" => "<LWA client ID>",
        "lwaClientSecret" => "<LWA client secret>",
        "lwaRefreshToken" => "<LWA refresh token>",
        "awsAccessKeyId" => "<AWS access key ID>",
        "awsSecretAccessKey" => "<AWS secret access key>",
        // If you're not working in the North American marketplace, change
        // this to another endpoint from lib/Endpoint.php
        "endpoint" => SellingPartnerApi\Endpoint::NA,
    ]);

    Now looks like this:

    $connector = SellingPartnerApi::make(
        clientId: 'amzn1.application-oa2-client.asdfqwertyuiop...',
        clientSecret: 'amzn1.oa2-cs.v1.1234567890asdfghjkl...',
        refreshToken: 'Atzr|IwEBIA...',
        endpoint: Endpoint::NA,  // Or Endpoint::EU, Endpoint::FE, Endpoint::NA_SANDBOX, etc.
    );
  • To access a particular API, rather than directly instantiating an API class, like this:

    $reportsApi = new ReportsV20210630Api($config);
    $dfOrdersApi = new VendorDirectFulfillmentOrdersV1Api($config);

    Do this:

    $reportsApi = $connector()->seller()->reports();
    $dfOrdersApi = $connector()->vendor()->directFulfillmentOrders();
  • To call an endpoint:

    $response = $reportsApi->getReports(
        reportTypes: ['GET_MERCHANT_ALL_LISTINGS'],
        marketplaceIds: ['ATVPDKIKX0DER'],
        createdAfter: new DateTime('2024-03-01'),
    );
    $json = $response->json();
    $reports = $response->dto();  // A structured DTO

    What was previously referred to as models are now called DTOs. DTOs are required to make POST/PUT/PATCH requests, similarly to how models were required for those sorts of create/update operations in v5. For an example of how to use a DTO to make a POST request, see the Working with DTOs section of the README.

  • To specify which data elements you want to retrieve when calling restricted endpoints (getOrder, getOrders, and getOrderItems), pass an additional dataElements parameter to SellingPartnerApi::make() rather than passing the $data_elements parameter to the restricted endpoint itself.

Any other questions about upgrading should be answerable using the README, but if you have any questions, feel free to open a discussion :)