readECheck method

Future<ECheck> readECheck({
  1. required String echeckId,
  2. String? realmId,
  3. String? authToken,
})

Retrieves the details of an echeck transaction that has been previously created. Supply the id as returned in the echecks response body from the previous create operation.

Implementation

Future<ECheck> readECheck({
  required String echeckId,
  String? realmId,
  String? authToken,
}) async {
  authToken ??= authenticationService.getCachedToken()?.access_token;
  realmId ??= authenticationService.getCachedRealmId();

  Map<String, String> headers = {
    "Authorization": "Bearer ${authToken ?? ""}",
    'Content-Type': 'application/json',
    //'Accept': 'application/json',
  };

  Uri endpoint =
  Uri.https(baseUrl, "/quickbooks/v4/payments/echecks/$echeckId");

  //print(endpoint.toString());

  var response = await http.get(
    endpoint,
    headers: headers,
  );

  if (response.statusCode == 200) {
    return ECheck.fromJson(jsonDecode(response.body));
  } else {
    throw ECheckException(
        statusCode: response.statusCode, message: response.body);
  }
}