forked from chanxuehong/wechat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
applyid.go
39 lines (32 loc) · 1.59 KB
/
applyid.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package device
import (
"github.com/masiqi/wechat.v2/mp/core"
)
type ApplyIdParameters struct {
Quantity int `json:"quantity"` // 必须, 申请的设备ID的数量,单次新增设备超过500个,需走人工审核流程
ApplyReason string `json:"apply_reason"` // 必须, 申请理由,不超过100个字
Comment string `json:"comment,omitempty"` // 可选, 备注,不超过15个汉字或30个英文字母
PoiId *int64 `json:"poi_id,omitempty"` // 可选, 设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。
}
type ApplyIdResult struct {
ApplyId int64 `json:"apply_id"` // 申请的批次ID,可用在“查询设备列表”接口按批次查询本次申请成功的设备ID。
AuditStatus int `json:"audit_status"` // 审核状态。0:审核未通过、1:审核中、2:审核已通过;若单次申请的设备ID数量小于等于500个,系统会进行快速审核;若单次申请的设备ID数量大于500个,会在三个工作日内完成审核
AuditComment string `json:"audit_comment"` // 审核备注,包括审核不通过的原因
}
// 申请设备ID
func ApplyId(clt *core.Client, para *ApplyIdParameters) (rslt *ApplyIdResult, err error) {
var result struct {
core.Error
ApplyIdResult `json:"data"`
}
incompleteURL := "https://api.weixin.qq.com/shakearound/device/applyid?access_token="
if err = clt.PostJSON(incompleteURL, para, &result); err != nil {
return
}
if result.ErrCode != core.ErrCodeOK {
err = &result.Error
return
}
rslt = &result.ApplyIdResult
return
}