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 package androidpublisher
39
40 import (
41 "bytes"
42 "context"
43 "encoding/json"
44 "errors"
45 "fmt"
46 "io"
47 "net/http"
48 "net/url"
49 "strconv"
50 "strings"
51
52 googleapi "google.golang.org/api/googleapi"
53 gensupport "google.golang.org/api/internal/gensupport"
54 option "google.golang.org/api/option"
55 internaloption "google.golang.org/api/option/internaloption"
56 htransport "google.golang.org/api/transport/http"
57 )
58
59
60
61 var _ = bytes.NewBuffer
62 var _ = strconv.Itoa
63 var _ = fmt.Sprintf
64 var _ = json.NewDecoder
65 var _ = io.Copy
66 var _ = url.Parse
67 var _ = gensupport.MarshalJSON
68 var _ = googleapi.Version
69 var _ = errors.New
70 var _ = strings.Replace
71 var _ = context.Canceled
72 var _ = internaloption.WithDefaultEndpoint
73
74 const apiId = "androidpublisher:v1.1"
75 const apiName = "androidpublisher"
76 const apiVersion = "v1.1"
77 const basePath = "https://www.googleapis.com/androidpublisher/v1.1/applications/"
78
79
80 const (
81
82 AndroidpublisherScope = "https://www.googleapis.com/auth/androidpublisher"
83 )
84
85
86 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
87 scopesOption := option.WithScopes(
88 "https://www.googleapis.com/auth/androidpublisher",
89 )
90
91 opts = append([]option.ClientOption{scopesOption}, opts...)
92 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
93 client, endpoint, err := htransport.NewClient(ctx, opts...)
94 if err != nil {
95 return nil, err
96 }
97 s, err := New(client)
98 if err != nil {
99 return nil, err
100 }
101 if endpoint != "" {
102 s.BasePath = endpoint
103 }
104 return s, nil
105 }
106
107
108
109
110
111
112 func New(client *http.Client) (*Service, error) {
113 if client == nil {
114 return nil, errors.New("client is nil")
115 }
116 s := &Service{client: client, BasePath: basePath}
117 s.Inapppurchases = NewInapppurchasesService(s)
118 return s, nil
119 }
120
121 type Service struct {
122 client *http.Client
123 BasePath string
124 UserAgent string
125
126 Inapppurchases *InapppurchasesService
127 }
128
129 func (s *Service) userAgent() string {
130 if s.UserAgent == "" {
131 return googleapi.UserAgent
132 }
133 return googleapi.UserAgent + " " + s.UserAgent
134 }
135
136 func NewInapppurchasesService(s *Service) *InapppurchasesService {
137 rs := &InapppurchasesService{s: s}
138 return rs
139 }
140
141 type InapppurchasesService struct {
142 s *Service
143 }
144
145
146
147 type InappPurchase struct {
148
149
150
151
152 ConsumptionState int64 `json:"consumptionState,omitempty"`
153
154
155
156 DeveloperPayload string `json:"developerPayload,omitempty"`
157
158
159
160 Kind string `json:"kind,omitempty"`
161
162
163
164 OrderId string `json:"orderId,omitempty"`
165
166
167
168
169
170
171 PurchaseState int64 `json:"purchaseState,omitempty"`
172
173
174
175 PurchaseTime int64 `json:"purchaseTime,omitempty,string"`
176
177
178
179
180
181
182
183 PurchaseType *int64 `json:"purchaseType,omitempty"`
184
185
186
187 googleapi.ServerResponse `json:"-"`
188
189
190
191
192
193
194
195 ForceSendFields []string `json:"-"`
196
197
198
199
200
201
202
203
204 NullFields []string `json:"-"`
205 }
206
207 func (s *InappPurchase) MarshalJSON() ([]byte, error) {
208 type NoMethod InappPurchase
209 raw := NoMethod(*s)
210 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
211 }
212
213
214
215 type InapppurchasesGetCall struct {
216 s *Service
217 packageName string
218 productId string
219 token string
220 urlParams_ gensupport.URLParams
221 ifNoneMatch_ string
222 ctx_ context.Context
223 header_ http.Header
224 }
225
226
227 func (r *InapppurchasesService) Get(packageName string, productId string, token string) *InapppurchasesGetCall {
228 c := &InapppurchasesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
229 c.packageName = packageName
230 c.productId = productId
231 c.token = token
232 return c
233 }
234
235
236
237
238 func (c *InapppurchasesGetCall) Fields(s ...googleapi.Field) *InapppurchasesGetCall {
239 c.urlParams_.Set("fields", googleapi.CombineFields(s))
240 return c
241 }
242
243
244
245
246
247
248 func (c *InapppurchasesGetCall) IfNoneMatch(entityTag string) *InapppurchasesGetCall {
249 c.ifNoneMatch_ = entityTag
250 return c
251 }
252
253
254
255
256 func (c *InapppurchasesGetCall) Context(ctx context.Context) *InapppurchasesGetCall {
257 c.ctx_ = ctx
258 return c
259 }
260
261
262
263 func (c *InapppurchasesGetCall) Header() http.Header {
264 if c.header_ == nil {
265 c.header_ = make(http.Header)
266 }
267 return c.header_
268 }
269
270 func (c *InapppurchasesGetCall) doRequest(alt string) (*http.Response, error) {
271 reqHeaders := make(http.Header)
272 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20200627")
273 for k, v := range c.header_ {
274 reqHeaders[k] = v
275 }
276 reqHeaders.Set("User-Agent", c.s.userAgent())
277 if c.ifNoneMatch_ != "" {
278 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
279 }
280 var body io.Reader = nil
281 c.urlParams_.Set("alt", alt)
282 c.urlParams_.Set("prettyPrint", "false")
283 urls := googleapi.ResolveRelative(c.s.BasePath, "{packageName}/inapp/{productId}/purchases/{token}")
284 urls += "?" + c.urlParams_.Encode()
285 req, err := http.NewRequest("GET", urls, body)
286 if err != nil {
287 return nil, err
288 }
289 req.Header = reqHeaders
290 googleapi.Expand(req.URL, map[string]string{
291 "packageName": c.packageName,
292 "productId": c.productId,
293 "token": c.token,
294 })
295 return gensupport.SendRequest(c.ctx_, c.s.client, req)
296 }
297
298
299
300
301
302
303
304
305 func (c *InapppurchasesGetCall) Do(opts ...googleapi.CallOption) (*InappPurchase, error) {
306 gensupport.SetOptions(c.urlParams_, opts...)
307 res, err := c.doRequest("json")
308 if res != nil && res.StatusCode == http.StatusNotModified {
309 if res.Body != nil {
310 res.Body.Close()
311 }
312 return nil, &googleapi.Error{
313 Code: res.StatusCode,
314 Header: res.Header,
315 }
316 }
317 if err != nil {
318 return nil, err
319 }
320 defer googleapi.CloseBody(res)
321 if err := googleapi.CheckResponse(res); err != nil {
322 return nil, err
323 }
324 ret := &InappPurchase{
325 ServerResponse: googleapi.ServerResponse{
326 Header: res.Header,
327 HTTPStatusCode: res.StatusCode,
328 },
329 }
330 target := &ret
331 if err := gensupport.DecodeResponse(target, res); err != nil {
332 return nil, err
333 }
334 return ret, nil
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373 }
374
View as plain text