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

@gat-solutions/ecommerce

v1.1.3

Published

## Introduction Đây là một thư viện chứa các hàm để kết nối với service ecommerce của công ty GreenAgri

Downloads

63

Readme

E-commerce Integration

Introduction

Đây là một thư viện chứa các hàm để kết nối với service ecommerce của công ty GreenAgri

Installation

$ npm install @gat-solutions/ecommerce

Config environment

ECOMMERCE_SERVICE_URL=
ECOMMERCE_SERVICE_APP_CODE=
ECOMMERCE_SERVICE_APP_SECRET=

EcommerceService

Muốn kết nối được với service ecommerce của GreenAgri bạn cần phải có app-code và app-secret. Sau đó dùng hàm dưới đây để lấy access token.

...
    const { token } = await EcommerceService.generateToken();
...

Sau khi có được access token bạn cần khởi tạo EcommerceService:

...
    const ecommerceService = new EcommerceService(token);
...

GetPlatformAuthorizeUrl

Lấy đường dẫn đăng nhập của các sàn TMDT

...
    const payload = {
        platformType: PlatformType.TIKI
    };
    const { url } = await ecommerceService.getPlatformAuthorizeUrl(payload)
...

Đường dẫn trả về sẽ đưa bạn đến trang đăng nhập của sàn TMDT.

ConnectPlatform

Liên kết với một sàn TMDT

...
    const payload = {
        merchantId: "uuid"
        code: "something"
        platformType: PlatformType.TIKI
    };
    const data = await ecommerceService.connectPlatform(payload)
...
  • merchantId: Mã cửa hàng liên kết với sàn TMDT
  • code: đoạn mã trả về sau khi login thành công trên sàn

ConnectTikiInhouse

Liến kết với sàn Tiki thông qua app-inhouse (Only dev mode)

...
    const payload = {
        merchantId: "uuid"
    };
    const data = await ecommerceService.connectTikiInhouse(payload)
...
  • merchantId: Mã cửa hàng liên kết với sàn Tiki

GetAllLinkedShop

Lấy danh sách những cửa hàng đã liên kết

...
    const payload = {
        merchantId: "uuid",
        limit: 20,
        page: 1
    };
    const data = await ecommerceService.getAllLinkedShop(payload)
...

GetAllPlatformProducts

Lấy danh sách sản phẩm trên sàn TMDT

...
    const payload = {
        merchantId: "uuid",
        platformType: PlatformType.TIKI
        limit: 20,
        page: 1,
        name: "UCook"
    };
    const data = await ecommerceService.getAllPlatformProducts(payload)
...

LinkProduct

Liên kết sản phẩm trên cửa hàng với sản phẩm trên sàn TMDT

...
    const payload = {
        merchantId: "uuid",
        data: [
            {
                merchantProductId: "uuid",
                platformProductId: "uuid",
                platformType: PlatformType.TIKI
            }
        ]
    };
    const data = await ecommerceService.linkProduct(payload)
...
  • merchantProductId: Mã sản phẩm trên cửa hàng
  • platformProductId: Mã sản phẩm trên sàn

GetAllLinkedProducts

Lấy danh sách các sản phẩm đã liên kết

...
    const payload = {
        merchantId: "uuid",
        platformType: PlatformType.TIKI
        limit: 20,
        page: 1,
    };
    const data = await ecommerceService.getAllLinkedProducts(payload)
...

GraphQL

Schema

import { schema } from "@gat-solutions/ecommerce";

export default schema;

Resolver

import {
  GetAllLinkedProductArgs,
  GetAllPlatformProductArgs,
  GetAllLinkedPlatformArgs,
  LinkProductArgs,
  ConnectPlatformArgs,
  Mutation,
  Query,
  parseToResolver,
} from "@gat-solutions/ecommerce";

class EcommerceQuery implements Query {
  async getPlatformAuthorizeUrl(root: any, args: any, context: Context) {
    ...
  }
  async getAllLinkedPlatform(root: any, args: GetAllLinkedPlatformArgs, context: Context) {
    ...
  }
  async getAllPlatformProduct(root: any, args: GetAllPlatformProductArgs, context: Context) {
    ...
  }
  async getAllLinkedProduct(root: any, args: GetAllLinkedProductArgs, context: any) {
    ...
  }
}

class EcommerceMutation implements Mutation {
  async connectPlatform(root: any, args: ConnectPlatformArgs, context: Context) {
    ...
  }
  async connectTikiInhouse(root: any, args: any, context: Context) {
    ...
  }
  async linkProduct(root: any, args: LinkProductArgs, context: Context) {
    ...
  }
}

const ecommerceQuery = new EcommerceQuery();
const ecommerceMutation = new EcommerceMutation();

export default parseToResolver(ecommerceQuery, ecommerceMutation);