purchaseOffering method

Future<PurchaseOfferingResponse> purchaseOffering({
  1. required int count,
  2. required String offeringId,
  3. String? name,
  4. String? requestId,
  5. String? start,
  6. Map<String, String>? tags,
})

Purchase an offering and create a reservation.

May throw BadRequestException. May throw InternalServerErrorException. May throw ForbiddenException. May throw BadGatewayException. May throw NotFoundException. May throw GatewayTimeoutException. May throw TooManyRequestsException. May throw ConflictException.

Parameter count : Number of resources

Parameter offeringId : Offering to purchase, e.g. '87654321'

Parameter name : Name for the new reservation

Parameter requestId : Unique request ID to be specified. This is needed to prevent retries from creating multiple resources.

Parameter start : Requested reservation start time (UTC) in ISO-8601 format. The specified time must be between the first day of the current month and one year from now. If no value is given, the default is now.

Parameter tags : A collection of key-value pairs

Implementation

Future<PurchaseOfferingResponse> purchaseOffering({
  required int count,
  required String offeringId,
  String? name,
  String? requestId,
  String? start,
  Map<String, String>? tags,
}) async {
  ArgumentError.checkNotNull(count, 'count');
  _s.validateNumRange(
    'count',
    count,
    1,
    1152921504606846976,
    isRequired: true,
  );
  ArgumentError.checkNotNull(offeringId, 'offeringId');
  final $payload = <String, dynamic>{
    'count': count,
    if (name != null) 'name': name,
    'requestId': requestId ?? _s.generateIdempotencyToken(),
    if (start != null) 'start': start,
    if (tags != null) 'tags': tags,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/prod/offerings/${Uri.encodeComponent(offeringId)}/purchase',
    exceptionFnMap: _exceptionFns,
  );
  return PurchaseOfferingResponse.fromJson(response);
}