createInvoiceUnit method

Future<CreateInvoiceUnitResponse> createInvoiceUnit({
  1. required String invoiceReceiver,
  2. required String name,
  3. required InvoiceUnitRule rule,
  4. String? clientToken,
  5. String? description,
  6. List<ResourceTag>? resourceTags,
  7. bool? taxInheritanceDisabled,
})

This creates a new invoice unit with the provided definition.

May throw AccessDeniedException. May throw InternalServerException. May throw ThrottlingException. May throw ValidationException.

Parameter invoiceReceiver : The Amazon Web Services account ID chosen to be the receiver of an invoice unit. All invoices generated for that invoice unit will be sent to this account ID.

Parameter name : The unique name of the invoice unit that is shown on the generated invoice. This can't be changed once it is set. To change this name, you must delete the invoice unit recreate.

Parameter rule : The InvoiceUnitRule object used to create invoice units.

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

Parameter description : The invoice unit's description. This can be changed at a later time.

Parameter resourceTags : The tag structure that contains a tag key and value.

Parameter taxInheritanceDisabled : Whether the invoice unit based tax inheritance is/ should be enabled or disabled.

Implementation

Future<CreateInvoiceUnitResponse> createInvoiceUnit({
  required String invoiceReceiver,
  required String name,
  required InvoiceUnitRule rule,
  String? clientToken,
  String? description,
  List<ResourceTag>? resourceTags,
  bool? taxInheritanceDisabled,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.0',
    'X-Amz-Target': 'Invoicing.CreateInvoiceUnit'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'InvoiceReceiver': invoiceReceiver,
      'Name': name,
      'Rule': rule,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (description != null) 'Description': description,
      if (resourceTags != null) 'ResourceTags': resourceTags,
      if (taxInheritanceDisabled != null)
        'TaxInheritanceDisabled': taxInheritanceDisabled,
    },
  );

  return CreateInvoiceUnitResponse.fromJson(jsonResponse.body);
}