createAgreementRequest method

Future<CreateAgreementRequestOutput> createAgreementRequest({
  1. required Intent intent,
  2. required List<RequestedTerm> requestedTerms,
  3. String? agreementProposalIdentifier,
  4. String? clientToken,
  5. String? sourceAgreementIdentifier,
  6. TaxConfiguration? taxConfiguration,
})

Creates an agreement request that acts as a quote for the terms you want to accept. The agreement request captures the requested terms, calculates charges, and returns a summary. Use AcceptAgreementRequest with the returned agreementRequestId to finalize the agreement.

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

Parameter intent : The purpose and desired outcome of the agreement request. This is a required parameter that determines how the agreement request is processed.

  • NEW – Creates a new agreement for terms in the request.
  • AMEND – Modifies an existing agreement with terms that are accepted in the request.
  • REPLACE – Creates a new agreement with accepted terms and replaces the existing agreement.

Parameter requestedTerms : A list of terms that define what is being accepted as part of the agreement. Some terms require configuration.

Parameter agreementProposalIdentifier : The agreement proposal signed by the proposer. The proposal includes the requested resources and the terms that outline an agreement outcome.

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

Parameter sourceAgreementIdentifier : The agreement's identifier that the request acts upon.

Parameter taxConfiguration : Configuration for tax estimation in the agreement request response.

Implementation

Future<CreateAgreementRequestOutput> createAgreementRequest({
  required Intent intent,
  required List<RequestedTerm> requestedTerms,
  String? agreementProposalIdentifier,
  String? clientToken,
  String? sourceAgreementIdentifier,
  TaxConfiguration? taxConfiguration,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'AWSMPCommerceService_v20200301.CreateAgreementRequest'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'intent': intent.value,
      'requestedTerms': requestedTerms,
      if (agreementProposalIdentifier != null)
        'agreementProposalIdentifier': agreementProposalIdentifier,
      'clientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (sourceAgreementIdentifier != null)
        'sourceAgreementIdentifier': sourceAgreementIdentifier,
      if (taxConfiguration != null) 'taxConfiguration': taxConfiguration,
    },
  );

  return CreateAgreementRequestOutput.fromJson(jsonResponse.body);
}