easycb

package module
v0.1.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2025 License: MIT Imports: 9 Imported by: 0

README

Easy Cross Border (EasyCb-Go)

Lazada/Tiktok/Shopee Seller Open Platform SDK For Golang

MIT license Go.Dev reference

Overview

EasyCb features are support platform:

  • Shopify
  • Amazon
  • AliExpress
  • ...

Getting Started

Prerequisites

EasyCb requires Go version 1.17 or above.

import "github.com/easycb/easycb-go"

Alternatively, use go get:

go get -u github.com/easycb/easycb-go
Running EasyCb

A basic example Lazada open api:

package main

import (
	"fmt"
	"time"
	"github.com/easycb/easycb-go"
	"github.com/easycb/easycb-go/lazada"
)

func main() {
	appKey := ""
	appSecret := ""
	baseUrl := "https://api.lazada.com.my/rest"
	accessToken := ""
	client, err := lazada.NewClient(appKey, appSecret, baseUrl)
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	client.SetAccessToken(accessToken)

	query := easycb.AnyMap{
		"sort_direction": "DESC",
		"offset":         0,
		"limit":          100,
		"sort_by":        "created_at",
		"created_before": time.Now().Format(time.RFC3339),
		"created_after":  time.Now().Add(-15 * 24 * time.Hour).Format(time.RFC3339),
	}

	res, err := client.GetOrders(query)
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	fmt.Println(res.Code)
}

A basic example Shopee open api:

package main

import (
	"fmt"
	"time"
	"github.com/easycb/easycb-go"
	"github.com/easycb/easycb-go/shopee"
)

func main() {
	partnerId := int64(123456)
	partnerKey := ""
	baseUrl := "https://partner.shopeemobile.com"
	shopId := int64(56789)
	accessToken := ""
	client, err := shopee.NewClient(partnerId, partnerKey, baseUrl)
	if err != nil {
		return
	}
	client.SetShopId(shopId).SetAccessToken(accessToken)
	
	
	query := easycb.AnyMap{
		"offset":      0,
		"page_size":   50,
		"item_status": []string{"NORMAL", "UNLIST"},
	}

	res, err := client.GetProductList(query)
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	fmt.Println(res.Message)
}

A basic example Tiktok shop partner api:

package main

import (
	"fmt"
	"time"
	"github.com/easycb/easycb-go"
	"github.com/easycb/easycb-go/tiktok"
)

func main() {
	appKey := ""
	appSecret := ""
	baseUrl := "https://open-api.tiktokglobalshop.com"
	accessToken := ""
	shopCipher := ""
	client, err := tiktok.NewClient(appKey, appSecret, baseUrl)
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	client.SetAccessToken(accessToken).SetShopCipher(shopCipher)

	query := easycb.AnyMap{
		"page_size": 20,
	}

	body := easycb.AnyMap{
		"create_time_ge": time.Now().Add(-15 * 24 * time.Hour).Unix(),
		"create_time_lt": time.Now().Unix(),
	}
	
	res, err := client.GetOrderList(query, body)
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	
	fmt.Println(res.Code)
}

Contributors

Thank you for contributing to the EasyCb SDK!

License

Released under the MIT License

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MissLazadaInitParamErr = errors.New("missing lazada init param")
	MissShopeeInitParamErr = errors.New("missing shopee init param")
	MissTiktokInitParamErr = errors.New("missing tiktok init param")
	MissParamErr           = errors.New("missing required parameter")
	MarshalErr             = errors.New("marshal error")
	UnmarshalErr           = errors.New("unmarshal error")
	SignatureErr           = errors.New("signature error")
	MissBaseUrlErr         = errors.New("missing base url")
)

Functions

func GenerateSHA256

func GenerateSHA256(input []byte, secret []byte) string

func InterfaceToString

func InterfaceToString(value interface{}) string

Types

type AnyMap

type AnyMap map[string]interface{}

func (AnyMap) GetInterface

func (am AnyMap) GetInterface(key string) interface{}

func (AnyMap) GetString

func (am AnyMap) GetString(key string) string

func (AnyMap) JsonBody

func (am AnyMap) JsonBody() (jb string)

func (AnyMap) Remove

func (am AnyMap) Remove(key string)

func (AnyMap) Reset

func (am AnyMap) Reset()

func (AnyMap) Set

func (am AnyMap) Set(key string, value interface{}) AnyMap

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL