walletsTransfer method
- String idempotencyKey, {
- WalletTransferRequest? walletTransferRequest,
- Future<
void> ? abortTrigger,
Transfer between wallets
Moves funds from one of the partner's wallets to another, converting between their currencies. amount is in the source wallet's currency and is rounded to two decimals. The destination receives the amount converted at the current rate, rounded to two decimals. Returns the transferId, the sent and received amounts and currencies, the conversionRate and the transferDate. Both wallets record an exchange transaction. The two wallets must differ, and the amount must be above zero; otherwise, or when the source balance is too low, the call returns 400 with code 10001. An unknown wallet returns 404 with code 10004. Requires an Idempotency-Key header (a UUID). Repeating a completed transfer with the same key returns 409 with code 12000 (IDEMPOTENCY_KEY_ALREADY_USED) and moves no money; one still running returns 409 with code 12002, and a different body with the same key 409 with code 12001. A request that ended in an error can be sent again with the same key and body.
Parameters:
-
String idempotencyKey (required): UUID idempotency key for safe retries of this operation.
-
WalletTransferRequest walletTransferRequest: The source wallet, destination wallet and amount.
Implementation
Future<WalletTransfer?> walletsTransfer(String idempotencyKey, { WalletTransferRequest? walletTransferRequest, Future<void>? abortTrigger, }) async {
final response = await walletsTransferWithHttpInfo(idempotencyKey, walletTransferRequest: walletTransferRequest, abortTrigger: abortTrigger,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'WalletTransfer',) as WalletTransfer;
}
return null;
}