Categorygithub.com/hiscaler/51tracking-go
modulepackage
0.0.0-20220729060557-48dfd08aa603
Repository: https://github.com/hiscaler/51tracking-go.git
Documentation: pkg.go.dev

# README

51Tracking SDK

文档地址

https://www.51tracking.com/v3/api-index?language=Golang#api-version

数据更新频率

正常

  • 添加 30 天内未签收的属于正常更新频次也就是下限是 4 小时上限是 6 小时;
  • 30~45 天仍未签收就会降低更新频率至下限 6 小时上限 8 小时;
  • 45~60 天仍未签收更新频率变为下限 12 小时上限 14 小时;
  • 60~80 天仍未签收更新频率变为下限 24 小时上限 26 小时;
  • 超过 80 天仍未签收将停止更新。

其他

  • 快递更新间隔正常时间是 4~6 个小时;
  • 邮政更新间隔是 6~8 个小时;
  • sfb2c 更新间隔为 8 小时。

手动更新条件

  1. 查询不到超过 15 天,已经停止更新了的单号;
  2. 已经签收,并且已经停止更新了的单号;
  3. 添加时间超过 30 天,已经停止更新的单号;
  4. 其他条件暂时无法通过该接口更新。

安装

go get github.com/hiscaler/51tracking-go

使用

client := NewTracking51(config.Config{
    Debug:        true,
    Sandbox:      true,
    AppKey:       "xxx",
    IntervalTime: 1500,
})

配置说明

type Config struct {
	Debug        bool   // 是否为调试模式(调试模式下会输出 HTTP 请求和返回数据)
	Sandbox      bool   // 是否为沙箱测试环境
	Version      string // API 版本(当前固定为 V3)
	AppKey       string // App Key
	IntervalTime int64  // 当前请求与上次请求间隔的时间(单位为毫秒),默认为零,表示没有间隔,大于 0 表示实际间隔的毫秒数
}

服务

Account

  • 帐号情况
client.Services.Account.Profile()

Courier

  • 获取物流商列表
client.Services.Courier.List()
  • 修改包裹物流商
client.Services.Courier.Change("trackingNumber", "oldCourierCode", "newCourierCode")

Tracking

  • 添加物流单号
client.Services.Tracking.Create()
  • 修改单号信息
client.Services.Tracking.Update()
  • 获取查询结果
params := TracksQueryParams{}
client.Services.Tracking.Query(params)
  • 删除查询单号
client.Services.Tracking.Delete([]DeleteTrackRequest{})
  • 停止单号更新
client.Services.Tracking.StopUpdate(StopUpdateRequests{})
  • 手动更新
client.Services.Tracking.Refresh([]RefreshRequest{})
  • 统计包裹状态
client.Services.Tracking.StatusStatistic(StatusStatisticRequest{})
  • 时效
client.Services.Tracking.TransitTime(TransitTimeRequest{})
  • 检测偏远地区
client.Services.Tracking.RemoteDetection(RemoteDetectionRequest{})

Webhook

针对 51Tracking 的数据推送,提供了 WebhookRequest 结构体,您可以使用他来接受推送过来的数据,并判断 Code 是否为 200 且 Data.Valid() 是否有效来进行下一步的业务逻辑处理。

Data.Valid(you51TrackingAccountEmail) 用来判断推送的数据是否来自 51Tracking,根据需要,您可以跳过此步。

var wr WebRequest
if json.Unmarshal(resp.Body, &wr) != nil {
	if wr.Code == 200 && wr.Data.Valid(you51TrackingAccountEmail) {
	    // you code	
    }
}

# Packages

No description provided by the author

# Functions

ErrorWrap 错误包装.
No description provided by the author

# Constants

请求类型错误.
No description provided by the author
物流商简码无法识别或者不支持该物流商.
No description provided by the author
系统错误.
缺少请求参数或者请求参数无法解析.
请求成功,但未获取到数据,可能是该单号、所查询目标数据不存在.
请求的资源不存在.
部分必填参数为空.
API 服务只提供给付费账户,请付费购买单号以解锁 API 服务.
请求参数数量超过限制.
请求参数格式不合要求.
请求参数长度超过限制.
成功签收.
可能异常.
运输过久.
待上网.
查询不到.
查询中.
到达待取.
运输中.
投递失败.
无错误.
请求超时.
API 请求频率次数限制,请稍后再试.
跟踪单号已存在,无需再次创建.
跟踪单号不存在.
授权失败或没有权限,请检查并确保你 API Key 正确无误.
No description provided by the author

# Structs

No description provided by the author
Courier https://www.51tracking.com/v3/api-index?language=Golang#%E7%89%A9%E6%B5%81%E5%95%86%E5%88%97%E8%A1%A8.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TrackInformation 详细物流信息.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author