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