vip_gosdk

package module
v0.0.0-...-5990a11 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: MIT Imports: 15 Imported by: 0

README

vip-sdk

唯品会开放平台Golang版本SDK

单元测试

鉴于安全原因, 不便暴露 appKey/secret 等信息. 所以在测试命令后提供了如下参数.

go test -v -args -appKey xxx -secret xxx -userNumber xxx

快速开始

import (
	"fmt"
	"github.com/lcr2000/vip-gosdk"
)

var Client *vip_gosdk.Client

func init()  {
	Client = vip_gosdk.NewClient("appKey", "secret", "userNumber")
}

func GetAddress() {
	res, err := Client.SelectAddress("")
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(res)
}

Documentation

Index

Constants

View Source
const (
	Format  = "JSON"
	Service = "com.vip.wpc.ospservice.vop.WpcVopOspService"
	Domain  = "https://gw.vipapis.com"
	Version = "1.0.0"
)

base

View Source
const (
	ApplyPaymentMethod     = "applyPayment"
	OrderCreateMethod      = "orderCreate"
	OrderCancelMethod      = "orderCancel"
	SelectAddressMethod    = "selectAddress"
	GetOrderInfoListMethod = "getOrderInfoList"
)

method

View Source
const (
	DefaultPage     = 1
	DefaultPageSize = 20
)

Default pagination parameters

Variables

View Source
var (
	// ErrInvalidOrderCreate invalid order create params
	ErrInvalidOrderCreate = errors.New("invalid order create params")
	// ErrOrderSnRequired order number required
	ErrOrderSnRequired = errors.New("order number required")
	// ErrOrderSnAndIpRequired order number or ip is empty
	ErrOrderSnOrIpEmpty = errors.New("order number or ip is empty")
)

Functions

func Hmac

func Hmac(key, data string) string

Generate hmac-md 5 encryption.

Types

type ApplyPaymentResp

type ApplyPaymentResp struct {
	BaseResp
	Result struct {
		ApplySuccess bool   `json:"applySuccess"`
		FailReason   string `json:"failReason"`
	} `json:"result"`
}

申请代扣

type ApplyPaymentResponse

type ApplyPaymentResponse struct {
	ApplyPaymentResp
}

func (*ApplyPaymentResponse) String

func (resp *ApplyPaymentResponse) String() string

type BaseResp

type BaseResp struct {
	ReturnCode    string `json:"returnCode"`
	ReturnMessage string `json:"returnMessage"`
}

type Client

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

The client saves some private required fields. Before executing the request, a new Client must be created.

func NewClient

func NewClient(appKey, secret, userNumber string) *Client

NewClient returns a new Client. appKey, secret, userNumber can not be empty.

func (*Client) Do

func (client *Client) Do(req Request, params map[string]interface{}, res Response) (err error)

General request.

type OrderCancelResp

type OrderCancelResp struct {
	BaseResp
	Result struct {
		Code int    `json:"code"`
		Msg  string `json:"msg"`
	} `json:"result"`
}

取消订单

type OrderCancelResponse

type OrderCancelResponse struct {
	OrderCancelResp
}

func (*OrderCancelResponse) String

func (resp *OrderCancelResponse) String() string

type OrderCreateReq

type OrderCreateReq struct {
	AreaId    string
	SizeInfo  string
	Address   string
	Consignee string
	Mobile    string
	ClientIp  string
	TraceId   string
}

type OrderCreateResp

type OrderCreateResp struct {
	BaseResp
	Result struct {
		Orders []struct {
			OrderSn string `json:"orderSn"`
		} `json:"orders"`
	} `json:"result"`
}

创建订单

type OrderCreateResponse

type OrderCreateResponse struct {
	OrderCreateResp
}

func (*OrderCreateResponse) String

func (resp *OrderCreateResponse) String() string

type OrderInfoListResp

type OrderInfoListResp struct {
	BaseResp
	Result []struct {
		ChildOrderSnList []struct {
			RealPayTotal string `json:"RealPayTotal"`
			ShippingFee  string `json:"ShippingFee"`
			Goods        []struct {
				GoodFullID string `json:"goodFullId"`
				Price      string `json:"price"`
				SizeID     string `json:"sizeId"`
				SizeNum    int64  `json:"sizeNum"`
			} `json:"goods"`
			OrderSn       string `json:"orderSn"`
			RefundStatus  int64  `json:"refundStatus"`
			StatusCode    int64  `json:"statusCode"`
			StatusName    string `json:"statusName"`
			TransportNo   string `json:"transportNo"`
			TransportName string `json:"transportName"`
		} `json:"childOrderSnList"`
		ParentOrderSn string `json:"parentOrderSn"`
	} `json:"result"`
}

订单状态信息

type OrderInfoListResponse

type OrderInfoListResponse struct {
	OrderInfoListResp
}

func (*OrderInfoListResponse) String

func (resp *OrderInfoListResponse) String() string

type Request

type Request interface {
	ApiMethod() string
	RequestMethod() string
}

The Request describes a request's method and request request type

type Response

type Response interface{}

The Request describes a request's return information

type SelectAddressRequest

type SelectAddressRequest struct{}

func (SelectAddressRequest) ApiMethod

func (a SelectAddressRequest) ApiMethod() string

func (SelectAddressRequest) RequestMethod

func (a SelectAddressRequest) RequestMethod() string

type SelectAddressResp

type SelectAddressResp struct {
	BaseResp
	Result struct {
		ChildList []struct {
			AreaCode string `json:"areaCode"`
			AreaName string `json:"areaName"`
		} `json:"childList"`
		Info struct {
			AreaCode string `json:"areaCode"`
			AreaName string `json:"areaName"`
		} `json:"info"`
	} `json:"result"`
}

查询地址库

type SelectAddressResponse

type SelectAddressResponse struct {
	SelectAddressResp
}

func (*SelectAddressResponse) String

func (resp *SelectAddressResponse) String() string

type VipApiEncrypt

type VipApiEncrypt struct {
	AppKey    string `json:"appKey"`
	Format    string `json:"format"`
	Method    string `json:"method"`
	Service   string `json:"service"`
	Timestamp string `json:"timestamp"`
	Version   string `json:"version"`
}

Signature encryption string.

Jump to

Keyboard shortcuts

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