Skip to content
Permalink
Browse files

SWF-21 Implemented last 4 digits display

- we now grab the last 4 digits of account number and store on the `Account` object
- modified the `AccountCell` and table displays to reflect this change
  • Loading branch information
ahm11003 committed Apr 4, 2019
1 parent ffd4f19 commit 41a9d58cee846c2e15a287b72ad9264f7c7a3c57
@@ -99,11 +99,13 @@
<tableRow identifier="account" id="5xi-FS-LlJ" customClass="AccountCell" customModule="SynchronyFinancial_WatchKit_Extension"> <tableRow identifier="account" id="5xi-FS-LlJ" customClass="AccountCell" customModule="SynchronyFinancial_WatchKit_Extension">
<group key="rootItem" width="1" height="44" alignment="left" layout="vertical" id="mYi-9N-Ue7"> <group key="rootItem" width="1" height="44" alignment="left" layout="vertical" id="mYi-9N-Ue7">
<items> <items>
<label alignment="left" text="Label" id="Tl1-Kc-YJS"/> <label alignment="left" text="Account Name" id="Tl1-Kc-YJS"/>
<label width="136" alignment="left" verticalAlignment="bottom" text="(...XXXX)" textAlignment="left" id="OWC-kI-GEy"/>
</items> </items>
</group> </group>
<connections> <connections>
<outlet property="accountName" destination="Tl1-Kc-YJS" id="cgD-CY-lzh"/> <outlet property="accountName" destination="Tl1-Kc-YJS" id="cgD-CY-lzh"/>
<outlet property="last4Label" destination="OWC-kI-GEy" id="su7-E3-eEF"/>
</connections> </connections>
</tableRow> </tableRow>
</items> </items>
@@ -11,4 +11,5 @@ import WatchKit


class AccountCell: NSObject { class AccountCell: NSObject {
@IBOutlet weak var accountName: WKInterfaceLabel! @IBOutlet weak var accountName: WKInterfaceLabel!
@IBOutlet weak var last4Label: WKInterfaceLabel!
} }
@@ -48,6 +48,7 @@ class AccountTableInterfaceController: WKInterfaceController {
for index in 0..<accountTable.numberOfRows { for index in 0..<accountTable.numberOfRows {
if let row = accountTable.rowController(at: index) as? AccountCell { if let row = accountTable.rowController(at: index) as? AccountCell {
row.accountName.setText(accounts[index].accountName) row.accountName.setText(accounts[index].accountName)
row.last4Label.setText("(...\(accounts[index].last4))")
} }
} }
} }
@@ -49,6 +49,7 @@ class FetchData {
if let accounts = dict["account_number_list"]?.arrayValue { if let accounts = dict["account_number_list"]?.arrayValue {
accounts.forEach { accounts.forEach {
if let accountAlias = $0.dictionaryValue["account_alias"]?.string, if let accountAlias = $0.dictionaryValue["account_alias"]?.string,
let last4 = $0["last4_acct_number"].string,
let creditLimitString = $0.dictionaryValue["credit_limit"]?.string, let creditLimitString = $0.dictionaryValue["credit_limit"]?.string,
let creditLimit = Double(creditLimitString), let creditLimit = Double(creditLimitString),
let payDueDateString = $0.dictionaryValue["next_payment_due_date"]?.string, let payDueDateString = $0.dictionaryValue["next_payment_due_date"]?.string,
@@ -62,7 +63,7 @@ class FetchData {
let statementBalString = $0.dictionaryValue["statement_bal"]?.string, let statementBalString = $0.dictionaryValue["statement_bal"]?.string,
let statementBalance = Double(statementBalString), let statementBalance = Double(statementBalString),
let accountName = $0.dictionaryValue["cc_program_name"]?.string { let accountName = $0.dictionaryValue["cc_program_name"]?.string {
let inAccount = Account(accountAlias: accountAlias, creditLimit: creditLimit, paymentDueDate: paymentDueDate, curBalance: currentBalance, availCredit: availableCredit, minPayDue: minPaymentDue, statementBal: statementBalance, accountName: accountName) let inAccount = Account(accountAlias, creditLimit, last4, paymentDueDate, currentBalance, availableCredit, minPaymentDue, statementBalance, accountName)
accountList.append(inAccount) accountList.append(inAccount)
} }
} }
@@ -10,6 +10,7 @@ import Foundation
class Account: NSObject { class Account: NSObject {
var accountAlias: String var accountAlias: String
var creditLimit: Double var creditLimit: Double
var last4: String
//var transactions: [Transaction] //var transactions: [Transaction]
var paymentDueDate: Date var paymentDueDate: Date
//var cycleEndDate: Date //var cycleEndDate: Date
@@ -20,9 +21,10 @@ class Account: NSObject {
var statementBal: Double var statementBal: Double
var accountName: String var accountName: String


init(accountAlias: String, creditLimit: Double, paymentDueDate: Date, curBalance: Double, availCredit: Double, minPayDue: Double, statementBal: Double, accountName: String) { init(_ accountAlias: String, _ creditLimit: Double, _ last4: String, _ paymentDueDate: Date, _ curBalance: Double, _ availCredit: Double, _ minPayDue: Double, _ statementBal: Double, _ accountName: String) {
self.accountAlias = accountAlias self.accountAlias = accountAlias
self.creditLimit = creditLimit self.creditLimit = creditLimit
self.last4 = last4
//self.transactions = transactions //self.transactions = transactions
//self.balance = transactions.map { $0.amount }.reduce(0.0, +) //self.balance = transactions.map { $0.amount }.reduce(0.0, +)
self.paymentDueDate = paymentDueDate self.paymentDueDate = paymentDueDate

0 comments on commit 41a9d58

Please sign in to comment.
You can’t perform that action at this time.