sendAgreementCancellationRequest method

Future<SendAgreementCancellationRequestOutput> sendAgreementCancellationRequest({
  1. required String agreementId,
  2. required AgreementCancellationRequestReasonCode reasonCode,
  3. String? clientToken,
  4. String? description,
})

Allows sellers (proposers) to submit a cancellation request for an active agreement. The cancellation request is created in PENDING_APPROVAL status, at which point the buyer can review it.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ValidationException.

Parameter agreementId : The unique identifier of the agreement for which the cancellation request is being submitted.

Parameter reasonCode : The reason code for the cancellation request.

Parameter clientToken : A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.

Parameter description : An optional detailed description of the cancellation reason (1-2000 characters).

Implementation

Future<SendAgreementCancellationRequestOutput>
    sendAgreementCancellationRequest({
  required String agreementId,
  required AgreementCancellationRequestReasonCode reasonCode,
  String? clientToken,
  String? description,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target':
        'AWSMPCommerceService_v20200301.SendAgreementCancellationRequest'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'agreementId': agreementId,
      'reasonCode': reasonCode.value,
      'clientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (description != null) 'description': description,
    },
  );

  return SendAgreementCancellationRequestOutput.fromJson(jsonResponse.body);
}