create method

Future<SubscriptionOffer> create(
  1. SubscriptionOffer request,
  2. String packageName,
  3. String productId,
  4. String basePlanId, {
  5. String? offerId,
  6. String? regionsVersion_version,
  7. String? $fields,
})

Creates a new subscription offer.

Only auto-renewing base plans can have subscription offers. The offer state will be DRAFT until it is activated.

request - The metadata request object.

Request parameters:

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

productId - Required. The parent subscription (ID) for which the offer should be created. Must be equal to the product_id field on the SubscriptionOffer resource.

basePlanId - Required. The parent base plan (ID) for which the offer should be created. Must be equal to the base_plan_id field on the SubscriptionOffer resource.

offerId - Required. The ID to use for the offer. For the requirements on this format, see the documentation of the offer_id field on the SubscriptionOffer 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 SubscriptionOffer.

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<SubscriptionOffer> create(
  SubscriptionOffer request,
  core.String packageName,
  core.String productId,
  core.String basePlanId, {
  core.String? offerId,
  core.String? regionsVersion_version,
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if (offerId != null) 'offerId': [offerId],
    if (regionsVersion_version != null)
      'regionsVersion.version': [regionsVersion_version],
    if ($fields != null) 'fields': [$fields],
  };

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

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