Change ionia base url. Add exception throwing for error messaging for some of ionia calls.

This commit is contained in:
M 2022-06-30 13:23:11 +01:00
parent 0a7f8bf286
commit def28ba5c8

View file

@ -8,7 +8,7 @@ import 'package:cake_wallet/ionia/ionia_virtual_card.dart';
import 'package:cake_wallet/ionia/ionia_category.dart'; import 'package:cake_wallet/ionia/ionia_category.dart';
class IoniaApi { class IoniaApi {
static const baseUri = 'apidev.dashdirect.org'; static const baseUri = 'apidev.ionia.io';
static const pathPrefix = 'cake'; static const pathPrefix = 'cake';
static final createUserUri = Uri.https(baseUri, '/$pathPrefix/CreateUser'); static final createUserUri = Uri.https(baseUri, '/$pathPrefix/CreateUser');
static final verifyEmailUri = Uri.https(baseUri, '/$pathPrefix/VerifyEmail'); static final verifyEmailUri = Uri.https(baseUri, '/$pathPrefix/VerifyEmail');
@ -229,14 +229,14 @@ class IoniaApi {
final response = await post(getPurchaseMerchantsUrl, headers: headers, body: json.encode(body)); final response = await post(getPurchaseMerchantsUrl, headers: headers, body: json.encode(body));
if (response.statusCode != 200) { if (response.statusCode != 200) {
return null; throw Exception('Unexpected response');
} }
final decodedBody = json.decode(response.body) as Map<String, dynamic>; final decodedBody = json.decode(response.body) as Map<String, dynamic>;
final isSuccessful = decodedBody['Successful'] as bool ?? false; final isSuccessful = decodedBody['Successful'] as bool ?? false;
if (!isSuccessful) { if (!isSuccessful) {
return null; throw Exception(decodedBody['ErrorMessage'] as String);
} }
final data = decodedBody['Data'] as Map<String, dynamic>; final data = decodedBody['Data'] as Map<String, dynamic>;