analyzeExpense method

Future<AnalyzeExpenseResponse> analyzeExpense({
  1. required Document document,
})

AnalyzeExpense synchronously analyzes an input document for financially related relationships between text.

Information is returned as ExpenseDocuments and seperated as follows:

  • LineItemGroups- A data set containing LineItems which store information about the lines of text, such as an item purchased and its price on a receipt.
  • SummaryFields- Contains all other information a receipt, such as header information or the vendors name.

May throw AccessDeniedException. May throw BadDocumentException. May throw DocumentTooLargeException. May throw InternalServerError. May throw InvalidParameterException. May throw InvalidS3ObjectException. May throw ProvisionedThroughputExceededException. May throw ThrottlingException. May throw UnsupportedDocumentException.

Implementation

Future<AnalyzeExpenseResponse> analyzeExpense({
  required Document document,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Textract.AnalyzeExpense'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Document': document,
    },
  );

  return AnalyzeExpenseResponse.fromJson(jsonResponse.body);
}