1
// Package androidpublisher provides access to the Google Play Android Developer API.
3
// See https://developers.google.com/android-publisher
7
// import "google.golang.org/api/androidpublisher/v1.1"
9
// androidpublisherService, err := androidpublisher.New(oauthHttpClient)
10
package androidpublisher
17
"google.golang.org/api/googleapi"
25
// Always reference these packages, just in case the auto-generated code
27
var _ = bytes.NewBuffer
30
var _ = json.NewDecoder
33
var _ = googleapi.Version
35
var _ = strings.Replace
37
const apiId = "androidpublisher:v1.1"
38
const apiName = "androidpublisher"
39
const apiVersion = "v1.1"
40
const basePath = "https://www.googleapis.com/androidpublisher/v1.1/applications/"
42
// OAuth2 scopes used by this API.
44
// View and manage your Google Play Android Developer account
45
AndroidpublisherScope = "https://www.googleapis.com/auth/androidpublisher"
48
func New(client *http.Client) (*Service, error) {
50
return nil, errors.New("client is nil")
52
s := &Service{client: client, BasePath: basePath}
53
s.Inapppurchases = NewInapppurchasesService(s)
54
s.Purchases = NewPurchasesService(s)
60
BasePath string // API endpoint base URL
62
Inapppurchases *InapppurchasesService
64
Purchases *PurchasesService
67
func NewInapppurchasesService(s *Service) *InapppurchasesService {
68
rs := &InapppurchasesService{s: s}
72
type InapppurchasesService struct {
76
func NewPurchasesService(s *Service) *PurchasesService {
77
rs := &PurchasesService{s: s}
81
type PurchasesService struct {
85
type InappPurchase struct {
86
// ConsumptionState: The consumption state of the inapp product.
87
// Possible values are:
88
// - Yet to be consumed
90
ConsumptionState int64 `json:"consumptionState,omitempty"`
92
// DeveloperPayload: A developer-specified string that contains
93
// supplemental information about an order.
94
DeveloperPayload string `json:"developerPayload,omitempty"`
96
// Kind: This kind represents an inappPurchase object in the
97
// androidpublisher service.
98
Kind string `json:"kind,omitempty"`
100
// PurchaseState: The purchase state of the order. Possible values are:
104
PurchaseState int64 `json:"purchaseState,omitempty"`
106
// PurchaseTime: The time the product was purchased, in milliseconds
107
// since the epoch (Jan 1, 1970).
108
PurchaseTime int64 `json:"purchaseTime,omitempty,string"`
111
type SubscriptionPurchase struct {
112
// AutoRenewing: Whether the subscription will automatically be renewed
113
// when it reaches its current expiry time.
114
AutoRenewing bool `json:"autoRenewing,omitempty"`
116
// InitiationTimestampMsec: Time at which the subscription was granted,
117
// in milliseconds since Epoch.
118
InitiationTimestampMsec int64 `json:"initiationTimestampMsec,omitempty,string"`
120
// Kind: This kind represents a subscriptionPurchase object in the
121
// androidpublisher service.
122
Kind string `json:"kind,omitempty"`
124
// ValidUntilTimestampMsec: Time at which the subscription will expire,
125
// in milliseconds since Epoch.
126
ValidUntilTimestampMsec int64 `json:"validUntilTimestampMsec,omitempty,string"`
129
// method id "androidpublisher.inapppurchases.get":
131
type InapppurchasesGetCall struct {
136
opt_ map[string]interface{}
139
// Get: Checks the purchase and consumption status of an inapp item.
140
func (r *InapppurchasesService) Get(packageName string, productId string, token string) *InapppurchasesGetCall {
141
c := &InapppurchasesGetCall{s: r.s, opt_: make(map[string]interface{})}
142
c.packageName = packageName
143
c.productId = productId
148
// Fields allows partial responses to be retrieved.
149
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
150
// for more information.
151
func (c *InapppurchasesGetCall) Fields(s ...googleapi.Field) *InapppurchasesGetCall {
152
c.opt_["fields"] = googleapi.CombineFields(s)
156
func (c *InapppurchasesGetCall) Do() (*InappPurchase, error) {
157
var body io.Reader = nil
158
params := make(url.Values)
159
params.Set("alt", "json")
160
if v, ok := c.opt_["fields"]; ok {
161
params.Set("fields", fmt.Sprintf("%v", v))
163
urls := googleapi.ResolveRelative(c.s.BasePath, "{packageName}/inapp/{productId}/purchases/{token}")
164
urls += "?" + params.Encode()
165
req, _ := http.NewRequest("GET", urls, body)
166
googleapi.Expand(req.URL, map[string]string{
167
"packageName": c.packageName,
168
"productId": c.productId,
171
req.Header.Set("User-Agent", "google-api-go-client/0.5")
172
res, err := c.s.client.Do(req)
176
defer googleapi.CloseBody(res)
177
if err := googleapi.CheckResponse(res); err != nil {
180
var ret *InappPurchase
181
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
186
// "description": "Checks the purchase and consumption status of an inapp item.",
187
// "httpMethod": "GET",
188
// "id": "androidpublisher.inapppurchases.get",
189
// "parameterOrder": [
196
// "description": "The package name of the application the inapp product was sold in (for example, 'com.some.thing').",
197
// "location": "path",
202
// "description": "The inapp product SKU (for example, 'com.some.thing.inapp1').",
203
// "location": "path",
208
// "description": "The token provided to the user's device when the inapp product was purchased.",
209
// "location": "path",
214
// "path": "{packageName}/inapp/{productId}/purchases/{token}",
216
// "$ref": "InappPurchase"
219
// "https://www.googleapis.com/auth/androidpublisher"
225
// method id "androidpublisher.purchases.cancel":
227
type PurchasesCancelCall struct {
230
subscriptionId string
232
opt_ map[string]interface{}
235
// Cancel: Cancels a user's subscription purchase. The subscription
236
// remains valid until its expiration time.
237
func (r *PurchasesService) Cancel(packageName string, subscriptionId string, token string) *PurchasesCancelCall {
238
c := &PurchasesCancelCall{s: r.s, opt_: make(map[string]interface{})}
239
c.packageName = packageName
240
c.subscriptionId = subscriptionId
245
// Fields allows partial responses to be retrieved.
246
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
247
// for more information.
248
func (c *PurchasesCancelCall) Fields(s ...googleapi.Field) *PurchasesCancelCall {
249
c.opt_["fields"] = googleapi.CombineFields(s)
253
func (c *PurchasesCancelCall) Do() error {
254
var body io.Reader = nil
255
params := make(url.Values)
256
params.Set("alt", "json")
257
if v, ok := c.opt_["fields"]; ok {
258
params.Set("fields", fmt.Sprintf("%v", v))
260
urls := googleapi.ResolveRelative(c.s.BasePath, "{packageName}/subscriptions/{subscriptionId}/purchases/{token}/cancel")
261
urls += "?" + params.Encode()
262
req, _ := http.NewRequest("POST", urls, body)
263
googleapi.Expand(req.URL, map[string]string{
264
"packageName": c.packageName,
265
"subscriptionId": c.subscriptionId,
268
req.Header.Set("User-Agent", "google-api-go-client/0.5")
269
res, err := c.s.client.Do(req)
273
defer googleapi.CloseBody(res)
274
if err := googleapi.CheckResponse(res); err != nil {
279
// "description": "Cancels a user's subscription purchase. The subscription remains valid until its expiration time.",
280
// "httpMethod": "POST",
281
// "id": "androidpublisher.purchases.cancel",
282
// "parameterOrder": [
289
// "description": "The package name of the application for which this subscription was purchased (for example, 'com.some.thing').",
290
// "location": "path",
294
// "subscriptionId": {
295
// "description": "The purchased subscription ID (for example, 'monthly001').",
296
// "location": "path",
301
// "description": "The token provided to the user's device when the subscription was purchased.",
302
// "location": "path",
307
// "path": "{packageName}/subscriptions/{subscriptionId}/purchases/{token}/cancel",
309
// "https://www.googleapis.com/auth/androidpublisher"
315
// method id "androidpublisher.purchases.get":
317
type PurchasesGetCall struct {
320
subscriptionId string
322
opt_ map[string]interface{}
325
// Get: Checks whether a user's subscription purchase is valid and
326
// returns its expiry time.
327
func (r *PurchasesService) Get(packageName string, subscriptionId string, token string) *PurchasesGetCall {
328
c := &PurchasesGetCall{s: r.s, opt_: make(map[string]interface{})}
329
c.packageName = packageName
330
c.subscriptionId = subscriptionId
335
// Fields allows partial responses to be retrieved.
336
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
337
// for more information.
338
func (c *PurchasesGetCall) Fields(s ...googleapi.Field) *PurchasesGetCall {
339
c.opt_["fields"] = googleapi.CombineFields(s)
343
func (c *PurchasesGetCall) Do() (*SubscriptionPurchase, error) {
344
var body io.Reader = nil
345
params := make(url.Values)
346
params.Set("alt", "json")
347
if v, ok := c.opt_["fields"]; ok {
348
params.Set("fields", fmt.Sprintf("%v", v))
350
urls := googleapi.ResolveRelative(c.s.BasePath, "{packageName}/subscriptions/{subscriptionId}/purchases/{token}")
351
urls += "?" + params.Encode()
352
req, _ := http.NewRequest("GET", urls, body)
353
googleapi.Expand(req.URL, map[string]string{
354
"packageName": c.packageName,
355
"subscriptionId": c.subscriptionId,
358
req.Header.Set("User-Agent", "google-api-go-client/0.5")
359
res, err := c.s.client.Do(req)
363
defer googleapi.CloseBody(res)
364
if err := googleapi.CheckResponse(res); err != nil {
367
var ret *SubscriptionPurchase
368
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
373
// "description": "Checks whether a user's subscription purchase is valid and returns its expiry time.",
374
// "httpMethod": "GET",
375
// "id": "androidpublisher.purchases.get",
376
// "parameterOrder": [
383
// "description": "The package name of the application for which this subscription was purchased (for example, 'com.some.thing').",
384
// "location": "path",
388
// "subscriptionId": {
389
// "description": "The purchased subscription ID (for example, 'monthly001').",
390
// "location": "path",
395
// "description": "The token provided to the user's device when the subscription was purchased.",
396
// "location": "path",
401
// "path": "{packageName}/subscriptions/{subscriptionId}/purchases/{token}",
403
// "$ref": "SubscriptionPurchase"
406
// "https://www.googleapis.com/auth/androidpublisher"