convertCurrency method

Future<Conversion> convertCurrency({
  1. String? profileId,
  2. required String from,
  3. required String to,
  4. required double amount,
  5. String? nonce,
})

Convert a currency

Converts funds from from currency to to currency. Funds are converted on the from account in the profile_id profile.

https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_postconversion

Implementation

Future<Conversion> convertCurrency({
  String? profileId,
  required String from,
  required String to,
  required double amount,
  String? nonce,
}) async {
  var response = await _conversionsRestClient.convertCurrency(
    profileId: profileId,
    from: from,
    to: to,
    amount: amount,
    nonce: nonce,
  );

  if (response.statusCode != 200) throw response;

  return Conversion.fromJson(mapDecode(response.body));
}