Skip to content

Commit

Permalink
Bank sources API fix (true json), app fix and more documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Raghav Bhasin authored and Raghav Bhasin committed Aug 24, 2018
1 parent a0842d8 commit 652f1d6
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 22 deletions.
2 changes: 1 addition & 1 deletion DrackerAPI/API/users/bank/GET/get_bank_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ def lambda_handler(event, context):
else:
item["is_default"] = False
sources.append(item)
return {"message" : "SUCCESS", "list" : json.dumps(sources)}
return {"message" : "SUCCESS", "list" : sources}
except:
return {"message" : "ERROR"}
19 changes: 13 additions & 6 deletions ios App/Dracker/Application Flow/Bank Account/BankAccount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,20 @@ class BankAccount: UIViewController {
if message == "ERROR" {
return
} else {
let accounts_string = (data["list"] as? String)?.data(using: .utf8)!
do {
self.accounts_list = try JSONDecoder().decode([Account].self, from: accounts_string!)
} catch {
//Should never happen
let accounts = data["list"] as! [[String: Any]]
self.accounts_list = []
for account in accounts {
let name = account["name"] as! String
let institution = account["institution"] as! String
let url = account["url"] as! String
let is_default = account["is_default"] as! Bool

let new_account = Account(name: name, institution: institution, url: url, is_default: is_default)
self.accounts_list.append(new_account)
}
execute_on_main {
self.accounts_view.reloadData()
}
self.accounts_view.reloadData()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class AddTransaction: UIViewController {
payer.layer.transform = CATransform3DMakeTranslation(0, (main_frame?.height)!, 0)
UIView.animate(withDuration: 0.8, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseOut, animations: {[unowned self] in
payer.layer.transform = CATransform3DMakeTranslation(0, -top, 0)
self.navigation_title.text = "Select Phone"
self.navigation_title.text = "Phone Number"
}, completion: nil)
}

Expand Down Expand Up @@ -318,7 +318,7 @@ extension AddTransaction {
view.endEditing(true)
let actions = image_picker_action_sheet(controller: self, picker: picker, action1: "Tag an image from Library", action2: "Snap an image", camera: .rear, first_responder: first_responder)
actions.addAction(UIAlertAction(title: "Tag from Web", style: .default, handler: {[unowned self] (_) in
self.navigation_title.text = "Tag Image"
self.navigation_title.text = "Tag an Image"
let top = (self.navigationController?.navigationBar.frame.height)! + UIApplication.shared.statusBarFrame.height
let main_frame = UIApplication.shared.keyWindow?.screen.bounds
let image_search = ImageSearch()
Expand Down
10 changes: 10 additions & 0 deletions ios App/Dracker/Custom Components/Change.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import UIKit

/**
* A simple reusable view controller that is fully customizable based on the Configurations entry. This creates a generic change page with a title, an image, a single text field, and a button. All is customizable and is reused for:
- Change Password
- Change Email
- Set Reminder Frequency
- Set Passcode
- Change Passcode

The view perfoms the action and then switches back to the parent if successful else stays on with the error message.
**/
class Change: UIViewController {
let label: UILabel = {
let label = UILabel()
Expand Down
17 changes: 9 additions & 8 deletions ios App/Dracker/Data Model/Account.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import Foundation

struct Account: Decodable {
/**
* A struct to hold the information for a Bank Account.
- is_default: Is this the default payment source for settling transactions.
- name: Name of the Bank Account.
- institution: Name of the Bank Institution with which the account is linked.
- url: Dwolla resource for this bank account to create transfers
*/

struct Account {
let name: String
let institution: String
let url: String
var is_default: Bool

private enum CodingKeys: String, CodingKey {
case name = "name"
case institution = "institution"
case is_default = "is_default"
case url = "url"
}
}
9 changes: 9 additions & 0 deletions ios App/Dracker/Data Model/Configuration.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import Foundation

/**
* A struct to hold the configurations for the Change Voew Controller. This helps create the controller and make it reusable.
- title: First line of text or the main title of page.
- image: Image associated with the change action.
- button: Text to be displayed on the button.
- placeholder: Placeholder for the text field.
- isSecure: Is the text field secure.
- action: A function refrence that returns true on success(navigates back) and false on failure (stays on the same page). Used to perform the change action and switch back to parent. The function takes in the text of textfield as an argument.
*/
struct Configuration {
var title: String
var image: String
Expand Down
4 changes: 2 additions & 2 deletions ios App/Dracker/Data Model/Friends.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

/**
* A Struct to hold the information for a Friend.
* A struct to hold the information for a Friend.
- amount: Amount of for this friend.
- phone: Phone of this friend.
- name: Name of this friend.
Expand All @@ -17,7 +17,7 @@ struct Friends {
}

/**
* A Struct to hold the information for a transactions. Could be settled of unsettled.
* A struct to hold the information for a transactions. Could be settled of unsettled.
- is_debt: If the transaction was a debt or not
- amount: Amount for this transaction
- description: Description for this transaction
Expand Down
4 changes: 2 additions & 2 deletions ios App/Dracker/Data Model/Transactions.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit

/**
* A Struct to hold the information for Settled Transactions. A Settled Transaction contains the minimal information about it, since it has been payed off.
* A struct to hold the information for Settled Transactions. A Settled Transaction contains the minimal information about it, since it has been payed off.
- is_debt: If the transaction was a debt or not
- amount: Amount for this transaction
- description: Description for this transaction
Expand All @@ -15,7 +15,7 @@ struct Settled {
}

/**
* A Struct to hold the information for Unsettled Transactions. An Unsettled Transaction contains all the information about it that would be necessary to settle it.
* A struct to hold the information for Unsettled Transactions. An Unsettled Transaction contains all the information about it that would be necessary to settle it.
- is_debt: If the transaction was a debt or not
- amount: Amount for this transaction
- description: Description for this transaction
Expand Down
2 changes: 1 addition & 1 deletion ios App/Dracker/Data Model/User.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

/**
* A Struct to hold the information for a User. A User consists:
* A struct to hold the information for a User. A User consists:
- phone: Phone of the User.
- uid: uid for the User.
- name: Name of the User.
Expand Down

0 comments on commit 652f1d6

Please sign in to comment.