getCreditMemo method

Future<CreditMemo> getCreditMemo(
  1. String creditMemoId
)

Get credit memo details

Implementation

Future<CreditMemo> getCreditMemo(String creditMemoId) async {
  try {
    final response = await _client.authenticatedRequest<Map<String, dynamic>>(
      '/rest/V1/creditmemos/$creditMemoId',
    );

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