Skip to content

Swe 13 choose bank account #15

Merged
merged 12 commits into from Apr 10, 2019
Merged

Swe 13 choose bank account #15

merged 12 commits into from Apr 10, 2019

Conversation

rrk12005
Copy link
Owner

@rrk12005 rrk12005 commented Apr 7, 2019

This branch allows the user to choose the bank they want to use. Need to hook up to the makePayment API call

… type. Fetching bank account info and populating table with it. Updated getbankacctinfo request to grab the bank name and last 4 digits of bank account.
…type. Fetching bank account info and populating table with it. Updated getbankacctinfo request to grab the bank name and last 4 digits of bank account.
…g of account info, just able to display chosen bank name
…. new structure of storing default bank account in UseraDefaults
import WatchKit

class BankAcctCell: NSObject {
@IBOutlet weak var BankNameLabel: WKInterfaceLabel!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variable names should begin with a lowercase and follow camel case style.


class BankAcctCell: NSObject {
@IBOutlet weak var BankNameLabel: WKInterfaceLabel!
@IBOutlet weak var Last4Label: WKInterfaceLabel!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

}
}

extension UserDefaults {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This extension on UserDefaults should be in its own file, namely UserDefaults+Extensions.swift

paymentButton.setHidden(hide)
payFrom.setHidden(hide)
separate.setHidden(hide)
/*if(!hide){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug code should be removed prior to merging into master


override func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int) {
let acct = bankAccts[rowIndex]
self.dictForDefault.updateValue(String(acct.acctType.rawValue), forKey: "acctType")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this line is creating a new String from the acct.acctType.rawValue which will evaluate to either "1" or "0". Is that the intended behavior? Is there a reason we couldn't just use the rawValue which is int?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, for this line and the lines below, we don't need the explicit use of self

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it's a dictionary of strings, this value needs to be a string, therefore the conversion from int to string is necessary to store the value in the dict

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in that case we should change the raw value of AccountType to be String so we can avoid this conversion. The raw values of checking and savings can simply be string representations of those words

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. I'll add that with my changes

Copy link
Collaborator

@ahm11003 ahm11003 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this PR looks good. A few changes need to be made before it is ready to merge. Also, is it possible to populate the bank account and only fire off the web service if the user wants to change that account?


override func awake(withContext context: Any?) {
configureInterfaceObjects(true)
activityIndicator.configureForActivityIndicator()
super.awake(withContext: context)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super.awake(withContext: context) should be the first call within this function

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think you intend to show the activityIndicatorLabel here and then hide it again once web service returns

# Conflicts:
#	SynchronyFinancial/SynchronyFinancial WatchKit App/Base.lproj/Interface.storyboard
#	SynchronyFinancial/SynchronyFinancial WatchKit Extension/FetchData.swift
#	SynchronyFinancial/SynchronyFinancial WatchKit Extension/PaymentDetailInterfaceController.swift
#	SynchronyFinancial/SynchronyFinancial/Defaults.swift
@@ -44,14 +58,37 @@ class PaymentDetailInterfaceController: WKInterfaceController {
paymentButton.setTitle("Pay Now")
}
}

@IBAction func bankAccountsTapped() {
self.pushController(withName: "PaymentOptions", context: self.dictForBankAcct)
Copy link
Collaborator

@ahm11003 ahm11003 Apr 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary use of explicit self in function call as well as when passing in dictForBankAcct

@ahm11003
Copy link
Collaborator

ahm11003 commented Apr 8, 2019

Additionally, when we currently make a payment we pass in the last 4 digits of the bank account to pay from. So, we should either update that function to retrieve the value stored in UserDefaults and remove that parameter, or we should update existing calls to the make payment function to retrieve the value from UserDefaults prior to making the call.

…o API request is called so it is fired upon only when user want to change default bank acct. User's default bank account ID is now being used in the makePayment API call.
@@ -131,11 +130,11 @@ class FetchData {
//"fetch_bank_account_details"
dict["fetch_bank_account_details"]?.arrayValue.forEach {
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 ==
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So now that we have a raw value of String for AccountType we should just be able to say:
let accttype = AccountType(rawValue: $0["bank_account_type"].stringValue)

}


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove this blank line and the line below

@@ -50,7 +54,11 @@ 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
FetchData.submitPayment(for: alias, type: type, amount: self.paymentAmount, bankID: "9999") { confirmationNum, paymentID, error in
if let bankacct = UserDefaults.standard.dictionary(forKey: "default_bank_acct") as? [String: String] {
self.bankID = bankacct["bankAcctId"] ?? "9999"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we shouldn't be falling back on "9999" as a "default" bank account id unless that is consistent across ALL user accounts.

@IBAction func bankAccountsTapped() {
configureInterfaceObjects(true)
activityIndicator.configureForActivityIndicator()
FetchData.getBankInfo { accts, error in guard error == nil else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guard should be dropped down inside the closure


override func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int) {
let acct = bankAccts[rowIndex]
self.dictForDefault.updateValue(acct.acctType.rawValue, forKey: "acctType")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove explicit use of self on this line and subsequent lines

}
bankAccts = accts
configureRows()
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insert new line after this closing brace

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insert new line after this closing brace

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insert new line after this closing brace

@@ -50,12 +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
FetchData.submitPayment(for: alias, type: type, amount: self.paymentAmount, bankID: "9999") { confirmationNum, paymentID, error in
guard let bankacct = UserDefaults.standard.dictionary(forKey: "default_bank_acct") as? [String: String], let bankID = bankacct["bankAcctId"] else{
Copy link
Collaborator

@ahm11003 ahm11003 Apr 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our extension on UserDefaults stores a BankAcct object under this same key, can we utilize those functions we wrote here? Like:
guard let bankacct = UserDefaults.getDefaultBankAccount() as? BankAcct
and then pass in bankacct.bankID to the call to submitPayment

ahm11003 and others added 3 commits April 9, 2019 15:53
# Conflicts:
#	SynchronyFinancial/SynchronyFinancial WatchKit Extension/TransactionsInterfaceController.swift
#	SynchronyFinancial/SynchronyFinancial.xcodeproj/project.pbxproj
…ctInfo from UserDefaults in updating the selected bank account label as well as passing bankId in submit payment
@ahm11003 ahm11003 merged commit 8d33cc1 into master Apr 10, 2019
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants