Giter Club home page Giter Club logo

lazada-open-platform-sdk's Introduction

Nodejs wrapper for Lazada Open Platform API

Build Status

| ! WIP project

Usage

  1. Install sdk

    [~/project/dir] $ npm install lazada-open-platform-sdk
  2. Require LazadaAPI class

    import LazadaAPI from 'lazada-open-platform-sdk'
    // OR
    const LazadaAPI = require('lazada-open-platform-sdk')
  3. Instantiate a LazadaAPI Object

    /**
     * LazadaAPI class constructor
     * @param {string} appKey
     * @param {string} appSecret
     * @param {Venture} countryCode @ref: 'src/LazadaClient/constants.js'
     * countryCode should be one of the following
     * | 'SINGAPORE'
     * | 'THAILAND'
     * | 'MALAYSIA'
     * | 'VIETNAM'
     * | 'PHILIPPINES'
     * | 'INDONESIA'
     * @param {string?} accessToken require for some API
     */
    const aLazadaAPI = new LazadaAPI(appKey, appSecret, 'SINGAPORE')
    // OR
    const accessToken = 'some_access_token'
    const aLazadaAPIWithToken = new LazadaAPI(appKey, appSecret, 'SINGAPORE', accessToken)
  4. Call API action with proper parameters

    // all API action return promise
    aLazadaAPI
      .generateAccessToken({ code: 'auth_code' })
      .then(response => {
        const { access_token } = response // JSON data from Lazada's API
      })
    // for API action that require authorization, you must set the accessToken first
    aLazadaAPI.accessToken = 'some_access_token'
    aLazadaAPI
      .getShipmentProviders()
      .then(response => {
        // JSON data from Lazada's API
      })
  5. For available API actions, check the support table. For proper API request parameters, check Lazada's offcial documentation and source code located in src/LazadaClient/<namespace>

API Support

Order status
getDocument ✔️
getFailureReasons ✔️
getMultipleOrderItems ✔️
getOrder ✔️
getOrderItems ✔️
getOrders ✔️
setInvoiceNumber ✔️
setStatusToCanceled ✔️
setStatusToPackedByMarketplace ✔️
setStatusToReadyToShip ✔️

Product status
createProduct ✔️
getBrands ✔️
getCategoryAttributes ✔️
getCategoryTree ✔️
getProducts ✔️
getQcStatus 🚫
getResponse 🚫
migrateImage ✔️
migrateImages 🚫
removeProduct ✔️
setImages ✔️
updatePriceQuantity ✔️
updateProduct ✔️
uploadImage 🚫

Finance status
getPayoutStatus 🚫
getTransactionDetails 🚫

Logistics status
getShipmentProviders ✔️

Seller status
getSeller 🚫
updateSeller 🚫
updateUser 🚫

System status
generateAccessToken ✔️
refreshAccessToken ✔️

DataMoat status
dataMoatBatchLog 🚫
dataMoatComputeRisk 🚫
dataMoatLogin 🚫
dataMoatOrder 🚫

Development

Tools

  • node - runtime
  • babel - js transpiler
  • flow - type checker
  • jest - test runner
  • eslint - linter
  • vscode - recommended text editor

Convention

  1. sdk variables: camelCase
  2. api variables: snake_case or PascalCase

File structure

src/
├── LazadaAPI           // LazadaAPI: top level controller class
│   └── index.js        
├── LazadaClient        // LazadaClient: namespace seperated API actions
│   ├── index.js
│   ├── logistics.js
│   ├── order.js
│   ├── product.js
│   └── system.js
├── LazadaRequest       // LazadaRequest: responsible for network request
│   ├── index.js
│   └── signature       // logic for signing API request
│       └── index.js
├── __tests__           // all tests located here
└── index.js            // a.k.a. main.c

Design

const APIRequest = {
  appKey:      ":require",
  appSecret:   ":require",
  baseURL:     ":require" // Protocol (default: https) + Gateway (location specific)
  HttpAction:  "GET OR POST",  // API specific
  apiPath:     "action/path",  // API specific
  accessToken: ":optional",    // API specific
  payload: {}   // API specific
};

Reference

Lazada API Doc

https://open.lazada.com/doc/api.htm

lazada-open-platform-sdk's People

Contributors

conradlo 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.