go1688

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: GPL-3.0 Imports: 14 Imported by: 5

README

1688.com电商采购API

详情参见1688电商采购API文档 Go Reference Go goreleaser GitHub go.mod Go version of a Go module GoReportCard GitHub license GitHub release

Usage

package main

import (
	"log"
  
	"github.com/bububa/go1688"
	"github.com/bububa/go1688/requests/alibaba/product"
)

const (
	AppKey           = "xxx"
	AppSecret        = "xxx"
	productId uint64 = 594279676823
)

func main() {
	client := go1688.NewClient(AppKey, AppSecret, nil)
	getProductInfo(client, productId)
}

func getProductInfo(client *go1688.Client, productId uint64) {
	req := &product.CpsMediaProductInfoRequest{
		OfferId: productId,
	}
	info, bizInfos, err := product.CpsMediaProductInfo(client, req, "")
	if err != nil {
		log.Fatalln(err)
		return
	}
  log.Printf("info: %+v, biz: %+v", info, bizInfos)
}

Documentation

Index

Constants

View Source
const (
	GATEWAY  = "http://gw.open.1688.com/openapi"
	PROTOCOL = "param2"
	VERSION  = "1"
)
View Source
const JSONTIME_FORMAT = "20060102150405.000Z0700"

Variables

This section is empty.

Functions

func GetBytesBuffer

func GetBytesBuffer() *bytes.Buffer

func GetStringsBuilder

func GetStringsBuilder() *strings.Builder

func JSONMarshal

func JSONMarshal(req interface{}) string

JSONMarshal encode json without html escape

func PutBytesBuffer

func PutBytesBuffer(buf *bytes.Buffer)

func PutStringsBuilder

func PutStringsBuilder(builder *strings.Builder)

Types

type BaseRequest

type BaseRequest struct {
	// contains filtered or unexported fields
}

func NewBaseRequest

func NewBaseRequest(namespace string, name string) BaseRequest

func (*BaseRequest) Name

func (r *BaseRequest) Name() string

func (*BaseRequest) Namespace

func (r *BaseRequest) Namespace() string

func (*BaseRequest) Path

func (r *BaseRequest) Path() string

func (*BaseRequest) SetVersion

func (r *BaseRequest) SetVersion(version string)

func (*BaseRequest) Version

func (r *BaseRequest) Version() string

type BaseResponse

type BaseResponse struct {
	ErrorCode       string `json:"error_code,omitempty"`
	ErrorMessage    string `json:"error_message,omitempty"`
	RequestId       string `json:"request_id,omitempty"`
	Success         Bool   `json:"success,omitempty"`
	InnerErrorCode  string `json:"errorCode,omitempty"`
	InnerErrorMsg   string `json:"errorMsg,omitempty"`
	ErrorInfo       string `json:"errorInfo,omitempty"`
	ExtErrorMessage string `json:"extErrorMessage,omitempty"`
}

func (BaseResponse) Error

func (r BaseResponse) Error() string

func (BaseResponse) IsError

func (r BaseResponse) IsError() bool

type Bool added in v1.0.5

type Bool bool

Bool support string or bool for umarshal json

func (Bool) Bool added in v1.0.5

func (b Bool) Bool() bool

func (*Bool) UnmarshalJSON added in v1.0.5

func (b *Bool) UnmarshalJSON(s []byte) (err error)

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client api client

func NewClient

func NewClient(appKey string, secret string, httpClient *http.Client) *Client

NewClient create a new Client instance

func (*Client) Do

func (c *Client) Do(req Request, accessToken string, resp Response) error

Do execute api request

func (*Client) Sign

func (c *Client) Sign(path string, params map[string]string) string

Sign sign api request

func (*Client) Upload added in v1.0.4

func (c *Client) Upload(req UploadRequest, accessToken string, resp Response) error

Do execute api request

type FinalRequest

type FinalRequest struct {
	BaseRequest
	// contains filtered or unexported fields
}

func NewRequest

func NewRequest(namespace string, data RequestData) *FinalRequest

func (*FinalRequest) Params

func (r *FinalRequest) Params() map[string]string

type FinalUploadRequest added in v1.0.4

type FinalUploadRequest struct {
	BaseRequest
	// contains filtered or unexported fields
}

func NewUploadRequest added in v1.0.4

func NewUploadRequest(namespace string, data UploadRequestData) *FinalUploadRequest

func (*FinalUploadRequest) Files added in v1.0.4

func (r *FinalUploadRequest) Files() map[string]io.Reader

func (*FinalUploadRequest) Params added in v1.0.4

func (r *FinalUploadRequest) Params() map[string]string

type JsonTime

type JsonTime time.Time

func (JsonTime) Format

func (t JsonTime) Format() string

func (JsonTime) IsZero

func (t JsonTime) IsZero() bool

func (JsonTime) MarshalJSON

func (t JsonTime) MarshalJSON() ([]byte, error)

func (JsonTime) String

func (t JsonTime) String() string

func (JsonTime) Time

func (t JsonTime) Time() time.Time

func (*JsonTime) UnmarshalJSON

func (t *JsonTime) UnmarshalJSON(s []byte) (err error)

type Request

type Request interface {
	Namespace() string
	Name() string
	Version() string
	Path() string
	Params() map[string]string
}

type RequestData

type RequestData interface {
	Name() string
	Map() map[string]string
}

type Response

type Response interface {
	Error() string
	IsError() bool
}

type UploadRequest added in v1.0.4

type UploadRequest interface {
	Request
	Files() map[string]io.Reader
}

type UploadRequestData added in v1.0.4

type UploadRequestData interface {
	RequestData
	Files() map[string]io.Reader
}

Directories

Path Synopsis
internal
Package message 订阅消息相关
Package message 订阅消息相关
requests
alibaba/logistics
Package logistics 物流相关API
Package logistics 物流相关API
alibaba/p4p
Package p4p 营销活动相关API
Package p4p 营销活动相关API
alibaba/product
Package product 商品相关API
Package product 商品相关API
alibaba/trade
Package trade 交易相关API
Package trade 交易相关API

Jump to

Keyboard shortcuts

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