Skip to content
Permalink
Browse files

SWE-13 PR Requested changes

  • Loading branch information
rrk12005 committed Apr 9, 2019
1 parent cc16cdf commit 3594b682beae50e74873218fb79e9f0720322f36
@@ -132,8 +132,7 @@ class FetchData {
if let bankId = $0["bank_account_id"].string,
let bankName = $0["bank_name"].string,
let last4Acct = $0["last4_bank_acct_number"].string,
let accttype: AccountType = $0["bank_account_type"].stringValue ==
"C" ? .checkings : .savings {
let accttype: AccountType = AccountType(rawValue: $0["bank_account_type"].stringValue) {
bankIds.append(BankAcct(bankAcctId: bankId, acctType: accttype, bankName: bankName, last4Acct: last4Acct))
}
}
@@ -16,7 +16,7 @@ class PaymentDetailInterfaceController: WKInterfaceController {
var paymentButtonArmed: Bool = false
var paymentAmount: Double = 0.0
var dictForBankAcct: [String: [BankAcct]] = [:]
var bankID: String = ""
//var bankID: String = ""
@IBOutlet weak var activityIndicator: WKInterfaceImage!
@IBOutlet weak var activityIndicatorLabel: WKInterfaceLabel!
@IBOutlet weak var contentGroup: WKInterfaceGroup!
@@ -35,8 +35,6 @@ class PaymentDetailInterfaceController: WKInterfaceController {
return
}



self.paymentAmount = amount
self.selectedAccount = acct
paymentButton.setTitle(String(format: "Pay $%.2f", amount))
@@ -54,16 +52,17 @@ class PaymentDetailInterfaceController: WKInterfaceController {
let type: PaymentType = self.paymentAmount == self.selectedAccount?.curBalance ? .currentBal : .minimumDue

// process this payment using default bank account (9999) until ability to change account is implemented
if let bankacct = UserDefaults.standard.dictionary(forKey: "default_bank_acct") as? [String: String] {
self.bankID = bankacct["bankAcctId"] ?? "9999"
guard let bankacct = UserDefaults.standard.dictionary(forKey: "default_bank_acct") as? [String: String], let bankID = bankacct["bankAcctId"] else{
NSLog("Error retrieving Payment Option")
return
}

FetchData.submitPayment(for: alias, type: type, amount: self.paymentAmount, bankID: self.bankID) { confirmationNum, paymentID, error in
FetchData.submitPayment(for: alias, type: type, amount: self.paymentAmount, bankID: bankID) { confirmationNum, paymentID, error in
guard error == nil else {
let dismiss = WKAlertAction(title: "Dismiss", style: .cancel, handler: {})
self.presentAlert(withTitle: "Error", message: "We were unable to process your payment at this time. Please try again later.", preferredStyle: .alert, actions: [dismiss])
return
}

self.dictForPayment.updateValue(confirmationNum, forKey: "payment_confirmation_number")
self.dictForPayment.updateValue(paymentID, forKey: "payment_id")
self.activityIndicator.stopAnimatingAsIndicator()
@@ -86,9 +85,10 @@ class PaymentDetailInterfaceController: WKInterfaceController {
@IBAction func bankAccountsTapped() {
configureInterfaceObjects(true)
activityIndicator.configureForActivityIndicator()
FetchData.getBankInfo { accts, error in guard error == nil else {
NSLog("Error retrieving payment methods for account in paymentDetailInterfaceController.")
return
FetchData.getBankInfo { accts, error in
guard error == nil else {
NSLog("Error retrieving payment methods for account in paymentDetailInterfaceController.")
return
}
self.dictForBankAcct.updateValue(accts, forKey: "paymentOptions")
self.configureInterfaceObjects(false)
@@ -10,7 +10,6 @@ import WatchKit
import Foundation

class PaymentOptionsInterfaceController: WKInterfaceController {

@IBOutlet weak var bankAcctTable: WKInterfaceTable!
var bankAccts: [BankAcct] = []
var dictForDefault: [String: String] = [:]
@@ -24,14 +23,17 @@ class PaymentOptionsInterfaceController: WKInterfaceController {
bankAccts = accts
configureRows()
}

override func willActivate() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
}

override func didDeactivate() {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
}

private func configureRows() {
bankAcctTable.setNumberOfRows(bankAccts.count, withRowType: "bankAcctCell")
for index in 0..<bankAcctTable.numberOfRows {
@@ -44,10 +46,10 @@ class PaymentOptionsInterfaceController: WKInterfaceController {

override func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int) {
let acct = bankAccts[rowIndex]
self.dictForDefault.updateValue(acct.acctType.rawValue, forKey: "acctType")
self.dictForDefault.updateValue(acct.bankAcctId, forKey: "bankAcctId")
self.dictForDefault.updateValue(acct.bankName, forKey: "bankName")
self.dictForDefault.updateValue(acct.last4Acct, forKey: "last4Acct")
dictForDefault.updateValue(acct.acctType.rawValue, forKey: "acctType")
dictForDefault.updateValue(acct.bankAcctId, forKey: "bankAcctId")
dictForDefault.updateValue(acct.bankName, forKey: "bankName")
dictForDefault.updateValue(acct.last4Acct, forKey: "last4Acct")
UserDefaults.standard.set(dictForDefault, forKey: "default_bank_acct")
pop()
}

0 comments on commit 3594b68

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