createCapability method

Future<CreateCapabilityResponse> createCapability({
  1. required CapabilityConfiguration configuration,
  2. required String name,
  3. required CapabilityType type,
  4. String? clientToken,
  5. List<S3Location>? instructionsDocuments,
  6. List<Tag>? tags,
})

Instantiates a capability based on the specified parameters. A trading capability contains the information required to transform incoming EDI documents into JSON or XML outputs.

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

Parameter configuration : Specifies a structure that contains the details for a capability.

Parameter name : Specifies the name of the capability, used to identify it.

Parameter type : Specifies the type of the capability. Currently, only edi is supported.

Parameter clientToken : Reserved for future use.

Parameter instructionsDocuments : Specifies one or more locations in Amazon S3, each specifying an EDI document that can be used with this capability. Each item contains the name of the bucket and the key, to identify the document's location.

Parameter tags : Specifies the key-value pairs assigned to ARNs that you can use to group and search for resources by type. You can attach this metadata to resources (capabilities, partnerships, and so on) for any purpose.

Implementation

Future<CreateCapabilityResponse> createCapability({
  required CapabilityConfiguration configuration,
  required String name,
  required CapabilityType type,
  String? clientToken,
  List<S3Location>? instructionsDocuments,
  List<Tag>? tags,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'B2BI.CreateCapability'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'configuration': configuration,
      'name': name,
      'type': type.value,
      'clientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (instructionsDocuments != null)
        'instructionsDocuments': instructionsDocuments,
      if (tags != null) 'tags': tags,
    },
  );

  return CreateCapabilityResponse.fromJson(jsonResponse.body);
}