You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

709 lines
23 KiB

  1. // Copyright 2019 Google LLC.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Code generated file. DO NOT EDIT.
  5. // Package androidpublisher provides access to the Google Play Developer API.
  6. //
  7. // For product documentation, see: https://developers.google.com/android-publisher
  8. //
  9. // Creating a client
  10. //
  11. // Usage example:
  12. //
  13. // import "google.golang.org/api/androidpublisher/v1.1"
  14. // ...
  15. // ctx := context.Background()
  16. // androidpublisherService, err := androidpublisher.NewService(ctx)
  17. //
  18. // In this example, Google Application Default Credentials are used for authentication.
  19. //
  20. // For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
  21. //
  22. // Other authentication options
  23. //
  24. // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
  25. //
  26. // androidpublisherService, err := androidpublisher.NewService(ctx, option.WithAPIKey("AIza..."))
  27. //
  28. // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
  29. //
  30. // config := &oauth2.Config{...}
  31. // // ...
  32. // token, err := config.Exchange(ctx, ...)
  33. // androidpublisherService, err := androidpublisher.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
  34. //
  35. // See https://godoc.org/google.golang.org/api/option/ for details on options.
  36. package androidpublisher // import "google.golang.org/api/androidpublisher/v1.1"
  37. import (
  38. "bytes"
  39. "context"
  40. "encoding/json"
  41. "errors"
  42. "fmt"
  43. "io"
  44. "net/http"
  45. "net/url"
  46. "strconv"
  47. "strings"
  48. gensupport "google.golang.org/api/gensupport"
  49. googleapi "google.golang.org/api/googleapi"
  50. option "google.golang.org/api/option"
  51. htransport "google.golang.org/api/transport/http"
  52. )
  53. // Always reference these packages, just in case the auto-generated code
  54. // below doesn't.
  55. var _ = bytes.NewBuffer
  56. var _ = strconv.Itoa
  57. var _ = fmt.Sprintf
  58. var _ = json.NewDecoder
  59. var _ = io.Copy
  60. var _ = url.Parse
  61. var _ = gensupport.MarshalJSON
  62. var _ = googleapi.Version
  63. var _ = errors.New
  64. var _ = strings.Replace
  65. var _ = context.Canceled
  66. const apiId = "androidpublisher:v1.1"
  67. const apiName = "androidpublisher"
  68. const apiVersion = "v1.1"
  69. const basePath = "https://www.googleapis.com/androidpublisher/v1.1/applications/"
  70. // OAuth2 scopes used by this API.
  71. const (
  72. // View and manage your Google Play Developer account
  73. AndroidpublisherScope = "https://www.googleapis.com/auth/androidpublisher"
  74. )
  75. // NewService creates a new Service.
  76. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
  77. scopesOption := option.WithScopes(
  78. "https://www.googleapis.com/auth/androidpublisher",
  79. )
  80. // NOTE: prepend, so we don't override user-specified scopes.
  81. opts = append([]option.ClientOption{scopesOption}, opts...)
  82. client, endpoint, err := htransport.NewClient(ctx, opts...)
  83. if err != nil {
  84. return nil, err
  85. }
  86. s, err := New(client)
  87. if err != nil {
  88. return nil, err
  89. }
  90. if endpoint != "" {
  91. s.BasePath = endpoint
  92. }
  93. return s, nil
  94. }
  95. // New creates a new Service. It uses the provided http.Client for requests.
  96. //
  97. // Deprecated: please use NewService instead.
  98. // To provide a custom HTTP client, use option.WithHTTPClient.
  99. // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
  100. func New(client *http.Client) (*Service, error) {
  101. if client == nil {
  102. return nil, errors.New("client is nil")
  103. }
  104. s := &Service{client: client, BasePath: basePath}
  105. s.Inapppurchases = NewInapppurchasesService(s)
  106. s.Purchases = NewPurchasesService(s)
  107. return s, nil
  108. }
  109. type Service struct {
  110. client *http.Client
  111. BasePath string // API endpoint base URL
  112. UserAgent string // optional additional User-Agent fragment
  113. Inapppurchases *InapppurchasesService
  114. Purchases *PurchasesService
  115. }
  116. func (s *Service) userAgent() string {
  117. if s.UserAgent == "" {
  118. return googleapi.UserAgent
  119. }
  120. return googleapi.UserAgent + " " + s.UserAgent
  121. }
  122. func NewInapppurchasesService(s *Service) *InapppurchasesService {
  123. rs := &InapppurchasesService{s: s}
  124. return rs
  125. }
  126. type InapppurchasesService struct {
  127. s *Service
  128. }
  129. func NewPurchasesService(s *Service) *PurchasesService {
  130. rs := &PurchasesService{s: s}
  131. return rs
  132. }
  133. type PurchasesService struct {
  134. s *Service
  135. }
  136. // InappPurchase: An InappPurchase resource indicates the status of a
  137. // user's inapp product purchase.
  138. type InappPurchase struct {
  139. // ConsumptionState: The consumption state of the inapp product.
  140. // Possible values are:
  141. // - Yet to be consumed
  142. // - Consumed
  143. ConsumptionState int64 `json:"consumptionState,omitempty"`
  144. // DeveloperPayload: A developer-specified string that contains
  145. // supplemental information about an order.
  146. DeveloperPayload string `json:"developerPayload,omitempty"`
  147. // Kind: This kind represents an inappPurchase object in the
  148. // androidpublisher service.
  149. Kind string `json:"kind,omitempty"`
  150. // OrderId: The order id associated with the purchase of the inapp
  151. // product.
  152. OrderId string `json:"orderId,omitempty"`
  153. // PurchaseState: The purchase state of the order. Possible values are:
  154. //
  155. // - Purchased
  156. // - Canceled
  157. PurchaseState int64 `json:"purchaseState,omitempty"`
  158. // PurchaseTime: The time the product was purchased, in milliseconds
  159. // since the epoch (Jan 1, 1970).
  160. PurchaseTime int64 `json:"purchaseTime,omitempty,string"`
  161. // PurchaseType: The type of purchase of the inapp product. This field
  162. // is only set if this purchase was not made using the standard in-app
  163. // billing flow. Possible values are:
  164. // - Test (i.e. purchased from a license testing account)
  165. // - Promo (i.e. purchased using a promo code)
  166. // - Rewarded (i.e. from watching a video ad instead of paying)
  167. PurchaseType *int64 `json:"purchaseType,omitempty"`
  168. // ServerResponse contains the HTTP response code and headers from the
  169. // server.
  170. googleapi.ServerResponse `json:"-"`
  171. // ForceSendFields is a list of field names (e.g. "ConsumptionState") to
  172. // unconditionally include in API requests. By default, fields with
  173. // empty values are omitted from API requests. However, any non-pointer,
  174. // non-interface field appearing in ForceSendFields will be sent to the
  175. // server regardless of whether the field is empty or not. This may be
  176. // used to include empty fields in Patch requests.
  177. ForceSendFields []string `json:"-"`
  178. // NullFields is a list of field names (e.g. "ConsumptionState") to
  179. // include in API requests with the JSON null value. By default, fields
  180. // with empty values are omitted from API requests. However, any field
  181. // with an empty value appearing in NullFields will be sent to the
  182. // server as null. It is an error if a field in this list has a
  183. // non-empty value. This may be used to include null fields in Patch
  184. // requests.
  185. NullFields []string `json:"-"`
  186. }
  187. func (s *InappPurchase) MarshalJSON() ([]byte, error) {
  188. type NoMethod InappPurchase
  189. raw := NoMethod(*s)
  190. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  191. }
  192. // SubscriptionPurchase: A SubscriptionPurchase resource indicates the
  193. // status of a user's subscription purchase.
  194. type SubscriptionPurchase struct {
  195. // AutoRenewing: Whether the subscription will automatically be renewed
  196. // when it reaches its current expiry time.
  197. AutoRenewing bool `json:"autoRenewing,omitempty"`
  198. // InitiationTimestampMsec: Time at which the subscription was granted,
  199. // in milliseconds since the Epoch.
  200. InitiationTimestampMsec int64 `json:"initiationTimestampMsec,omitempty,string"`
  201. // Kind: This kind represents a subscriptionPurchase object in the
  202. // androidpublisher service.
  203. Kind string `json:"kind,omitempty"`
  204. // ValidUntilTimestampMsec: Time at which the subscription will expire,
  205. // in milliseconds since the Epoch.
  206. ValidUntilTimestampMsec int64 `json:"validUntilTimestampMsec,omitempty,string"`
  207. // ServerResponse contains the HTTP response code and headers from the
  208. // server.
  209. googleapi.ServerResponse `json:"-"`
  210. // ForceSendFields is a list of field names (e.g. "AutoRenewing") to
  211. // unconditionally include in API requests. By default, fields with
  212. // empty values are omitted from API requests. However, any non-pointer,
  213. // non-interface field appearing in ForceSendFields will be sent to the
  214. // server regardless of whether the field is empty or not. This may be
  215. // used to include empty fields in Patch requests.
  216. ForceSendFields []string `json:"-"`
  217. // NullFields is a list of field names (e.g. "AutoRenewing") to include
  218. // in API requests with the JSON null value. By default, fields with
  219. // empty values are omitted from API requests. However, any field with
  220. // an empty value appearing in NullFields will be sent to the server as
  221. // null. It is an error if a field in this list has a non-empty value.
  222. // This may be used to include null fields in Patch requests.
  223. NullFields []string `json:"-"`
  224. }
  225. func (s *SubscriptionPurchase) MarshalJSON() ([]byte, error) {
  226. type NoMethod SubscriptionPurchase
  227. raw := NoMethod(*s)
  228. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  229. }
  230. // method id "androidpublisher.inapppurchases.get":
  231. type InapppurchasesGetCall struct {
  232. s *Service
  233. packageName string
  234. productId string
  235. token string
  236. urlParams_ gensupport.URLParams
  237. ifNoneMatch_ string
  238. ctx_ context.Context
  239. header_ http.Header
  240. }
  241. // Get: Checks the purchase and consumption status of an inapp item.
  242. func (r *InapppurchasesService) Get(packageName string, productId string, token string) *InapppurchasesGetCall {
  243. c := &InapppurchasesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  244. c.packageName = packageName
  245. c.productId = productId
  246. c.token = token
  247. return c
  248. }
  249. // Fields allows partial responses to be retrieved. See
  250. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  251. // for more information.
  252. func (c *InapppurchasesGetCall) Fields(s ...googleapi.Field) *InapppurchasesGetCall {
  253. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  254. return c
  255. }
  256. // IfNoneMatch sets the optional parameter which makes the operation
  257. // fail if the object's ETag matches the given value. This is useful for
  258. // getting updates only after the object has changed since the last
  259. // request. Use googleapi.IsNotModified to check whether the response
  260. // error from Do is the result of In-None-Match.
  261. func (c *InapppurchasesGetCall) IfNoneMatch(entityTag string) *InapppurchasesGetCall {
  262. c.ifNoneMatch_ = entityTag
  263. return c
  264. }
  265. // Context sets the context to be used in this call's Do method. Any
  266. // pending HTTP request will be aborted if the provided context is
  267. // canceled.
  268. func (c *InapppurchasesGetCall) Context(ctx context.Context) *InapppurchasesGetCall {
  269. c.ctx_ = ctx
  270. return c
  271. }
  272. // Header returns an http.Header that can be modified by the caller to
  273. // add HTTP headers to the request.
  274. func (c *InapppurchasesGetCall) Header() http.Header {
  275. if c.header_ == nil {
  276. c.header_ = make(http.Header)
  277. }
  278. return c.header_
  279. }
  280. func (c *InapppurchasesGetCall) doRequest(alt string) (*http.Response, error) {
  281. reqHeaders := make(http.Header)
  282. for k, v := range c.header_ {
  283. reqHeaders[k] = v
  284. }
  285. reqHeaders.Set("User-Agent", c.s.userAgent())
  286. if c.ifNoneMatch_ != "" {
  287. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  288. }
  289. var body io.Reader = nil
  290. c.urlParams_.Set("alt", alt)
  291. c.urlParams_.Set("prettyPrint", "false")
  292. urls := googleapi.ResolveRelative(c.s.BasePath, "{packageName}/inapp/{productId}/purchases/{token}")
  293. urls += "?" + c.urlParams_.Encode()
  294. req, err := http.NewRequest("GET", urls, body)
  295. if err != nil {
  296. return nil, err
  297. }
  298. req.Header = reqHeaders
  299. googleapi.Expand(req.URL, map[string]string{
  300. "packageName": c.packageName,
  301. "productId": c.productId,
  302. "token": c.token,
  303. })
  304. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  305. }
  306. // Do executes the "androidpublisher.inapppurchases.get" call.
  307. // Exactly one of *InappPurchase or error will be non-nil. Any non-2xx
  308. // status code is an error. Response headers are in either
  309. // *InappPurchase.ServerResponse.Header or (if a response was returned
  310. // at all) in error.(*googleapi.Error).Header. Use
  311. // googleapi.IsNotModified to check whether the returned error was
  312. // because http.StatusNotModified was returned.
  313. func (c *InapppurchasesGetCall) Do(opts ...googleapi.CallOption) (*InappPurchase, error) {
  314. gensupport.SetOptions(c.urlParams_, opts...)
  315. res, err := c.doRequest("json")
  316. if res != nil && res.StatusCode == http.StatusNotModified {
  317. if res.Body != nil {
  318. res.Body.Close()
  319. }
  320. return nil, &googleapi.Error{
  321. Code: res.StatusCode,
  322. Header: res.Header,
  323. }
  324. }
  325. if err != nil {
  326. return nil, err
  327. }
  328. defer googleapi.CloseBody(res)
  329. if err := googleapi.CheckResponse(res); err != nil {
  330. return nil, err
  331. }
  332. ret := &InappPurchase{
  333. ServerResponse: googleapi.ServerResponse{
  334. Header: res.Header,
  335. HTTPStatusCode: res.StatusCode,
  336. },
  337. }
  338. target := &ret
  339. if err := gensupport.DecodeResponse(target, res); err != nil {
  340. return nil, err
  341. }
  342. return ret, nil
  343. // {
  344. // "description": "Checks the purchase and consumption status of an inapp item.",
  345. // "httpMethod": "GET",
  346. // "id": "androidpublisher.inapppurchases.get",
  347. // "parameterOrder": [
  348. // "packageName",
  349. // "productId",
  350. // "token"
  351. // ],
  352. // "parameters": {
  353. // "packageName": {
  354. // "description": "The package name of the application the inapp product was sold in (for example, 'com.some.thing').",
  355. // "location": "path",
  356. // "required": true,
  357. // "type": "string"
  358. // },
  359. // "productId": {
  360. // "description": "The inapp product SKU (for example, 'com.some.thing.inapp1').",
  361. // "location": "path",
  362. // "required": true,
  363. // "type": "string"
  364. // },
  365. // "token": {
  366. // "description": "The token provided to the user's device when the inapp product was purchased.",
  367. // "location": "path",
  368. // "required": true,
  369. // "type": "string"
  370. // }
  371. // },
  372. // "path": "{packageName}/inapp/{productId}/purchases/{token}",
  373. // "response": {
  374. // "$ref": "InappPurchase"
  375. // },
  376. // "scopes": [
  377. // "https://www.googleapis.com/auth/androidpublisher"
  378. // ]
  379. // }
  380. }
  381. // method id "androidpublisher.purchases.cancel":
  382. type PurchasesCancelCall struct {
  383. s *Service
  384. packageName string
  385. subscriptionId string
  386. token string
  387. urlParams_ gensupport.URLParams
  388. ctx_ context.Context
  389. header_ http.Header
  390. }
  391. // Cancel: Cancels a user's subscription purchase. The subscription
  392. // remains valid until its expiration time.
  393. func (r *PurchasesService) Cancel(packageName string, subscriptionId string, token string) *PurchasesCancelCall {
  394. c := &PurchasesCancelCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  395. c.packageName = packageName
  396. c.subscriptionId = subscriptionId
  397. c.token = token
  398. return c
  399. }
  400. // Fields allows partial responses to be retrieved. See
  401. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  402. // for more information.
  403. func (c *PurchasesCancelCall) Fields(s ...googleapi.Field) *PurchasesCancelCall {
  404. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  405. return c
  406. }
  407. // Context sets the context to be used in this call's Do method. Any
  408. // pending HTTP request will be aborted if the provided context is
  409. // canceled.
  410. func (c *PurchasesCancelCall) Context(ctx context.Context) *PurchasesCancelCall {
  411. c.ctx_ = ctx
  412. return c
  413. }
  414. // Header returns an http.Header that can be modified by the caller to
  415. // add HTTP headers to the request.
  416. func (c *PurchasesCancelCall) Header() http.Header {
  417. if c.header_ == nil {
  418. c.header_ = make(http.Header)
  419. }
  420. return c.header_
  421. }
  422. func (c *PurchasesCancelCall) doRequest(alt string) (*http.Response, error) {
  423. reqHeaders := make(http.Header)
  424. for k, v := range c.header_ {
  425. reqHeaders[k] = v
  426. }
  427. reqHeaders.Set("User-Agent", c.s.userAgent())
  428. var body io.Reader = nil
  429. c.urlParams_.Set("alt", alt)
  430. c.urlParams_.Set("prettyPrint", "false")
  431. urls := googleapi.ResolveRelative(c.s.BasePath, "{packageName}/subscriptions/{subscriptionId}/purchases/{token}/cancel")
  432. urls += "?" + c.urlParams_.Encode()
  433. req, err := http.NewRequest("POST", urls, body)
  434. if err != nil {
  435. return nil, err
  436. }
  437. req.Header = reqHeaders
  438. googleapi.Expand(req.URL, map[string]string{
  439. "packageName": c.packageName,
  440. "subscriptionId": c.subscriptionId,
  441. "token": c.token,
  442. })
  443. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  444. }
  445. // Do executes the "androidpublisher.purchases.cancel" call.
  446. func (c *PurchasesCancelCall) Do(opts ...googleapi.CallOption) error {
  447. gensupport.SetOptions(c.urlParams_, opts...)
  448. res, err := c.doRequest("json")
  449. if err != nil {
  450. return err
  451. }
  452. defer googleapi.CloseBody(res)
  453. if err := googleapi.CheckResponse(res); err != nil {
  454. return err
  455. }
  456. return nil
  457. // {
  458. // "description": "Cancels a user's subscription purchase. The subscription remains valid until its expiration time.",
  459. // "httpMethod": "POST",
  460. // "id": "androidpublisher.purchases.cancel",
  461. // "parameterOrder": [
  462. // "packageName",
  463. // "subscriptionId",
  464. // "token"
  465. // ],
  466. // "parameters": {
  467. // "packageName": {
  468. // "description": "The package name of the application for which this subscription was purchased (for example, 'com.some.thing').",
  469. // "location": "path",
  470. // "required": true,
  471. // "type": "string"
  472. // },
  473. // "subscriptionId": {
  474. // "description": "The purchased subscription ID (for example, 'monthly001').",
  475. // "location": "path",
  476. // "required": true,
  477. // "type": "string"
  478. // },
  479. // "token": {
  480. // "description": "The token provided to the user's device when the subscription was purchased.",
  481. // "location": "path",
  482. // "required": true,
  483. // "type": "string"
  484. // }
  485. // },
  486. // "path": "{packageName}/subscriptions/{subscriptionId}/purchases/{token}/cancel",
  487. // "scopes": [
  488. // "https://www.googleapis.com/auth/androidpublisher"
  489. // ]
  490. // }
  491. }
  492. // method id "androidpublisher.purchases.get":
  493. type PurchasesGetCall struct {
  494. s *Service
  495. packageName string
  496. subscriptionId string
  497. token string
  498. urlParams_ gensupport.URLParams
  499. ifNoneMatch_ string
  500. ctx_ context.Context
  501. header_ http.Header
  502. }
  503. // Get: Checks whether a user's subscription purchase is valid and
  504. // returns its expiry time.
  505. func (r *PurchasesService) Get(packageName string, subscriptionId string, token string) *PurchasesGetCall {
  506. c := &PurchasesGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  507. c.packageName = packageName
  508. c.subscriptionId = subscriptionId
  509. c.token = token
  510. return c
  511. }
  512. // Fields allows partial responses to be retrieved. See
  513. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  514. // for more information.
  515. func (c *PurchasesGetCall) Fields(s ...googleapi.Field) *PurchasesGetCall {
  516. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  517. return c
  518. }
  519. // IfNoneMatch sets the optional parameter which makes the operation
  520. // fail if the object's ETag matches the given value. This is useful for
  521. // getting updates only after the object has changed since the last
  522. // request. Use googleapi.IsNotModified to check whether the response
  523. // error from Do is the result of In-None-Match.
  524. func (c *PurchasesGetCall) IfNoneMatch(entityTag string) *PurchasesGetCall {
  525. c.ifNoneMatch_ = entityTag
  526. return c
  527. }
  528. // Context sets the context to be used in this call's Do method. Any
  529. // pending HTTP request will be aborted if the provided context is
  530. // canceled.
  531. func (c *PurchasesGetCall) Context(ctx context.Context) *PurchasesGetCall {
  532. c.ctx_ = ctx
  533. return c
  534. }
  535. // Header returns an http.Header that can be modified by the caller to
  536. // add HTTP headers to the request.
  537. func (c *PurchasesGetCall) Header() http.Header {
  538. if c.header_ == nil {
  539. c.header_ = make(http.Header)
  540. }
  541. return c.header_
  542. }
  543. func (c *PurchasesGetCall) doRequest(alt string) (*http.Response, error) {
  544. reqHeaders := make(http.Header)
  545. for k, v := range c.header_ {
  546. reqHeaders[k] = v
  547. }
  548. reqHeaders.Set("User-Agent", c.s.userAgent())
  549. if c.ifNoneMatch_ != "" {
  550. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  551. }
  552. var body io.Reader = nil
  553. c.urlParams_.Set("alt", alt)
  554. c.urlParams_.Set("prettyPrint", "false")
  555. urls := googleapi.ResolveRelative(c.s.BasePath, "{packageName}/subscriptions/{subscriptionId}/purchases/{token}")
  556. urls += "?" + c.urlParams_.Encode()
  557. req, err := http.NewRequest("GET", urls, body)
  558. if err != nil {
  559. return nil, err
  560. }
  561. req.Header = reqHeaders
  562. googleapi.Expand(req.URL, map[string]string{
  563. "packageName": c.packageName,
  564. "subscriptionId": c.subscriptionId,
  565. "token": c.token,
  566. })
  567. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  568. }
  569. // Do executes the "androidpublisher.purchases.get" call.
  570. // Exactly one of *SubscriptionPurchase or error will be non-nil. Any
  571. // non-2xx status code is an error. Response headers are in either
  572. // *SubscriptionPurchase.ServerResponse.Header or (if a response was
  573. // returned at all) in error.(*googleapi.Error).Header. Use
  574. // googleapi.IsNotModified to check whether the returned error was
  575. // because http.StatusNotModified was returned.
  576. func (c *PurchasesGetCall) Do(opts ...googleapi.CallOption) (*SubscriptionPurchase, error) {
  577. gensupport.SetOptions(c.urlParams_, opts...)
  578. res, err := c.doRequest("json")
  579. if res != nil && res.StatusCode == http.StatusNotModified {
  580. if res.Body != nil {
  581. res.Body.Close()
  582. }
  583. return nil, &googleapi.Error{
  584. Code: res.StatusCode,
  585. Header: res.Header,
  586. }
  587. }
  588. if err != nil {
  589. return nil, err
  590. }
  591. defer googleapi.CloseBody(res)
  592. if err := googleapi.CheckResponse(res); err != nil {
  593. return nil, err
  594. }
  595. ret := &SubscriptionPurchase{
  596. ServerResponse: googleapi.ServerResponse{
  597. Header: res.Header,
  598. HTTPStatusCode: res.StatusCode,
  599. },
  600. }
  601. target := &ret
  602. if err := gensupport.DecodeResponse(target, res); err != nil {
  603. return nil, err
  604. }
  605. return ret, nil
  606. // {
  607. // "description": "Checks whether a user's subscription purchase is valid and returns its expiry time.",
  608. // "httpMethod": "GET",
  609. // "id": "androidpublisher.purchases.get",
  610. // "parameterOrder": [
  611. // "packageName",
  612. // "subscriptionId",
  613. // "token"
  614. // ],
  615. // "parameters": {
  616. // "packageName": {
  617. // "description": "The package name of the application for which this subscription was purchased (for example, 'com.some.thing').",
  618. // "location": "path",
  619. // "required": true,
  620. // "type": "string"
  621. // },
  622. // "subscriptionId": {
  623. // "description": "The purchased subscription ID (for example, 'monthly001').",
  624. // "location": "path",
  625. // "required": true,
  626. // "type": "string"
  627. // },
  628. // "token": {
  629. // "description": "The token provided to the user's device when the subscription was purchased.",
  630. // "location": "path",
  631. // "required": true,
  632. // "type": "string"
  633. // }
  634. // },
  635. // "path": "{packageName}/subscriptions/{subscriptionId}/purchases/{token}",
  636. // "response": {
  637. // "$ref": "SubscriptionPurchase"
  638. // },
  639. // "scopes": [
  640. // "https://www.googleapis.com/auth/androidpublisher"
  641. // ]
  642. // }
  643. }