create method

Future<Subscription> create(
  1. Subscription request,
  2. String packageName, {
  3. String? productId,
  4. String? regionsVersion_version,
  5. String? $fields,
})

Creates a new subscription.

Newly added base plans will remain in draft state until activated.

request - The metadata request object.

Request parameters:

packageName - Required. The parent app (package name) for which the subscription should be created. Must be equal to the package_name field on the Subscription resource.

productId - Required. The ID to use for the subscription. For the requirements on this format, see the documentation of the product_id field on the Subscription resource.

regionsVersion_version - Required. A string representing the version of available regions being used for the specified resource. Regional prices for the resource have to be specified according to the information published in this article. Each time the supported locations substantially change, the version will be incremented. Using this field will ensure that creating and updating the resource with an older region's version and set of regional prices and currencies will succeed even though a new version is available. The latest version is 2022/02.

$fields - Selector specifying which fields to include in a partial response.

Completes with a Subscription.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<Subscription> create(
  Subscription request,
  core.String packageName, {
  core.String? productId,
  core.String? regionsVersion_version,
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if (productId != null) 'productId': [productId],
    if (regionsVersion_version != null)
      'regionsVersion.version': [regionsVersion_version],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'androidpublisher/v3/applications/' +
      commons.escapeVariable('$packageName') +
      '/subscriptions';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return Subscription.fromJson(
      response_ as core.Map<core.String, core.dynamic>);
}