createStarterMappingTemplate method

Future<CreateStarterMappingTemplateResponse> createStarterMappingTemplate({
  1. required MappingType mappingType,
  2. required TemplateDetails templateDetails,
  3. S3Location? outputSampleLocation,
})

Amazon Web Services B2B Data Interchange uses a mapping template in JSONata or XSLT format to transform a customer input file into a JSON or XML file that can be converted to EDI.

If you provide a sample EDI file with the same structure as the EDI files that you wish to generate, then the service can generate a mapping template. The starter template contains placeholder values which you can replace with JSONata or XSLT expressions to take data from your input file and insert it into the JSON or XML file that is used to generate the EDI.

If you do not provide a sample EDI file, then the service can generate a mapping template based on the EDI settings in the templateDetails parameter.

Currently, we only support generating a template that can generate the input to produce an Outbound X12 EDI file.

May throw AccessDeniedException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ValidationException.

Parameter mappingType : Specify the format for the mapping template: either JSONATA or XSLT.

Parameter templateDetails : Describes the details needed for generating the template. Specify the X12 transaction set and version for which the template is used: currently, we only support X12.

Parameter outputSampleLocation : Specify the location of the sample EDI file that is used to generate the mapping template.

Implementation

Future<CreateStarterMappingTemplateResponse> createStarterMappingTemplate({
  required MappingType mappingType,
  required TemplateDetails templateDetails,
  S3Location? outputSampleLocation,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'B2BI.CreateStarterMappingTemplate'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'mappingType': mappingType.value,
      'templateDetails': templateDetails,
      if (outputSampleLocation != null)
        'outputSampleLocation': outputSampleLocation,
    },
  );

  return CreateStarterMappingTemplateResponse.fromJson(jsonResponse.body);
}