getCustomerCards method

Future<GetCustomerCardsResponse> getCustomerCards(
  1. String customerToken,
  2. String query
)

Implementation

Future<GetCustomerCardsResponse> getCustomerCards(String customerToken, String query) async {
  try {
    _client = MyHttpClient(baseUrlTonder);
    Response? response = await _client?.get(
        Uri.parse('api/v1/cards/$query'),
        headers: {
          'Content-Type': 'application/json',
          'Authorization': 'Token $customerToken'
        }
    );

    if (response!.statusCode >= 200 ||response.statusCode < 300) {
      final jsonResponse = json.decode(response.body) as Map<String, dynamic>;
      return GetCustomerCardsResponse.fromJson(jsonResponse);
    } else {
      throw Exception(response.statusCode);
    }
  } catch (e) {
    throw Exception(e);
  }
}