fetchWallet method
Fetches the SmartWallet information for the user.
This method makes an API call to retrieve the SmartWallet data associated with the user.
Returns a Future that completes with a DC object:
- On success,
DC.data
will be called with a SmartWallet object representing the user's SmartWallet. - On failure,
DC.error
will be called with anException
object.
Implementation
Future<DC<Exception, SmartWallet>> fetchWallet() async {
try {
final Response response = await _dio.get(
'/v1/smart-wallets',
options: _options,
);
if (response.statusCode != 200) {
return DC.error(Exception('Failed to fetch wallet'));
}
final SmartWallet smartWallet = SmartWallet.fromJson(response.data);
setWallet = smartWallet;
return DC.data(smartWallet);
} catch (e) {
return DC.error(Exception(e.toString()));
}
}