-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
apps_metadata_eula.go
178 lines (160 loc) · 8.35 KB
/
apps_metadata_eula.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
package asc
import (
"context"
"fmt"
)
// EndUserLicenseAgreement defines model for EndUserLicenseAgreement.
//
// https://developer.apple.com/documentation/appstoreconnectapi/enduserlicenseagreement
type EndUserLicenseAgreement struct {
Attributes *EndUserLicenseAgreementAttributes `json:"attributes,omitempty"`
ID string `json:"id"`
Links ResourceLinks `json:"links"`
Relationships *EndUserLicenseAgreementRelationships `json:"relationships,omitempty"`
Type string `json:"type"`
}
// EndUserLicenseAgreementAttributes defines model for EndUserLicenseAgreement.Attributes
//
// https://developer.apple.com/documentation/appstoreconnectapi/enduserlicenseagreement/attributes
type EndUserLicenseAgreementAttributes struct {
AgreementText *string `json:"agreementText,omitempty"`
}
// EndUserLicenseAgreementRelationships defines model for EndUserLicenseAgreement.Relationships
//
// https://developer.apple.com/documentation/appstoreconnectapi/enduserlicenseagreement/relationships
type EndUserLicenseAgreementRelationships struct {
App *Relationship `json:"app,omitempty"`
Territories *PagedRelationship `json:"territories,omitempty"`
}
// endUserLicenseAgreementCreateRequest defines model for EndUserLicenseAgreementCreateRequest.
//
// https://developer.apple.com/documentation/appstoreconnectapi/enduserlicenseagreementcreaterequest/data
type endUserLicenseAgreementCreateRequest struct {
Attributes endUserLicenseAgreementCreateRequestAttributes `json:"attributes"`
Relationships endUserLicenseAgreementCreateRequestRelationships `json:"relationships"`
Type string `json:"type"`
}
// EndUserLicenseAgreementCreateRequestAttributes are attributes for EndUserLicenseAgreementCreateRequest
//
// https://developer.apple.com/documentation/appstoreconnectapi/enduserlicenseagreementcreaterequest/data/attributes
type endUserLicenseAgreementCreateRequestAttributes struct {
AgreementText string `json:"agreementText"`
}
// EndUserLicenseAgreementCreateRequestRelationships are relationships for EndUserLicenseAgreementCreateRequest
//
// https://developer.apple.com/documentation/appstoreconnectapi/enduserlicenseagreementcreaterequest/data/relationships
type endUserLicenseAgreementCreateRequestRelationships struct {
App relationshipDeclaration `json:"app"`
Territories pagedRelationshipDeclaration `json:"territories"`
}
// endUserLicenseAgreementUpdateRequest defines model for EndUserLicenseAgreementUpdateRequest.
//
// https://developer.apple.com/documentation/appstoreconnectapi/enduserlicenseagreementupdaterequest/data
type endUserLicenseAgreementUpdateRequest struct {
Attributes *endUserLicenseAgreementUpdateRequestAttributes `json:"attributes,omitempty"`
ID string `json:"id"`
Relationships *endUserLicenseAgreementUpdateRequestRelationships `json:"relationships,omitempty"`
Type string `json:"type"`
}
// EndUserLicenseAgreementUpdateRequestAttributes are attributes for EndUserLicenseAgreementUpdateRequest
//
// https://developer.apple.com/documentation/appstoreconnectapi/enduserlicenseagreementupdaterequest/data/attributes
type endUserLicenseAgreementUpdateRequestAttributes struct {
AgreementText *string `json:"agreementText,omitempty"`
}
// endUserLicenseAgreementUpdateRequestRelationships are relationships for EndUserLicenseAgreementUpdateRequest
//
// https://developer.apple.com/documentation/appstoreconnectapi/enduserlicenseagreementupdaterequest/data/relationships
type endUserLicenseAgreementUpdateRequestRelationships struct {
Territories *pagedRelationshipDeclaration `json:"territories,omitempty"`
}
// EndUserLicenseAgreementResponse defines model for EndUserLicenseAgreementResponse.
//
// https://developer.apple.com/documentation/appstoreconnectapi/enduserlicenseagreementresponse
type EndUserLicenseAgreementResponse struct {
Data EndUserLicenseAgreement `json:"data"`
Included []Territory `json:"included,omitempty"`
Links DocumentLinks `json:"links"`
}
// GetEULAQuery are query options for GetEULA
//
// https://developer.apple.com/documentation/appstoreconnectapi/read_end_user_license_agreement_information
type GetEULAQuery struct {
FieldsEndUserLicenseAgreements []string `url:"fields[endUserLicenseAgreements],omitempty"`
FieldsTerritories []string `url:"fields[territories],omitempty"`
Include []string `url:"include,omitempty"`
LimitTerritories int `url:"limit[territories],omitempty"`
}
// GetEULAForAppQuery are query options for GetEULAForApp
//
// https://developer.apple.com/documentation/appstoreconnectapi/read_the_end_user_license_agreement_information_of_an_app
type GetEULAForAppQuery struct {
FieldsEndUserLicenseAgreements []string `url:"fields[endUserLicenseAgreements],omitempty"`
}
// CreateEULA adds a custom end user license agreement (EULA) to an app and configure the territories to which it applies.
//
// https://developer.apple.com/documentation/appstoreconnectapi/create_an_end_user_license_agreement
func (s *AppsService) CreateEULA(ctx context.Context, agreementText string, appID string, territoryIDs []string) (*EndUserLicenseAgreementResponse, *Response, error) {
req := endUserLicenseAgreementCreateRequest{
Attributes: endUserLicenseAgreementCreateRequestAttributes{
AgreementText: agreementText,
},
Relationships: endUserLicenseAgreementCreateRequestRelationships{
App: *newRelationshipDeclaration(&appID, "apps"),
Territories: newPagedRelationshipDeclaration(territoryIDs, "territories"),
},
Type: "endUserLicenseAgreements",
}
res := new(EndUserLicenseAgreementResponse)
resp, err := s.client.post(ctx, "endUserLicenseAgreements", newRequestBody(req), res)
return res, resp, err
}
// UpdateEULA updates the text or territories for your custom end user license agreement.
//
// https://developer.apple.com/documentation/appstoreconnectapi/modify_an_end_user_license_agreement
func (s *AppsService) UpdateEULA(ctx context.Context, id string, agreementText *string, territoryIDs []string) (*EndUserLicenseAgreementResponse, *Response, error) {
req := endUserLicenseAgreementUpdateRequest{
ID: id,
Type: "endUserLicenseAgreements",
}
if agreementText != nil {
req.Attributes = &endUserLicenseAgreementUpdateRequestAttributes{
AgreementText: agreementText,
}
}
if len(territoryIDs) > 0 {
relationships := newPagedRelationshipDeclaration(territoryIDs, "territories")
req.Relationships = &endUserLicenseAgreementUpdateRequestRelationships{
Territories: &relationships,
}
}
url := fmt.Sprintf("endUserLicenseAgreements/%s", id)
res := new(EndUserLicenseAgreementResponse)
resp, err := s.client.patch(ctx, url, newRequestBody(req), res)
return res, resp, err
}
// DeleteEULA deletes the custom end user license agreement that is associated with an app.
//
// https://developer.apple.com/documentation/appstoreconnectapi/delete_an_end_user_license_agreement
func (s *AppsService) DeleteEULA(ctx context.Context, id string) (*Response, error) {
url := fmt.Sprintf("endUserLicenseAgreements/%s", id)
return s.client.delete(ctx, url, nil)
}
// GetEULA gets the custom end user license agreement associated with an app, and the territories it applies to.
//
// https://developer.apple.com/documentation/appstoreconnectapi/read_end_user_license_agreement_information
func (s *AppsService) GetEULA(ctx context.Context, id string, params *GetEULAQuery) (*EndUserLicenseAgreementResponse, *Response, error) {
url := fmt.Sprintf("endUserLicenseAgreements/%s", id)
res := new(EndUserLicenseAgreementResponse)
resp, err := s.client.get(ctx, url, params, res)
return res, resp, err
}
// GetEULAForApp gets the custom end user license agreement (EULA) for a specific app and the territories where the agreement applies.
//
// https://developer.apple.com/documentation/appstoreconnectapi/read_the_end_user_license_agreement_information_of_an_app
func (s *AppsService) GetEULAForApp(ctx context.Context, id string, params *GetEULAForAppQuery) (*EndUserLicenseAgreementResponse, *Response, error) {
url := fmt.Sprintf("apps/%s/endUserLicenseAgreement", id)
res := new(EndUserLicenseAgreementResponse)
resp, err := s.client.get(ctx, url, params, res)
return res, resp, err
}