Giter VIP home page Giter VIP logo

sellercentersdk-php's Introduction

1) Requirements

PHP 5.5 and later.

Composer

You can install the sdk via Composer. Run the following command:

composer require rocket-labs/sellercenter-sdk-php dev-master

To use the sdk code, use Composer's autoload:

require_once('vendor/autoload.php');

2) Implemented methods

These methods can be accessed through RocketLabs\SellerCenterSdk\Endpoint\Endpoints class:

  • Order endpoint - Endpoints::order()
    • GetOrders
    • GetOrder
    • GetDocument
    • GetOrderItems
    • SetStatusToCanceled
    • SetStatusToPackedByMarketplace
    • SetStatusToReadyToShip

All another methods you can call with GenericRequest, for more information please look at this sample for GET-methods or this one for POST-methods.

3) Samples

To understand how to work with the SDK, please look at samples. To make the samples work, change the API settings in samples/config/config.php. You need to set up the SellerCenter URL (only https is supported), your login and API key.

API key can be found in your SellerCenter account under Settings > Manage Users. If a given user has no API key yet, generate it by clicking a corresponding link.

After this you can run any sample and see the real results requests.

Please note, that POST requests could affect on your real products, orders etc. Make sure that SKUs or Order IDs in samples are not intersect with data in your SellerCenter account.

3.1) Generic Samples

You can access every API Method by using the GenericRequest class and the core implementation.

see sample in action

cd samples
php ./genericGetter.php

3.1) Endpoints Samples

For the most important API endpoints the SDK provides facades for simple API usage. See endpoint samples here.

The following code describes the pattern how to use the endpoints implementation:

<?php
    use RocketLabs\SellerCenterSdk\Core\Client;
    use RocketLabs\SellerCenterSdk\Core\Configuration;
    use RocketLabs\SellerCenterSdk\Endpoint\Endpoints;

    // create client instance with your credetials
    $client = Client::create(new Configuration(SC_API_URL, SC_API_USER, SC_API_KEY));

    // get response for a certain api call with fluent interface:
    // Endpoints - name of endpoint - api method to call - call($client)
    $response = Endpoints::order()->getOrder(12)->call($client);

    // Or, for some complex methods, RequestBuilders can be used,
    // In such cases API command will have following structure:
    // Endpoints - name of endpoint - api method to call - some builder's setters - build - call($client)
    $response = Endpoints::order()->getOrders()->setSorting('created_at', 'ASC')->setLimit(12)->build()->call($client);

see a sample in action

open file of a sample. For example samples/endpoint/order/getOrder.php, and change the variable $orderId to contain order id of your seller. Then run it in the console:

php ./samples/endpoint/order/getOrder.php

sellercentersdk-php's People

Contributors

nicolopignarocket avatar rocket-internet-git avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.