readAllCards method
Returns a list of up to ten cards for the company specified
with the id parameter. The cards are returned in descending
order with most recent entry first. This operation cannot
retrieve cards created via the QuickBooks Online interface.
If more than 10 cards are needed, specify the number to be
retrieved using ?count=number
appended to the end of the query.
For example, /cards?count=100 would retrieve 100 cards.
Implementation
Future<List<Card>> readAllCards({
required String requestId,
required String customerId,
String? realmId,
String? authToken,
}) async {
authToken ??= authenticationService.getCachedToken()?.access_token;
realmId ??= authenticationService.getCachedRealmId();
Map<String, String> headers = {
"Request-ID": requestId,
"Authorization": "Bearer ${authToken ?? ""}",
'Content-Type': 'application/json',
//'Accept': 'application/json',
};
Uri endpoint = Uri.https(
baseUrl, "/quickbooks/v4/customers/$customerId/cards");
//print (endpoint.toString());
var response = await
http.get(endpoint, headers: headers,);
if (response.statusCode == 200) {
return (jsonDecode(response.body) as List).map((e) => Card.fromJson(e)).toList();
}
else {
throw CardException(statusCode: response.statusCode, message: response.body);
}
}