1<?php
2/*
3 * Copyright 2014 Google Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy of
7 * the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17
18namespace Google\Service\AndroidPublisher\Resource;
19
20use Google\Service\AndroidPublisher\SubscriptionPurchase;
21use Google\Service\AndroidPublisher\SubscriptionPurchasesAcknowledgeRequest;
22use Google\Service\AndroidPublisher\SubscriptionPurchasesDeferRequest;
23use Google\Service\AndroidPublisher\SubscriptionPurchasesDeferResponse;
24
25/**
26 * The "subscriptions" collection of methods.
27 * Typical usage is:
28 *  <code>
29 *   $androidpublisherService = new Google\Service\AndroidPublisher(...);
30 *   $subscriptions = $androidpublisherService->subscriptions;
31 *  </code>
32 */
33class PurchasesSubscriptions extends \Google\Service\Resource
34{
35  /**
36   * Acknowledges a subscription purchase. (subscriptions.acknowledge)
37   *
38   * @param string $packageName The package name of the application for which this
39   * subscription was purchased (for example, 'com.some.thing').
40   * @param string $subscriptionId The purchased subscription ID (for example,
41   * 'monthly001').
42   * @param string $token The token provided to the user's device when the
43   * subscription was purchased.
44   * @param SubscriptionPurchasesAcknowledgeRequest $postBody
45   * @param array $optParams Optional parameters.
46   */
47  public function acknowledge($packageName, $subscriptionId, $token, SubscriptionPurchasesAcknowledgeRequest $postBody, $optParams = [])
48  {
49    $params = ['packageName' => $packageName, 'subscriptionId' => $subscriptionId, 'token' => $token, 'postBody' => $postBody];
50    $params = array_merge($params, $optParams);
51    return $this->call('acknowledge', [$params]);
52  }
53  /**
54   * Cancels a user's subscription purchase. The subscription remains valid until
55   * its expiration time. (subscriptions.cancel)
56   *
57   * @param string $packageName The package name of the application for which this
58   * subscription was purchased (for example, 'com.some.thing').
59   * @param string $subscriptionId The purchased subscription ID (for example,
60   * 'monthly001').
61   * @param string $token The token provided to the user's device when the
62   * subscription was purchased.
63   * @param array $optParams Optional parameters.
64   */
65  public function cancel($packageName, $subscriptionId, $token, $optParams = [])
66  {
67    $params = ['packageName' => $packageName, 'subscriptionId' => $subscriptionId, 'token' => $token];
68    $params = array_merge($params, $optParams);
69    return $this->call('cancel', [$params]);
70  }
71  /**
72   * Defers a user's subscription purchase until a specified future expiration
73   * time. (subscriptions.defer)
74   *
75   * @param string $packageName The package name of the application for which this
76   * subscription was purchased (for example, 'com.some.thing').
77   * @param string $subscriptionId The purchased subscription ID (for example,
78   * 'monthly001').
79   * @param string $token The token provided to the user's device when the
80   * subscription was purchased.
81   * @param SubscriptionPurchasesDeferRequest $postBody
82   * @param array $optParams Optional parameters.
83   * @return SubscriptionPurchasesDeferResponse
84   */
85  public function defer($packageName, $subscriptionId, $token, SubscriptionPurchasesDeferRequest $postBody, $optParams = [])
86  {
87    $params = ['packageName' => $packageName, 'subscriptionId' => $subscriptionId, 'token' => $token, 'postBody' => $postBody];
88    $params = array_merge($params, $optParams);
89    return $this->call('defer', [$params], SubscriptionPurchasesDeferResponse::class);
90  }
91  /**
92   * Checks whether a user's subscription purchase is valid and returns its expiry
93   * time. (subscriptions.get)
94   *
95   * @param string $packageName The package name of the application for which this
96   * subscription was purchased (for example, 'com.some.thing').
97   * @param string $subscriptionId The purchased subscription ID (for example,
98   * 'monthly001').
99   * @param string $token The token provided to the user's device when the
100   * subscription was purchased.
101   * @param array $optParams Optional parameters.
102   * @return SubscriptionPurchase
103   */
104  public function get($packageName, $subscriptionId, $token, $optParams = [])
105  {
106    $params = ['packageName' => $packageName, 'subscriptionId' => $subscriptionId, 'token' => $token];
107    $params = array_merge($params, $optParams);
108    return $this->call('get', [$params], SubscriptionPurchase::class);
109  }
110  /**
111   * Refunds a user's subscription purchase, but the subscription remains valid
112   * until its expiration time and it will continue to recur.
113   * (subscriptions.refund)
114   *
115   * @param string $packageName The package name of the application for which this
116   * subscription was purchased (for example, 'com.some.thing').
117   * @param string $subscriptionId "The purchased subscription ID (for example,
118   * 'monthly001').
119   * @param string $token The token provided to the user's device when the
120   * subscription was purchased.
121   * @param array $optParams Optional parameters.
122   */
123  public function refund($packageName, $subscriptionId, $token, $optParams = [])
124  {
125    $params = ['packageName' => $packageName, 'subscriptionId' => $subscriptionId, 'token' => $token];
126    $params = array_merge($params, $optParams);
127    return $this->call('refund', [$params]);
128  }
129  /**
130   * Refunds and immediately revokes a user's subscription purchase. Access to the
131   * subscription will be terminated immediately and it will stop recurring.
132   * (subscriptions.revoke)
133   *
134   * @param string $packageName The package name of the application for which this
135   * subscription was purchased (for example, 'com.some.thing').
136   * @param string $subscriptionId The purchased subscription ID (for example,
137   * 'monthly001').
138   * @param string $token The token provided to the user's device when the
139   * subscription was purchased.
140   * @param array $optParams Optional parameters.
141   */
142  public function revoke($packageName, $subscriptionId, $token, $optParams = [])
143  {
144    $params = ['packageName' => $packageName, 'subscriptionId' => $subscriptionId, 'token' => $token];
145    $params = array_merge($params, $optParams);
146    return $this->call('revoke', [$params]);
147  }
148}
149
150// Adding a class alias for backwards compatibility with the previous class name.
151class_alias(PurchasesSubscriptions::class, 'Google_Service_AndroidPublisher_Resource_PurchasesSubscriptions');
152