diff --git a/lib/ionia/ionia_api.dart b/lib/ionia/ionia_api.dart index b00c52217..93960b5fd 100644 --- a/lib/ionia/ionia_api.dart +++ b/lib/ionia/ionia_api.dart @@ -6,6 +6,7 @@ import 'package:http/http.dart'; import 'package:cake_wallet/ionia/ionia_user_credentials.dart'; import 'package:cake_wallet/ionia/ionia_virtual_card.dart'; import 'package:cake_wallet/ionia/ionia_category.dart'; +import 'package:cake_wallet/ionia/ionia_gift_card.dart'; class IoniaApi { static const baseUri = 'apidev.ionia.io'; @@ -17,6 +18,7 @@ class IoniaApi { static final getMerchantsUrl = Uri.https(baseUri, '/$pathPrefix/GetMerchants'); static final getMerchantsByFilterUrl = Uri.https(baseUri, '/$pathPrefix/GetMerchantsByFilter'); static final getPurchaseMerchantsUrl = Uri.https(baseUri, '/$pathPrefix/PurchaseGiftCard'); + static final getCurrentUserGiftCardSummariesUrl = Uri.https(baseUri, '/$pathPrefix/GetCurrentUserGiftCardSummaries'); // Create user @@ -245,7 +247,7 @@ class IoniaApi { // Get Current User Gift Card Summaries - Future> getCurrentUserGiftCardSummaries({ + Future> getCurrentUserGiftCardSummaries({ @required String username, @required String password, @required String clientId}) async { @@ -253,7 +255,7 @@ class IoniaApi { 'clientId': clientId, 'username': username, 'password': password}; - final response = await post(getMerchantsUrl, headers: headers); + final response = await post(getCurrentUserGiftCardSummariesUrl, headers: headers); if (response.statusCode != 200) { return []; @@ -269,7 +271,7 @@ class IoniaApi { final data = decodedBody['Data'] as List; return data.map((dynamic e) { final element = e as Map; - return IoniaMerchant.fromJsonMap(element); + return IoniaGiftCard.fromJsonMap(element); }).toList(); } } \ No newline at end of file diff --git a/lib/ionia/ionia_gift_card.dart b/lib/ionia/ionia_gift_card.dart new file mode 100644 index 000000000..ee99f7986 --- /dev/null +++ b/lib/ionia/ionia_gift_card.dart @@ -0,0 +1,71 @@ +import 'package:flutter/foundation.dart'; + +class IoniaGiftCard { + IoniaGiftCard({ + @required this.id, + @required this.merchantId, + @required this.legalName, + @required this.systemName, + @required this.barcodeUrl, + @required this.cardNumber, + @required this.cardPin, + @required this.usageInstructions, + @required this.balanceInstructions, + @required this.paymentInstructions, + @required this.cardImageUrl, + @required this.tip, + @required this.purchaseAmount, + @required this.actualAmount, + @required this.totalTransactionAmount, + @required this.totalDashTransactionAmount, + @required this.remainingAmount, + @required this.createdDateFormatted, + @required this.lastTransactionDateFormatted, + @required this.isActive, + @required this.isEmpty, + @required this.logoUrl}); + + factory IoniaGiftCard.fromJsonMap(Map element) { + return IoniaGiftCard( + id: element['Id'] as int, + merchantId: element['MerchantId'] as int, + legalName: element['LegalName'] as String, + systemName: element['SystemName'] as String, + barcodeUrl: element['BarcodeUrl'] as String, + cardNumber: element['CardNumber'] as String, + tip: element['Tip'] as double, + purchaseAmount: element['PurchaseAmount'] as double, + actualAmount: element['ActualAmount'] as double, + totalTransactionAmount: element['TotalTransactionAmount'] as double, + totalDashTransactionAmount: element['TotalDashTransactionAmount'] as double, + remainingAmount: element['RemainingAmount'] as double, + isActive: element['IsActive'] as bool, + isEmpty: element['IsEmpty'] as bool, + logoUrl: element['LogoUrl'] as String, + createdDateFormatted: element['CreatedDate'] as String, + lastTransactionDateFormatted: element['LastTransactionDate'] as String); + } + + final int id; + final int merchantId; + final String legalName; + final String systemName; + final String barcodeUrl; + final String cardNumber; + final String cardPin; + final Map usageInstructions; + final Map balanceInstructions; + final Map paymentInstructions; + final String cardImageUrl; + final double tip; + final double purchaseAmount; + final double actualAmount; + final double totalTransactionAmount; + final double totalDashTransactionAmount; + final double remainingAmount; + final String createdDateFormatted; + final String lastTransactionDateFormatted; + final bool isActive; + final bool isEmpty; + final String logoUrl; +} \ No newline at end of file diff --git a/lib/ionia/ionia_service.dart b/lib/ionia/ionia_service.dart index 19574e997..ceb95f6fc 100644 --- a/lib/ionia/ionia_service.dart +++ b/lib/ionia/ionia_service.dart @@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:cake_wallet/.secrets.g.dart' as secrets; import 'package:cake_wallet/ionia/ionia_api.dart'; +import 'package:cake_wallet/ionia/ionia_gift_card.dart'; import 'package:cake_wallet/ionia/ionia_category.dart'; class IoniaService { @@ -114,7 +115,7 @@ class IoniaService { // Get Current User Gift Card Summaries - Future> getCurrentUserGiftCardSummaries() async { + Future> getCurrentUserGiftCardSummaries() async { final username = await secureStorage.read(key: ioniaUsernameStorageKey); final password = await secureStorage.read(key: ioniaPasswordStorageKey); return ioniaApi.getCurrentUserGiftCardSummaries(username: username, password: password, clientId: clientId); diff --git a/lib/src/screens/ionia/cards/ionia_account_cards_page.dart b/lib/src/screens/ionia/cards/ionia_account_cards_page.dart index ba2ddae55..07ab4b17e 100644 --- a/lib/src/screens/ionia/cards/ionia_account_cards_page.dart +++ b/lib/src/screens/ionia/cards/ionia_account_cards_page.dart @@ -1,3 +1,4 @@ +import 'package:cake_wallet/ionia/ionia_gift_card.dart'; import 'package:cake_wallet/ionia/ionia_merchant.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/ionia/widgets/card_item.dart'; @@ -125,7 +126,7 @@ class _IoniaCardListView extends StatelessWidget { }) : super(key: key); final String emptyText; - final List merchList; + final List merchList; @override Widget build(BuildContext context) { @@ -148,12 +149,11 @@ class _IoniaCardListView extends StatelessWidget { child: CardItem( title: merchant.legalName, backgroundColor: Theme.of(context).accentTextTheme.display4.backgroundColor.withOpacity(0.1), - discount: merchant.minimumDiscount, + discount: 0, discountBackground: AssetImage('assets/images/red_badge_discount.png'), titleColor: Theme.of(context).accentTextTheme.display4.backgroundColor, subtitleColor: Theme.of(context).hintColor, - subTitle: - '${merchant.isOnline ? '${S.of(context).online}' ' && ${S.current.in_store}' : S.of(context).offline}', + subTitle: '', logoUrl: merchant.logoUrl, ), ); diff --git a/lib/view_model/ionia/ionia_account_view_model.dart b/lib/view_model/ionia/ionia_account_view_model.dart index 1b049b974..1bdc1c9f7 100644 --- a/lib/view_model/ionia/ionia_account_view_model.dart +++ b/lib/view_model/ionia/ionia_account_view_model.dart @@ -1,6 +1,7 @@ import 'package:cake_wallet/ionia/ionia_merchant.dart'; import 'package:cake_wallet/ionia/ionia_service.dart'; import 'package:mobx/mobx.dart'; +import 'package:cake_wallet/ionia/ionia_gift_card.dart'; part 'ionia_account_view_model.g.dart'; @@ -20,16 +21,16 @@ abstract class IoniaAccountViewModelBase with Store { String email; @observable - List merchs; + List merchs; @computed int get countOfMerch => merchs.where((merch) => merch.isActive).length; @computed - List get activeMechs => merchs.where((merch) => merch.isActive).toList(); + List get activeMechs => merchs.where((merch) => merch.isActive).toList(); @computed - List get redeemedMerchs => merchs.where((merch) => !merch.isActive).toList(); + List get redeemedMerchs => merchs.where((merch) => !merch.isActive).toList(); @action void logout() {