topsdk

package module
v0.0.0-...-bde22ba Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2018 License: GPL-3.0 Imports: 17 Imported by: 0

README

topsdkgo

taobao api sdk for golang

Documentation

Index

Constants

View Source
const (
	QimenErpTransfer = iota
	QimenErpCheck
	QimenCpNotify
	QimenCpOut
)
View Source
const (
	UnknownSign = iota
	Md5Sign
	HmacSign
)
View Source
const (
	UnknownResponse = iota
	JsonResponse
	XmlResponse
)
View Source
const UriBatch string = "http://gw.api.taobao.com/router/batch"
View Source
const UriDefault string = "http://gw.api.taobao.com/router/rest"

gateway, some method must be called through https

View Source
const UriHttpsDefault string = "https://eco.taobao.com/router/rest"
View Source
const UriSandbox string = "http://mockgw.hz.taeapp.com/gw"

Variables

This section is empty.

Functions

func BuildParams

func BuildParams(appkey, secret, AccessToken, method string, payload []byte, params IParameterMap,
	respFmt ResponseFormat) string

func GetTimestamp

func GetTimestamp() string

func HttpGet

func HttpGet(url string) (body string, err error)

func HttpPost

func HttpPost(url, contentType, data string) (body string, err error)

func MethodName

func MethodName(request interface{}) string

func MissingAppKey

func MissingAppKey(formt ResponseFormat) string

func MissingMethod

func MissingMethod(format ResponseFormat) string

func QimenEventName

func QimenEventName(status QimenEventStatus) (name string)

func Sign

func Sign(form IParameterMap, secret string, payload []byte) string

func SignHmac

func SignHmac(params Parameters, secret string, payload []byte) string

func SignMd5

func SignMd5(params Parameters, secret string, payload []byte) string

func Value2Str

func Value2Str(v *reflect.Value) (ans string)

func ValueIsEmpty

func ValueIsEmpty(v *reflect.Value) (ans bool)

Types

type App

type App struct {
	Key, Secret, RandomNum string
}

top app parameters

type Client

type Client struct {
	App
	UriNormal, UriBatch string
}

func (*Client) CallMethod

func (self *Client) CallMethod(uri, AccessToken, method string, paramsMap IParameterMap,
	respFmt ResponseFormat) (body string, err error)

func (*Client) CallMethodEx

func (self *Client) CallMethodEx(uri, method string, ssn *Session, params IParameterMap,
	respFmt ResponseFormat) (body string, err error)

func (*Client) DoBatch

func (self *Client) DoBatch(uri, AccessToken string, requests []IParameterMap,
	respFmt ResponseFormat) (body string, err error)

func (*Client) DoBatchEx

func (self *Client) DoBatchEx(uri, AccessToken string, requests []interface{},
	respFmt ResponseFormat) (body string, err error)

func (*Client) DoRequest

func (self *Client) DoRequest(uri, AccessToken string, request interface{},
	respFmt ResponseFormat) (body string, err error)

func (*Client) QimenEventsProduce

func (self *Client) QimenEventsProduce(uri, AccessToken string, events QimenEvents) (err error)

type ErrorResponse

type ErrorResponse struct {
	ErrorResponseObject `json:"error_response"`
}

type ErrorResponseObject

type ErrorResponseObject struct {
	Code      int    `json:"code"`
	Msg       string `json:"msg"`
	SubCode   string `json:"sub_code"`
	SubMsg    string `json:"sub_msg"`
	RequestId string `json:"request_id"`
}

type FormValues

type FormValues map[string][]string

func (FormValues) Get

func (self FormValues) Get(name string) (value string, exists bool)

func (FormValues) Len

func (self FormValues) Len() int

func (FormValues) Names

func (self FormValues) Names() []string

func (FormValues) Set

func (self FormValues) Set(name, value string)

type IParameterMap

type IParameterMap interface {
	Len() int
	Names() []string
	Get(name string) (string, bool)
	Set(name, value string)
}

type LogisticsDummySendRequest

type LogisticsDummySendRequest struct {
	Request
	Tid      uint64 `json:"tid,omitempty"`
	Feature  string `json:"feature,omitempty"`
	SellerIp string `json:"seller_ip,omitempty"`
}

type LogisticsDummySendResponse

type LogisticsDummySendResponse struct {
	LogisticsDummySendResponseRoot `json:"logistics_dummy_send_response"`
}

type LogisticsDummySendResponseRoot

type LogisticsDummySendResponseRoot struct {
	Shipping `json:"shipping"`
}

type NewSession

type NewSession struct {
	R1ExpiresIn  int    `json:"r1_expires_in,string"`
	W1ExpiresIn  int    `json:"w1_expires_in,string"`
	R2ExpiresIn  int    `json:"r2_expires_in,string"`
	W2ExpiresIn  int    `json:"w2_expires_in,string"`
	ExpiresIn    int    `json:"expires_in,string"`
	ReExpiresIn  int    `json:"re_expires_in,string"`
	RefreshToken string `json:"refresh_token"`
	AccessToken  string `json:"top_session"`
	Sign         string `json:"sign"`
	ErrCode      int    `json:"error,string"`
	ErrDesc      string `json:"error_description"`
}

func RefreshSession

func RefreshSession(appkey, secret, AccessToken, RefreshToken string) (ans NewSession, err error)

type Order

type Order struct {
	BuyerRate    bool   `json:"buyer_rate"`
	SellerRate   bool   `json:"seller_rate"`
	Cid          uint64 `json:"cid"`
	Num          uint   `json:"num"`
	NumIid       uint64 `json:"num_iid"`
	Oid          uint64 `json:"oid"`
	OuterIid     string `json:"outer_iid"`
	Payment      string `json:"payment"`
	Price        string `json:"price"`
	RefundStatus string `json:"refund_status"`
	Status       string `json:"status"`
	Title        string `json:"title"`
	TotalFee     string `json:"total_fee"`
}

type Orders

type Orders struct {
	Order []Order `json:"order"`
}

type Parameter

type Parameter struct {
	Key, Value string
}

type ParameterMap

type ParameterMap map[string]string

func NewParameterMap

func NewParameterMap(capacity int) ParameterMap

func Struct2Map

func Struct2Map(obj interface{}) (ans ParameterMap)

func (ParameterMap) Get

func (self ParameterMap) Get(name string) (value string, exists bool)

func (ParameterMap) Len

func (self ParameterMap) Len() int

func (ParameterMap) Names

func (self ParameterMap) Names() []string

func (ParameterMap) Set

func (self ParameterMap) Set(name, value string)

type Parameters

type Parameters []Parameter

func (Parameters) Len

func (self Parameters) Len() int

func (Parameters) Less

func (self Parameters) Less(i, j int) bool

func (Parameters) Swap

func (self Parameters) Swap(i, j int)

type QimenEvent

type QimenEvent struct {
	Event QimenEventProduceRequest `json:"event"`
}

type QimenEventProduceRequest

type QimenEventProduceRequest struct {
	Status   string `json:"status,omitempty"`
	Tid      uint64 `json:"tid,omitempty"`
	Ext      string `json:"ext,omitempty"`
	Platform string `json:"platform,omitempty"`
	Create   string `json:"create,omitempty"`
	Nick     string `json:"nick,omitempty"`
}

type QimenEventProduceResponse

type QimenEventProduceResponse struct {
	QimenEventProduceResponseRoot `json:"qimen_event_produce_response"`
}

type QimenEventProduceResponseRoot

type QimenEventProduceResponseRoot struct {
	IsSuccess bool `json:"is_success,omitempty,string"`
}

type QimenEventStatus

type QimenEventStatus int

type QimenEvents

type QimenEvents []QimenEvent

type QimenEventsProduceResponse

type QimenEventsProduceResponse struct {
	QimenEventsProduceResponseRoot `json:"qimen_events_produce_response"`
}

type QimenEventsProduceResponseRoot

type QimenEventsProduceResponseRoot struct {
	IsAllSuccess bool         `json:"is_all_success,omitempty,string"`
	Results      QimenResults `json:"results,omitempty"`
}

type QimenResult

type QimenResult struct {
	IsSuccess    bool   `json:"is_success,omitempty,string"`
	ErrorCode    string `json:"error_code,omitempty"`
	ErrorMessage string `json:"error_message,omitempty"`
}

type QimenResults

type QimenResults struct {
	QimenResult []QimenResult `json:"qimen_result,omitempty"`
}

type Request

type Request struct {
	//Timestamp string `json:"timestamp"`
	//Sign string `json:"sign"`
	//AppKey       string `json:"app_key"`
	Method       string
	TargetAppKey string `json:"target_app_key"`
	SignMethod   string `json:"sign_method"`
	AccessToken  string `json:"session"`
	Format       string `json:"format"`
	Version      string `json:"v"`
	PartnerId    string `json:"partner_id"`
	Simplify     bool   `json:"simplify"`
}

type ResponseFormat

type ResponseFormat int

response content-type, optional xml or json

func ResponseFormatFromName

func ResponseFormatFromName(name string) ResponseFormat

type Session

type Session struct {
	AccessToken, RefreshToken string
	ExpireAt, ReExpireAt      time.Time
}

type Shipping

type Shipping struct {
	IsSuccess bool `json:"is_success,omitempty"`
}

type SignMethod

type SignMethod int

sign method, optional md5 or hmac

func SignMethodFromName

func SignMethodFromName(name string) SignMethod

type Trade

type Trade struct {
	Tid              uint64 `json:"tid"`
	SellerNick       string `json:"seller_nick"`
	BuyerNick        string `json:"buyer_nick"`
	Created          string `json:"created"`
	HasBuyerMessage  bool   `json:"has_buyer_message"`
	Orders           Orders `json:"orders"`
	PayTime          string `json:"pay_time"`
	ReceiverAddress  string `json:"receiver_address"`
	ReceiverCity     string `json:"receiver_city"`
	ReceiverDistrict string `json:"receiver_district"`
	ReceiverMobile   string `json:"receiver_mobile"`
	ReceiverName     string `json:"receiver_name"`
	ReceiverState    string `json:"receiver_state"`
	ReceiverZip      string `json:"receiver_zip"`
	SellerFlag       int    `json:"seller_flag"`
	TotalFee         string `json:"total_fee"`
	Type             string `json:"type"`
}

type TradeFullinfoGetResponse

type TradeFullinfoGetResponse struct {
	TradeFullinfoGetResponseRoot `json:"trade_fullinfo_get_response"`
}

type TradeFullinfoGetResponseRoot

type TradeFullinfoGetResponseRoot struct {
	Trade `json:"trade"`
}

type Trades

type Trades struct {
	Trade []Trade `json:"trade"`
}

type TradesSoldGetRequest

type TradesSoldGetRequest struct {
	Request
	Fields       string `json:"fields,omitempty"`
	StartCreated string `json:"start_created,omitempty"`
	EndCreated   string `json:"end_created,omitempty"`
	Status       string `json:"status,omitempty"`
	BuyerNick    string `json:"buyer_nick,omitempty"`
	Type         string `json:"type,omitempty"`
	ExtType      string `json:"ext_type,omitempty"`
	RateStatus   string `json:"rate_status,omitempty"`
	Tag          string `json:"tag,omitempty"`
	PageNo       int    `json:"page_no,omitempty"`
	PageSize     int    `json:"page_size,omitempty"`
	UseHasNext   bool   `json:"use_has_next,omitempty"`
}

type TradesSoldGetResponse

type TradesSoldGetResponse struct {
	TradesSoldGetResponseRoot `json:"trades_sold_get_response"`
}

type TradesSoldGetResponseRoot

type TradesSoldGetResponseRoot struct {
	TotalResults int    `json:"total_results"`
	Trades       Trades `json:"trades"`
}

type UserSellerGetRequest

type UserSellerGetRequest struct {
	Fields string `json:"fields"`
}

Directories

Path Synopsis
demo

Jump to

Keyboard shortcuts

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