-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
apps_metadata_infos.go
181 lines (163 loc) · 8.31 KB
/
apps_metadata_infos.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
179
180
181
package asc
import (
"context"
"fmt"
)
// AppInfo defines model for AppInfo.
//
// https://developer.apple.com/documentation/appstoreconnectapi/appinfo
type AppInfo struct {
Attributes *AppInfoAttributes `json:"attributes,omitempty"`
ID string `json:"id"`
Links ResourceLinks `json:"links"`
Relationships *AppInfoRelationships `json:"relationships,omitempty"`
Type string `json:"type"`
}
// AppInfoAttributes defines model for AppInfo.Attributes
//
// https://developer.apple.com/documentation/appstoreconnectapi/appinfo/attributes
type AppInfoAttributes struct {
AppStoreAgeRating *AppStoreAgeRating `json:"appStoreAgeRating,omitempty"`
AppStoreState *AppStoreVersionState `json:"appStoreState,omitempty"`
BrazilAgeRating *BrazilAgeRating `json:"brazilAgeRating,omitempty"`
KidsAgeBand *KidsAgeBand `json:"kidsAgeBand,omitempty"`
}
// AppInfoRelationships defines model for AppInfo.Relationships
//
// https://developer.apple.com/documentation/appstoreconnectapi/appinfo/relationships
type AppInfoRelationships struct {
App *Relationship `json:"app,omitempty"`
AppInfoLocalizations *PagedRelationship `json:"appInfoLocalizations,omitempty"`
PrimaryCategory *Relationship `json:"primaryCategory,omitempty"`
PrimarySubcategoryOne *Relationship `json:"primarySubcategoryOne,omitempty"`
PrimarySubcategoryTwo *Relationship `json:"primarySubcategoryTwo,omitempty"`
SecondaryCategory *Relationship `json:"secondaryCategory,omitempty"`
SecondarySubcategoryOne *Relationship `json:"secondarySubcategoryOne,omitempty"`
SecondarySubcategoryTwo *Relationship `json:"secondarySubcategoryTwo,omitempty"`
}
// AppInfoResponse defines model for AppInfoResponse.
//
// https://developer.apple.com/documentation/appstoreconnectapi/appinforesponse
type AppInfoResponse struct {
Data AppInfo `json:"data"`
Included []AppInfoResponseIncluded `json:"included,omitempty"`
Links DocumentLinks `json:"links"`
}
// AppInfosResponse defines model for AppInfosResponse.
//
// https://developer.apple.com/documentation/appstoreconnectapi/appinfosresponse
type AppInfosResponse struct {
Data []AppInfo `json:"data"`
Included []AppInfoResponseIncluded `json:"included,omitempty"`
Links PagedDocumentLinks `json:"links"`
Meta *PagingInformation `json:"meta,omitempty"`
}
// AppInfoResponseIncluded is a heterogenous wrapper for the possible types that can be returned
// in a AppInfoResponse or AppInfosResponse.
type AppInfoResponseIncluded included
// appInfoUpdateRequest defines model for AppInfoUpdateRequest.
//
// https://developer.apple.com/documentation/appstoreconnectapi/appinfoupdaterequest/data
type appInfoUpdateRequest struct {
ID string `json:"id"`
Relationships *appInfoUpdateRequestRelationships `json:"relationships,omitempty"`
Type string `json:"type"`
}
// AppInfoUpdateRequestRelationships are relationships for AppInfoUpdateRequest
//
// https://developer.apple.com/documentation/appstoreconnectapi/appinfoupdaterequest/data/relationships
type appInfoUpdateRequestRelationships struct {
PrimaryCategory *relationshipDeclaration `json:"primaryCategory,omitempty"`
PrimarySubcategoryOne *relationshipDeclaration `json:"primarySubcategoryOne,omitempty"`
PrimarySubcategoryTwo *relationshipDeclaration `json:"primarySubcategoryTwo,omitempty"`
SecondaryCategory *relationshipDeclaration `json:"secondaryCategory,omitempty"`
SecondarySubcategoryOne *relationshipDeclaration `json:"secondarySubcategoryOne,omitempty"`
SecondarySubcategoryTwo *relationshipDeclaration `json:"secondarySubcategoryTwo,omitempty"`
}
// AppInfoUpdateRequestRelationships is a public-facing options object for AppInfoUpdateRequest relationships.
type AppInfoUpdateRequestRelationships struct {
PrimaryCategoryID *string
PrimarySubcategoryOneID *string
PrimarySubcategoryTwoID *string
SecondaryCategoryID *string
SecondarySubcategoryOneID *string
SecondarySubcategoryTwoID *string
}
// GetAppInfoQuery are query options for GetAppInfo
//
// https://developer.apple.com/documentation/appstoreconnectapi/read_app_info_information
type GetAppInfoQuery struct {
FieldsAppInfos []string `url:"fields[appInfos],omitempty"`
FieldsAppInfoLocalizations []string `url:"fields[appInfoLocalizations],omitempty"`
FieldsAppCategories []string `url:"fields[appCategories],omitempty"`
Include []string `url:"include,omitempty"`
LimitAppInfoLocalizations int `url:"limit[appInfoLocalizations],omitempty"`
}
// ListAppInfosForAppQuery are query options for ListAppInfosForApp
//
// https://developer.apple.com/documentation/appstoreconnectapi/list_all_app_infos_for_an_app
type ListAppInfosForAppQuery struct {
FieldsAppInfos []string `url:"fields[appInfos],omitempty"`
FieldsApps []string `url:"fields[apps],omitempty"`
FieldsAppInfoLocalizations []string `url:"fields[appInfoLocalizations],omitempty"`
FieldsAppCategories []string `url:"fields[appCategories],omitempty"`
Limit int `url:"limit,omitempty"`
Include []string `url:"include,omitempty"`
Cursor string `url:"cursor,omitempty"`
}
// GetAppInfo reads App Store information including your App Store state, age ratings, Brazil age rating, and kids' age band.
//
// https://developer.apple.com/documentation/appstoreconnectapi/read_app_info_information
func (s *AppsService) GetAppInfo(ctx context.Context, id string, params *GetAppInfoQuery) (*AppInfoResponse, *Response, error) {
url := fmt.Sprintf("appInfos/%s", id)
res := new(AppInfoResponse)
resp, err := s.client.get(ctx, url, params, res)
return res, resp, err
}
// ListAppInfosForApp gets information about an app that is currently live on App Store, or that goes live with the next version.
//
// https://developer.apple.com/documentation/appstoreconnectapi/list_all_app_infos_for_an_app
func (s *AppsService) ListAppInfosForApp(ctx context.Context, id string, params *ListAppInfosForAppQuery) (*AppInfosResponse, *Response, error) {
url := fmt.Sprintf("apps/%s/appInfos", id)
res := new(AppInfosResponse)
resp, err := s.client.get(ctx, url, params, res)
return res, resp, err
}
// UpdateAppInfo updates the App Store categories and sub-categories for your app.
//
// https://developer.apple.com/documentation/appstoreconnectapi/modify_an_app_info
func (s *AppsService) UpdateAppInfo(ctx context.Context, id string, relationships *AppInfoUpdateRequestRelationships) (*AppInfoResponse, *Response, error) {
req := appInfoUpdateRequest{
ID: id,
Type: "appInfos",
}
if relationships != nil {
req.Relationships = &appInfoUpdateRequestRelationships{
PrimaryCategory: newRelationshipDeclaration(relationships.PrimaryCategoryID, "appCategories"),
PrimarySubcategoryOne: newRelationshipDeclaration(relationships.PrimarySubcategoryOneID, "appCategories"),
PrimarySubcategoryTwo: newRelationshipDeclaration(relationships.PrimarySubcategoryTwoID, "appCategories"),
SecondaryCategory: newRelationshipDeclaration(relationships.SecondaryCategoryID, "appCategories"),
SecondarySubcategoryOne: newRelationshipDeclaration(relationships.SecondarySubcategoryOneID, "appCategories"),
SecondarySubcategoryTwo: newRelationshipDeclaration(relationships.SecondarySubcategoryTwoID, "appCategories"),
}
}
url := fmt.Sprintf("appInfos/%s", id)
res := new(AppInfoResponse)
resp, err := s.client.patch(ctx, url, newRequestBody(req), res)
return res, resp, err
}
// UnmarshalJSON is a custom unmarshaller for the heterogenous data stored in AppInfoResponseIncluded.
func (i *AppInfoResponseIncluded) UnmarshalJSON(b []byte) error {
typeName, inner, err := unmarshalInclude(b)
i.Type = typeName
i.inner = inner
return err
}
// AppInfoLocalization returns the AppInfoLocalization stored within, if one is present.
func (i *AppInfoResponseIncluded) AppInfoLocalization() *AppInfoLocalization {
return extractIncludedAppInfoLocalization(i.inner)
}
// AppCategory returns the AppCategory stored within, if one is present.
func (i *AppInfoResponseIncluded) AppCategory() *AppCategory {
return extractIncludedAppCategory(i.inner)
}