Skip to content

crazyfactory/amazon-selling-partner-api-fulfillment-inbound-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwaggerClient-php

The Selling Partner API for Fulfillment Inbound lets you create applications that create and update inbound shipments of inventory to Amazon's fulfillment network.

This PHP package is automatically generated by the Swagger Codegen project:

Requirements

PHP 5.5 and later

Installation & Usage

Composer

To install the bindings via Composer, add the following to composer.json:

{
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com//.git"
    }
  ],
  "require": {
    "/": "*@dev"
  }
}

Then run composer install

Manual Installation

Download the files and include autoload.php:

    require_once('/path/to/SwaggerClient-php/vendor/autoload.php');

Tests

To run the unit tests:

composer install
./vendor/bin/phpunit

Getting Started

Please follow the installation procedure and then run the following:

A method within aclass to get the API instance (via config DI) -- You need to upddate the config source as you wish. It will automatically handle your request and signing your request using https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html

/**
     * Get authenticated FBA Inbound API Instance using
     * credential from the configuration
     *
     * @return FbaInboundApi
     */
    public function getFbaInboundApiInstance(): FbaInboundApi
    {
        $tokenStorage = new FsTokenStorage($this->config->get('application')->get('cacheDir') . DS . '.aws-tokens');
        $stsAuthenticationConfiguration = new Configuration();
        $stsConfig = $this->config->get('aws')->get('sts');
        $lwaConfig = $this->config->get('amazon')->get('lwa');
        $spApiConfig = $this->config->get('amazon')->get('selling_partner_api');

        $stsAuthenticationConfiguration->setApiKey('refresh_token', $lwaConfig['refresh_token']);
        $stsAuthenticationConfiguration->setApiKey('client_id', $lwaConfig['client_id']);
        $stsAuthenticationConfiguration->setApiKey('client_secret', $lwaConfig['client_secret']);
        $stsAuthenticationConfiguration->setApiKey('access_key', $stsConfig['access_key']);
        $stsAuthenticationConfiguration->setApiKey('secret_key', $stsConfig['secret_key']);
        $stsAuthenticationConfiguration->setApiKey('role_arn', $stsConfig['role_arn']);
        $stsAuthenticationConfiguration->setDebug(false);

        $credential = new Credentials($tokenStorage, $stsAuthenticationConfiguration);
        // Cache and retrieve both LWA tokens and assumeRole via sts tokens
        $tokens = $credential->getCredentials();

        $config = Configuration::getDefaultConfiguration();
        $config->setAccessToken($tokens['lwa_access_token']);
        $config->setApiKey('accessKey', $tokens['sts_credentials']['access_key']);
        $config->setApiKey('secretKey', $tokens['sts_credentials']['secret_key']);
        $config->setApiKey('region', $spApiConfig['region']);
        $config->setApiKey('securityToken', $tokens['sts_credentials']['session_token']);
        $config->setDebug(false);
        $config->setHost($spApiConfig['host']);

        return new FbaInboundApi(
            new Client(),
            $config
        );
    }
<?php
require_once(__DIR__ . '/vendor/autoload.php');

$apiInstance =  ....... // Instantiate it from the above method getFbaInboundApiInstance

$shipment_id = "shipment_id_example"; // string | A shipment identifier originally returned by the createInboundShipmentPlan operation.
$need_by_date = new \DateTime("2013-10-20"); // \DateTime | Date that the shipment must arrive at the Amazon fulfillment center to avoid delivery promise breaks for pre-ordered items. Must be in YYYY-MM-DD format. The response to the getPreorderInfo operation returns this value.
$marketplace_id = "marketplace_id_example"; // string | A marketplace identifier. Specifies the marketplace the shipment is tied to.

try {
    $result = $apiInstance->confirmPreorder($shipment_id, $need_by_date, $marketplace_id);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling FbaInboundApi->confirmPreorder: ', $e->getMessage(), PHP_EOL;
}

?>

Documentation for API Endpoints

All URIs are relative to https://sellingpartnerapi-na.amazon.com

Class Method HTTP request Description
FbaInboundApi confirmPreorder PUT /fba/inbound/v0/shipments/{shipmentId}/preorder/confirm
FbaInboundApi confirmTransport POST /fba/inbound/v0/shipments/{shipmentId}/transport/confirm
FbaInboundApi createInboundShipment POST /fba/inbound/v0/shipments/{shipmentId}
FbaInboundApi createInboundShipmentPlan POST /fba/inbound/v0/plans
FbaInboundApi estimateTransport POST /fba/inbound/v0/shipments/{shipmentId}/transport/estimate
FbaInboundApi getBillOfLading GET /fba/inbound/v0/shipments/{shipmentId}/billOfLading
FbaInboundApi getInboundGuidance GET /fba/inbound/v0/itemsGuidance
FbaInboundApi getLabels GET /fba/inbound/v0/shipments/{shipmentId}/labels
FbaInboundApi getPreorderInfo GET /fba/inbound/v0/shipments/{shipmentId}/preorder
FbaInboundApi getPrepInstructions GET /fba/inbound/v0/prepInstructions
FbaInboundApi getShipmentItems GET /fba/inbound/v0/shipmentItems
FbaInboundApi getShipmentItemsByShipmentId GET /fba/inbound/v0/shipments/{shipmentId}/items
FbaInboundApi getShipments GET /fba/inbound/v0/shipments
FbaInboundApi getTransportDetails GET /fba/inbound/v0/shipments/{shipmentId}/transport
FbaInboundApi putTransportDetails PUT /fba/inbound/v0/shipments/{shipmentId}/transport
FbaInboundApi updateInboundShipment PUT /fba/inbound/v0/shipments/{shipmentId}
FbaInboundApi voidTransport POST /fba/inbound/v0/shipments/{shipmentId}/transport/void

Documentation For Models

Documentation For Authorization

All endpoints do not require authorization.

Author