kuaidi100

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: MIT Imports: 10 Imported by: 0

README

Golang

📦 Golang 快递100

godoc goproxy.cn goreportcard.com deps.dev

安装

go get -v -u go.dtapp.net/kuaidi100@v1.0.4

Documentation

Index

Constants

View Source
const (
	LogTable = "kuaidi100"
)
View Source
const (
	Version = "1.0.4"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client 实例

func NewClient

func NewClient(config *ClientConfig) (*Client, error)

NewClient 创建实例化

func (*Client) GetCustomer

func (c *Client) GetCustomer() string

func (*Client) GetKey

func (c *Client) GetKey() string

func (*Client) Poll

func (c *Client) Poll(ctx context.Context, notMustParams ...gorequest.Params) (*PollResult, error)

Poll 实时快递查询接口 https://api.kuaidi100.com/document/5f0ffb5ebc8da837cbd8aefc

func (*Client) PollQuery

func (c *Client) PollQuery(ctx context.Context, notMustParams ...gorequest.Params) (*PollQueryResult, error)

PollQuery 实时快递查询接口 https://api.kuaidi100.com/document/5f0ffb5ebc8da837cbd8aefc

func (*Client) SetAesCustomer added in v1.0.3

func (c *Client) SetAesCustomer(v string) *Client

func (*Client) SetClientIP added in v1.0.3

func (c *Client) SetClientIP(clientIP string) *Client

SetClientIP 配置

func (*Client) SetKey added in v1.0.3

func (c *Client) SetKey(v string) *Client

func (*Client) SetLogFun added in v1.0.3

func (c *Client) SetLogFun(logFun gorequest.LogFunc)

SetLogFun 设置日志记录函数

func (*Client) SetTrace added in v1.0.3

func (c *Client) SetTrace(trace bool)

SetTrace 设置OpenTelemetry链路追踪

func (*Client) TraceEndSpan added in v1.0.3

func (c *Client) TraceEndSpan()

TraceEndSpan 结束OpenTelemetry链路追踪状态

func (*Client) TraceGetSpanID added in v1.0.3

func (c *Client) TraceGetSpanID() (spanID string)

TraceGetSpanID 获取OpenTelemetry链路追踪SpanID

func (*Client) TraceGetTraceID added in v1.0.3

func (c *Client) TraceGetTraceID() (traceID string)

TraceGetTraceID 获取OpenTelemetry链路追踪TraceID

func (*Client) TraceRecordError added in v1.0.3

func (c *Client) TraceRecordError(err error, options ...trace.EventOption)

TraceRecordError 记录OpenTelemetry链路追踪错误

func (*Client) TraceSetAttributes added in v1.0.3

func (c *Client) TraceSetAttributes(kv ...attribute.KeyValue)

TraceSetAttributes 设置OpenTelemetry链路追踪属性

func (*Client) TraceSetStatus added in v1.0.3

func (c *Client) TraceSetStatus(code codes.Code, description string)

TraceSetStatus 设置OpenTelemetry链路追踪状态

func (*Client) TraceStartSpan added in v1.0.3

func (c *Client) TraceStartSpan(ctx context.Context, spanName string) context.Context

TraceStartSpan 开始OpenTelemetry链路追踪状态

type ClientConfig

type ClientConfig struct {
	Customer string // 授权码
	Key      string // 密钥
}

ClientConfig 实例配置

type PollQueryResponse

type PollQueryResponse struct {
	Message string `json:"message"` // 消息体,请忽略
	Nu      string `json:"nu"`      // 单号
	Ischeck string `json:"ischeck"` // 是否签收标记,0未签收,1已签收,请忽略,明细状态请参考state字段
	Com     string `json:"com"`     // 快递公司编码,一律用小写字母
	Status  string `json:"status"`  // 通讯状态,请忽略
	Data    []struct {
		Time       string `json:"time"`       // 时间,原始格式
		Context    string `json:"context"`    // 内容
		Ftime      string `json:"ftime"`      // 格式化后时间
		AreaCode   string `json:"areaCode"`   // 本数据元对应的行政区域的编码,实时查询接口中提交resultv2=1或者resultv2=4标记后才会出现
		AreaName   string `json:"areaName"`   // 本数据元对应的行政区域的名称,实时查询接口中提交resultv2=1或者resultv2=4标记后才会出现
		Status     string `json:"status"`     // 本数据元对应的物流状态名称或者高级状态名称,实时查询接口中提交resultv2=1或者resultv2=4标记后才会出现
		Location   string `json:"location"`   // 本数据元对应的快件当前地点,实时查询接口中提交resultv2=4标记后才会出现
		AreaCenter string `json:"areaCenter"` // 本数据元对应的行政区域经纬度,实时查询接口中提交resultv2=4标记后才会出现
		AreaPinYin string `json:"areaPinYin"` // 本数据元对应的行政区域拼音,实时查询接口中提交resultv2=4标记后才会出现
		StatusCode string `json:"statusCode"` // 本数据元对应的高级物流状态值,实时查询接口中提交resultv2=4标记后才会出现
	} `json:"data"` // 最新查询结果,数组,包含多项,全量,倒序(即时间最新的在最前),每项都是对象,对象包含字段请展开
	State     string `json:"state"`     // 快递单当前状态,默认为0在途,1揽收,2疑难,3签收,4退签,5派件,8清关,14拒签等10个基础物流状态,如需要返回高级物流状态,请参考 resultv2 传值
	Condition string `json:"condition"` // 快递单明细状态标记,暂未实现,请忽略
	RouteInfo struct {
		From struct {
			Number string `json:"number"`
			Name   string `json:"name"`
		} `json:"from"`
		Cur struct {
			Number string `json:"number"`
			Name   string `json:"name"`
		} `json:"cur"`
		To interface{} `json:"to"`
	} `json:"routeInfo"`
	IsLoop bool `json:"isLoop"`
}

type PollQueryResult

type PollQueryResult struct {
	Result PollQueryResponse  // 结果
	Body   []byte             // 内容
	Http   gorequest.Response // 请求
}

type PollResponse

type PollResponse struct {
	Result     bool   `json:"result"`
	ReturnCode string `json:"returnCode"`
	Message    string `json:"message"`
}

type PollResult

type PollResult struct {
	Result PollResponse       // 结果
	Body   []byte             // 内容
	Http   gorequest.Response // 请求
}

Jump to

Keyboard shortcuts

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