npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

shipxanh-oalazada

v1.0.5

Published

Lazada Open Platform SDK for Node.js

Downloads

128

Readme

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 | :heavy_check_mark: | | getFailureReasons | :heavy_check_mark: | | getMultipleOrderItems | :heavy_check_mark: | | getOrder | :heavy_check_mark: | | getOrderItems | :heavy_check_mark: | | getOrders | :heavy_check_mark: | | setInvoiceNumber | :heavy_check_mark: | | setStatusToCanceled | :heavy_check_mark: | | setStatusToPackedByMarketplace | :heavy_check_mark: | | setStatusToReadyToShip | :heavy_check_mark: |


| Product | status | | --------------------- | ------------------ | | createProduct | :heavy_check_mark: | | getBrands | :heavy_check_mark: | | getCategoryAttributes | :heavy_check_mark: | | getCategoryTree | :heavy_check_mark: | | getProductItem | :heavy_check_mark: | | getProducts | :heavy_check_mark: | | getQcStatus | :no_entry_sign: | | getResponse | :heavy_check_mark: | | migrateImage | :heavy_check_mark: | | migrateImages | :heavy_check_mark: | | removeProduct | :heavy_check_mark: | | setImages | :heavy_check_mark: | | updatePriceQuantity | :heavy_check_mark: | | updateProduct | :heavy_check_mark: | | uploadImage | :no_entry_sign: |


| Media | status | | ------------------- | ------------------ | | initCreateVideo | :heavy_check_mark: | | uploadBlockVideo | :heavy_check_mark: | | completeCreateVideo | :heavy_check_mark: |


| Finance | status | | --------------------- | --------------- | | getPayoutStatus | :no_entry_sign: | | getTransactionDetails | :no_entry_sign: |


| Logistics | status | | -------------------- | ------------------ | | getShipmentProviders | :heavy_check_mark: |


| Seller | status | | ------------ | --------------- | | getSeller | :no_entry_sign: | | updateSeller | :no_entry_sign: | | updateUser | :no_entry_sign: |


| System | status | | ------------------- | ------------------ | | generateAccessToken | :heavy_check_mark: | | refreshAccessToken | :heavy_check_mark: |


| DataMoat | status | | ------------------- | --------------- | | dataMoatBatchLog | :no_entry_sign: | | dataMoatComputeRisk | :no_entry_sign: | | dataMoatLogin | :no_entry_sign: | | dataMoatOrder | :no_entry_sign: |

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