createDocument method

Future<Map<String, dynamic>> createDocument(
  1. String host,
  2. Map<String, dynamic> parameters
)

Create a new document from scanned images.

host - The host server URL. parameters - The parameters for the document creation.

Returns a Map<String, dynamic> containing the document information.

Implementation

Future<Map<String, dynamic>> createDocument(
    String host, Map<String, dynamic> parameters) async {
  final url = '$host/api/storage/documents';
  try {
    final response = await http.post(
      Uri.parse(url),
      headers: {
        'Content-Type': 'application/json',
        'Content-Length': json.encode(parameters).length.toString()
      },
      body: json.encode(parameters),
    );
    return json.decode(response.body);
  } catch (error) {
    return {};
  }
}