convertCurrency method

Future<Response> 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<http.Response> convertCurrency({
  String? profileId,
  required String from,
  required String to,
  required double amount,
  String? nonce,
}) async {
  Map<String, String> body = {
    'from': from,
    'to': to,
    'amount': amount.toString(),
  };
  if (profileId != null) body['profile_id'] = profileId;
  if (nonce != null) body['nonce'] = nonce;

  return post(
    path: '/conversions',
    body: body,
  );
}