getCreditMemoPdf method

Future<String> getCreditMemoPdf(
  1. String creditMemoId
)

Get credit memo PDF

Implementation

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

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