-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi_extend_a_subscription_renewal_date.go
57 lines (52 loc) · 2.09 KB
/
api_extend_a_subscription_renewal_date.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package appstoreserverapi
import (
"bytes"
"encoding/json"
"net/http"
)
// ApiExtendAsubscriptionRenewalDate 延长订阅续订日期
// Extend a Subscription Renewal Date
// doc: https://developer.apple.com/documentation/appstoreserverapi/extend_a_subscription_renewal_date
func (c *client) ApiExtendAsubscriptionRenewalDate(transactionId string, req ExtendRenewalDateRequest) (*ExtendRenewalDateResponse, error) {
reqUrl := c.apiExtendASubscriptionRenewalDateUrl + transactionId
b, _ := json.Marshal(req)
r, err := c.doRequest(http.MethodPut, reqUrl, bytes.NewReader(b))
if err != nil {
return nil, err
}
result := &ExtendRenewalDateResponse{
raw: r.String(),
EffectiveDate: r.Get("effectiveDate").Int(),
OriginalTransactionId: r.Get("originalTransactionId").String(),
Success: r.Get("success").Bool(),
WebOrderLineItemId: r.Get("webOrderLineItemId").String(),
}
return result, err
}
type ExtendRenewalDateRequest struct {
// 必填。延长订阅续订日期的天数。最大值为 90 天。
// Required.
// The number of days to extend the subscription renewal date.
// The maximum value is 90 days.
ExtendByDays uint8 `json:"extendByDays"`
// 必填。订阅日期延长的原因代码。
// Required.
// The reason code for the subscription date extension.
ExtendReasonCode uint8 `json:"extendReasonCode"`
// 必填。一个字符串,其中包含您提供的用于唯一标识此续订日期扩展请求的值。
// 字符串的最大长度为 128 个字符。
// Required.
// A string that contains a value you provide to uniquely identify this renewal-date-extension request.
// The maximum length of the string is 128 characters.
RequestIdentifier string `json:"requestIdentifier"`
}
type ExtendRenewalDateResponse struct {
raw string
EffectiveDate int64 `json:"effectiveDate"`
OriginalTransactionId string `json:"originalTransactionId"`
Success bool `json:"success"`
WebOrderLineItemId string `json:"webOrderLineItemId"`
}
func (r *ExtendRenewalDateResponse) Raw() string {
return r.raw
}