insertPage method

Future<Map<String, dynamic>> insertPage(
  1. String host,
  2. String docId,
  3. Map<String, dynamic> parameters
)

Insert a page into a document.

host - The host server URL. docId - The ID of the document. parameters - The parameters for the page insertion.

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

Implementation

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