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\Reseller\Resource;
19
20use Google\Service\Reseller\ChangePlanRequest;
21use Google\Service\Reseller\RenewalSettings;
22use Google\Service\Reseller\Seats;
23use Google\Service\Reseller\Subscription;
24use Google\Service\Reseller\Subscriptions as SubscriptionsModel;
25
26/**
27 * The "subscriptions" collection of methods.
28 * Typical usage is:
29 *  <code>
30 *   $resellerService = new Google\Service\Reseller(...);
31 *   $subscriptions = $resellerService->subscriptions;
32 *  </code>
33 */
34class Subscriptions extends \Google\Service\Resource
35{
36  /**
37   * Activates a subscription previously suspended by the reseller. If you did not
38   * suspend the customer subscription and it is suspended for any other reason,
39   * such as for abuse or a pending ToS acceptance, this call will not reactivate
40   * the customer subscription. (subscriptions.activate)
41   *
42   * @param string $customerId This can be either the customer's primary domain
43   * name or the customer's unique identifier. If the domain name for a customer
44   * changes, the old domain name cannot be used to access the customer, but the
45   * customer's unique identifier (as returned by the API) can always be used. We
46   * recommend storing the unique identifier in your systems where applicable.
47   * @param string $subscriptionId This is a required property. The
48   * `subscriptionId` is the subscription identifier and is unique for each
49   * customer. Since a `subscriptionId` changes when a subscription is updated, we
50   * recommend to not use this ID as a key for persistent data. And the
51   * `subscriptionId` can be found using the retrieve all reseller subscriptions
52   * method.
53   * @param array $optParams Optional parameters.
54   * @return Subscription
55   */
56  public function activate($customerId, $subscriptionId, $optParams = [])
57  {
58    $params = ['customerId' => $customerId, 'subscriptionId' => $subscriptionId];
59    $params = array_merge($params, $optParams);
60    return $this->call('activate', [$params], Subscription::class);
61  }
62  /**
63   * Updates a subscription plan. Use this method to update a plan for a 30-day
64   * trial or a flexible plan subscription to an annual commitment plan with
65   * monthly or yearly payments. How a plan is updated differs depending on the
66   * plan and the products. For more information, see the description in [manage
67   * subscriptions](/admin-sdk/reseller/v1/how-
68   * tos/manage_subscriptions#update_subscription_plan).
69   * (subscriptions.changePlan)
70   *
71   * @param string $customerId This can be either the customer's primary domain
72   * name or the customer's unique identifier. If the domain name for a customer
73   * changes, the old domain name cannot be used to access the customer, but the
74   * customer's unique identifier (as returned by the API) can always be used. We
75   * recommend storing the unique identifier in your systems where applicable.
76   * @param string $subscriptionId This is a required property. The
77   * `subscriptionId` is the subscription identifier and is unique for each
78   * customer. Since a `subscriptionId` changes when a subscription is updated, we
79   * recommend to not use this ID as a key for persistent data. And the
80   * `subscriptionId` can be found using the retrieve all reseller subscriptions
81   * method.
82   * @param ChangePlanRequest $postBody
83   * @param array $optParams Optional parameters.
84   * @return Subscription
85   */
86  public function changePlan($customerId, $subscriptionId, ChangePlanRequest $postBody, $optParams = [])
87  {
88    $params = ['customerId' => $customerId, 'subscriptionId' => $subscriptionId, 'postBody' => $postBody];
89    $params = array_merge($params, $optParams);
90    return $this->call('changePlan', [$params], Subscription::class);
91  }
92  /**
93   * Updates a user license's renewal settings. This is applicable for accounts
94   * with annual commitment plans only. For more information, see the description
95   * in [manage subscriptions](/admin-sdk/reseller/v1/how-
96   * tos/manage_subscriptions#update_renewal).
97   * (subscriptions.changeRenewalSettings)
98   *
99   * @param string $customerId This can be either the customer's primary domain
100   * name or the customer's unique identifier. If the domain name for a customer
101   * changes, the old domain name cannot be used to access the customer, but the
102   * customer's unique identifier (as returned by the API) can always be used. We
103   * recommend storing the unique identifier in your systems where applicable.
104   * @param string $subscriptionId This is a required property. The
105   * `subscriptionId` is the subscription identifier and is unique for each
106   * customer. Since a `subscriptionId` changes when a subscription is updated, we
107   * recommend to not use this ID as a key for persistent data. And the
108   * `subscriptionId` can be found using the retrieve all reseller subscriptions
109   * method.
110   * @param RenewalSettings $postBody
111   * @param array $optParams Optional parameters.
112   * @return Subscription
113   */
114  public function changeRenewalSettings($customerId, $subscriptionId, RenewalSettings $postBody, $optParams = [])
115  {
116    $params = ['customerId' => $customerId, 'subscriptionId' => $subscriptionId, 'postBody' => $postBody];
117    $params = array_merge($params, $optParams);
118    return $this->call('changeRenewalSettings', [$params], Subscription::class);
119  }
120  /**
121   * Updates a subscription's user license settings. For more information about
122   * updating an annual commitment plan or a flexible plan subscription’s
123   * licenses, see [Manage Subscriptions](/admin-sdk/reseller/v1/how-
124   * tos/manage_subscriptions#update_subscription_seat).
125   * (subscriptions.changeSeats)
126   *
127   * @param string $customerId This can be either the customer's primary domain
128   * name or the customer's unique identifier. If the domain name for a customer
129   * changes, the old domain name cannot be used to access the customer, but the
130   * customer's unique identifier (as returned by the API) can always be used. We
131   * recommend storing the unique identifier in your systems where applicable.
132   * @param string $subscriptionId This is a required property. The
133   * `subscriptionId` is the subscription identifier and is unique for each
134   * customer. Since a `subscriptionId` changes when a subscription is updated, we
135   * recommend to not use this ID as a key for persistent data. And the
136   * `subscriptionId` can be found using the retrieve all reseller subscriptions
137   * method.
138   * @param Seats $postBody
139   * @param array $optParams Optional parameters.
140   * @return Subscription
141   */
142  public function changeSeats($customerId, $subscriptionId, Seats $postBody, $optParams = [])
143  {
144    $params = ['customerId' => $customerId, 'subscriptionId' => $subscriptionId, 'postBody' => $postBody];
145    $params = array_merge($params, $optParams);
146    return $this->call('changeSeats', [$params], Subscription::class);
147  }
148  /**
149   * Cancels, suspends, or transfers a subscription to direct.
150   * (subscriptions.delete)
151   *
152   * @param string $customerId This can be either the customer's primary domain
153   * name or the customer's unique identifier. If the domain name for a customer
154   * changes, the old domain name cannot be used to access the customer, but the
155   * customer's unique identifier (as returned by the API) can always be used. We
156   * recommend storing the unique identifier in your systems where applicable.
157   * @param string $subscriptionId This is a required property. The
158   * `subscriptionId` is the subscription identifier and is unique for each
159   * customer. Since a `subscriptionId` changes when a subscription is updated, we
160   * recommend to not use this ID as a key for persistent data. And the
161   * `subscriptionId` can be found using the retrieve all reseller subscriptions
162   * method.
163   * @param string $deletionType The `deletionType` query string enables the
164   * cancellation, downgrade, or suspension of a subscription.
165   * @param array $optParams Optional parameters.
166   */
167  public function delete($customerId, $subscriptionId, $deletionType, $optParams = [])
168  {
169    $params = ['customerId' => $customerId, 'subscriptionId' => $subscriptionId, 'deletionType' => $deletionType];
170    $params = array_merge($params, $optParams);
171    return $this->call('delete', [$params]);
172  }
173  /**
174   * Gets a specific subscription. The `subscriptionId` can be found using the
175   * [Retrieve all reseller subscriptions](/admin-sdk/reseller/v1/how-
176   * tos/manage_subscriptions#get_all_subscriptions) method. For more information
177   * about retrieving a specific subscription, see the information descrived in
178   * [manage subscriptions](/admin-sdk/reseller/v1/how-
179   * tos/manage_subscriptions#get_subscription). (subscriptions.get)
180   *
181   * @param string $customerId This can be either the customer's primary domain
182   * name or the customer's unique identifier. If the domain name for a customer
183   * changes, the old domain name cannot be used to access the customer, but the
184   * customer's unique identifier (as returned by the API) can always be used. We
185   * recommend storing the unique identifier in your systems where applicable.
186   * @param string $subscriptionId This is a required property. The
187   * `subscriptionId` is the subscription identifier and is unique for each
188   * customer. Since a `subscriptionId` changes when a subscription is updated, we
189   * recommend to not use this ID as a key for persistent data. And the
190   * `subscriptionId` can be found using the retrieve all reseller subscriptions
191   * method.
192   * @param array $optParams Optional parameters.
193   * @return Subscription
194   */
195  public function get($customerId, $subscriptionId, $optParams = [])
196  {
197    $params = ['customerId' => $customerId, 'subscriptionId' => $subscriptionId];
198    $params = array_merge($params, $optParams);
199    return $this->call('get', [$params], Subscription::class);
200  }
201  /**
202   * Creates or transfer a subscription. Create a subscription for a customer's
203   * account that you ordered using the [Order a new customer account](/admin-
204   * sdk/reseller/v1/reference/customers/insert.html) method. For more information
205   * about creating a subscription for different payment plans, see [manage
206   * subscriptions](/admin-sdk/reseller/v1/how-
207   * tos/manage_subscriptions#create_subscription).\ If you did not order the
208   * customer's account using the customer insert method, use the customer's
209   * `customerAuthToken` when creating a subscription for that customer. If
210   * transferring a G Suite subscription with an associated Google Drive or Google
211   * Vault subscription, use the [batch operation](/admin-sdk/reseller/v1/how-
212   * tos/batch.html) to transfer all of these subscriptions. For more information,
213   * see how to [transfer subscriptions](/admin-sdk/reseller/v1/how-
214   * tos/manage_subscriptions#transfer_a_subscription). (subscriptions.insert)
215   *
216   * @param string $customerId This can be either the customer's primary domain
217   * name or the customer's unique identifier. If the domain name for a customer
218   * changes, the old domain name cannot be used to access the customer, but the
219   * customer's unique identifier (as returned by the API) can always be used. We
220   * recommend storing the unique identifier in your systems where applicable.
221   * @param Subscription $postBody
222   * @param array $optParams Optional parameters.
223   *
224   * @opt_param string customerAuthToken The `customerAuthToken` query string is
225   * required when creating a resold account that transfers a direct customer's
226   * subscription or transfers another reseller customer's subscription to your
227   * reseller management. This is a hexadecimal authentication token needed to
228   * complete the subscription transfer. For more information, see the
229   * administrator help center.
230   * @return Subscription
231   */
232  public function insert($customerId, Subscription $postBody, $optParams = [])
233  {
234    $params = ['customerId' => $customerId, 'postBody' => $postBody];
235    $params = array_merge($params, $optParams);
236    return $this->call('insert', [$params], Subscription::class);
237  }
238  /**
239   * Lists of subscriptions managed by the reseller. The list can be all
240   * subscriptions, all of a customer's subscriptions, or all of a customer's
241   * transferable subscriptions. Optionally, this method can filter the response
242   * by a `customerNamePrefix`. For more information, see [manage subscriptions
243   * ](/admin-sdk/reseller/v1/how-tos/manage_subscriptions).
244   * (subscriptions.listSubscriptions)
245   *
246   * @param array $optParams Optional parameters.
247   *
248   * @opt_param string customerAuthToken The `customerAuthToken` query string is
249   * required when creating a resold account that transfers a direct customer's
250   * subscription or transfers another reseller customer's subscription to your
251   * reseller management. This is a hexadecimal authentication token needed to
252   * complete the subscription transfer. For more information, see the
253   * administrator help center.
254   * @opt_param string customerId This can be either the customer's primary domain
255   * name or the customer's unique identifier. If the domain name for a customer
256   * changes, the old domain name cannot be used to access the customer, but the
257   * customer's unique identifier (as returned by the API) can always be used. We
258   * recommend storing the unique identifier in your systems where applicable.
259   * @opt_param string customerNamePrefix When retrieving all of your
260   * subscriptions and filtering for specific customers, you can enter a prefix
261   * for a customer name. Using an example customer group that includes
262   * `exam.com`, `example20.com` and `example.com`: - `exa` -- Returns all
263   * customer names that start with 'exa' which could include `exam.com`,
264   * `example20.com`, and `example.com`. A name prefix is similar to using a
265   * regular expression's asterisk, exa*. - `example` -- Returns `example20.com`
266   * and `example.com`.
267   * @opt_param string maxResults When retrieving a large list, the `maxResults`
268   * is the maximum number of results per page. The `nextPageToken` value takes
269   * you to the next page. The default is 20.
270   * @opt_param string pageToken Token to specify next page in the list
271   * @return SubscriptionsModel
272   */
273  public function listSubscriptions($optParams = [])
274  {
275    $params = [];
276    $params = array_merge($params, $optParams);
277    return $this->call('list', [$params], SubscriptionsModel::class);
278  }
279  /**
280   * Immediately move a 30-day free trial subscription to a paid service
281   * subscription. This method is only applicable if a payment plan has already
282   * been set up for the 30-day trial subscription. For more information, see
283   * [manage subscriptions](/admin-sdk/reseller/v1/how-
284   * tos/manage_subscriptions#paid_service). (subscriptions.startPaidService)
285   *
286   * @param string $customerId This can be either the customer's primary domain
287   * name or the customer's unique identifier. If the domain name for a customer
288   * changes, the old domain name cannot be used to access the customer, but the
289   * customer's unique identifier (as returned by the API) can always be used. We
290   * recommend storing the unique identifier in your systems where applicable.
291   * @param string $subscriptionId This is a required property. The
292   * `subscriptionId` is the subscription identifier and is unique for each
293   * customer. Since a `subscriptionId` changes when a subscription is updated, we
294   * recommend to not use this ID as a key for persistent data. And the
295   * `subscriptionId` can be found using the retrieve all reseller subscriptions
296   * method.
297   * @param array $optParams Optional parameters.
298   * @return Subscription
299   */
300  public function startPaidService($customerId, $subscriptionId, $optParams = [])
301  {
302    $params = ['customerId' => $customerId, 'subscriptionId' => $subscriptionId];
303    $params = array_merge($params, $optParams);
304    return $this->call('startPaidService', [$params], Subscription::class);
305  }
306  /**
307   * Suspends an active subscription. You can use this method to suspend a paid
308   * subscription that is currently in the `ACTIVE` state. * For `FLEXIBLE`
309   * subscriptions, billing is paused. * For `ANNUAL_MONTHLY_PAY` or
310   * `ANNUAL_YEARLY_PAY` subscriptions: * Suspending the subscription does not
311   * change the renewal date that was originally committed to. * A suspended
312   * subscription does not renew. If you activate the subscription after the
313   * original renewal date, a new annual subscription will be created, starting on
314   * the day of activation. We strongly encourage you to suspend subscriptions
315   * only for short periods of time as suspensions over 60 days may result in the
316   * subscription being cancelled. (subscriptions.suspend)
317   *
318   * @param string $customerId This can be either the customer's primary domain
319   * name or the customer's unique identifier. If the domain name for a customer
320   * changes, the old domain name cannot be used to access the customer, but the
321   * customer's unique identifier (as returned by the API) can always be used. We
322   * recommend storing the unique identifier in your systems where applicable.
323   * @param string $subscriptionId This is a required property. The
324   * `subscriptionId` is the subscription identifier and is unique for each
325   * customer. Since a `subscriptionId` changes when a subscription is updated, we
326   * recommend to not use this ID as a key for persistent data. And the
327   * `subscriptionId` can be found using the retrieve all reseller subscriptions
328   * method.
329   * @param array $optParams Optional parameters.
330   * @return Subscription
331   */
332  public function suspend($customerId, $subscriptionId, $optParams = [])
333  {
334    $params = ['customerId' => $customerId, 'subscriptionId' => $subscriptionId];
335    $params = array_merge($params, $optParams);
336    return $this->call('suspend', [$params], Subscription::class);
337  }
338}
339
340// Adding a class alias for backwards compatibility with the previous class name.
341class_alias(Subscriptions::class, 'Google_Service_Reseller_Resource_Subscriptions');
342