// 增加分组 // NOTE: 无需指定 Id 字段 func (c *Client) MerchantGroupAdd(_group *group.GroupEx) (groupId int64, err error) { if _group == nil { err = errors.New("_group == nil") return } _group.Id = 0 // 无需指定 Id 字段 var request = struct { GroupDetail *group.GroupEx `json:"group_detail"` }{ GroupDetail: _group, } var result struct { Error GroupId int64 `json:"group_id"` } hasRetry := false RETRY: token, err := c.Token() if err != nil { return } _url := merchantGroupAddURL(token) if err = c.postJSON(_url, request, &result); err != nil { return } switch result.ErrCode { case errCodeOK: groupId = result.GroupId return case errCodeTimeout: if !hasRetry { hasRetry = true timeoutRetryWait() goto RETRY } fallthrough default: err = &result.Error return } }
// 增加分组 // NOTE: 无需指定 Id 字段 func (c *Client) MerchantGroupAdd(_group *group.GroupEx) (groupId int64, err error) { if _group == nil { err = errors.New("_group == nil") return } _group.Id = 0 token, err := c.Token() if err != nil { return } _url := merchantGroupAddURL(token) var request = struct { GroupDetail *group.GroupEx `json:"group_detail"` }{ GroupDetail: _group, } var result struct { Error GroupId int64 `json:"group_id"` } if err = c.postJSON(_url, request, &result); err != nil { return } if result.ErrCode != 0 { err = &result.Error return } groupId = result.GroupId return }