The transferBalance method in the SubAccounts class expects parameters defined by the BalanceTransferParameters type:
export type BalanceTransferParameters = {
/**
* The account ID from which the balance is transferred.
*/
from: string;
/**
* The account ID to which the balance is transferred.
*/
to: string;
/**
* The amount of balance to transfer.
*/
amount: string;
/**
* (Optional) A reference for the balance transfer.
*/
reference?: string;
};
transferBalance(params: BalanceTransferParameters): Promise<BalanceTransfer>;
Notably, the amount field is defined as a string type.
Problem
When invoking transferBalance with the amount as a string, a 422 Unprocessable Entity error is thrown :
The BalanceTransferParameters type definition for the amount field appears to be incorrect. Despite being defined as a string, it needs to be passed as a number for the request to succeed. This discrepancy should be addressed to avoid confusion and potential errors.
[AS-IS]
export type BalanceTransferParameters = {
from: string;
to: string;
amount: string;
reference?: string;
};
[TO-BE]
export type BalanceTransferParameters = {
from: string;
to: string;
amount: number;
reference?: string;
};
Motivation and Context
Testing Details
Example Output or Screenshots (if appropriate)
Types of changes
[x] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist
[ ] My code follows the code style of this project.
[x] My change requires a change to the documentation.
Description
The transferBalance method in the SubAccounts class expects parameters defined by the BalanceTransferParameters type:
Notably, the amount field is defined as a string type.
Problem
When invoking transferBalance with the amount as a string, a 422 Unprocessable Entity error is thrown :
Error :
Solution
When the amount is provided as a number, the request works correctly :
Successful Response:
Conclusion
The BalanceTransferParameters type definition for the amount field appears to be incorrect. Despite being defined as a string, it needs to be passed as a number for the request to succeed. This discrepancy should be addressed to avoid confusion and potential errors.
[AS-IS]
[TO-BE]
Motivation and Context
Testing Details
Example Output or Screenshots (if appropriate)
Types of changes
Checklist