voidInvoice method

Future<InvoiceObject> voidInvoice({
  1. required String code,
})

TODO: Figure out how to get this API to work it is not working even when you try using curl requests on PostMan This function receives an Invoice code argument and voids the invoice Returning an InvoiceObject with null parameters

Implementation

Future<InvoiceObject> voidInvoice({required String code}) async {
  InvoiceObject coinbaseResponse;
  Map data;
  Map response = await postToDB(
      api: 'https://api.commerce.coinbase.com/invoices/$code/void',
      apiKey: _apiKey,
      body: {});

  if (response.containsKey('error')) {
    data = response['error'];
  } else {
    data = response['data'];
  }

  ///Cast an [InvoiceObject] from the returned Map
  coinbaseResponse = InvoiceObject.fromJson(data);
  Logger(debug).displayLog(coinbaseResponse.toString());
  return coinbaseResponse;
}