getInvoicePdf method

Future<String> getInvoicePdf(
  1. String invoiceId
)

Get invoice PDF

Implementation

Future<String> getInvoicePdf(String invoiceId) async {
  try {
    final response = await _client.authenticatedRequest<String>(
      '/rest/V1/invoices/$invoiceId/pdf',
      options: Options(responseType: ResponseType.plain),
    );

    if (response.statusCode == 200) {
      return response.data!;
    } else {
      throw Exception('Failed to get invoice PDF: ${response.statusMessage}');
    }
  } on DioException catch (e) {
    throw Exception('Failed to get invoice PDF: ${e.message}');
  } catch (e) {
    throw Exception('Failed to get invoice PDF: $e');
  }
}