zero-to-prod/spapi-rdt

Create Restricted Data Tokens for Amazons Selling Partner API (SPAPI).

v4.0.0 2025-02-09 00:00 UTC

README

Repo GitHub Actions Workflow Status GitHub Actions Workflow Status Packagist Downloads php Packagist Version License wakatime Hits-of-Code

Contents

Introduction

Create Restricted Data Tokens for Amazons Selling Partner API (SPAPI).

Requirements

  • PHP 7.1 or higher.

Installation

Install Zerotoprod\SpapiRdt via Composer:

composer require zero-to-prod/spapi-rdt

This will add the package to your project’s dependencies and create an autoloader entry for it.

Usage

Orders

Access the different endpoints for getting Restricted Data Tokens for the Orders API

use Zerotoprod\SpapiRdt\SpapiRdt;

$response = SpapiRdt::from('access_token', 'targetApplication')
    ->orders()
    ->getOrders('123-1234567-1234567');

$restrictedDataToken = $response['response']['restrictedDataToken']

Testing

You can test the api by faking the response:

use Zerotoprod\SpapiRdt\SpapiRdt;
use Zerotoprod\SpapiRdt\Support\Testing\SpapiRdtFake;
use Zerotoprod\SpapiRdt\Support\Testing\SpapiRdtResponseFactory;

SpapiRdtFake::fake(
    SpapiRdtResponseFactory::factory()->make()
);

$response = SpapiRdt::from('access_token', 'targetApplication')
    ->orders()
    ->getOrders();

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page if you want to contribute.

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Commit changes (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature-branch).
  5. Create a new Pull Request.