Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update card model #8

Merged
merged 1 commit into from
Oct 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Source/Model/Card.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ public class Card: Mappable {
/// The id of the card.
public private(set) var id: String?

/// The list of addresses for the card.
public private(set) var addresses: [Address]?
/// The card's primary address dictionary.
public private(set) var address: [String : String]?

/// The balance available for withdrawal/usage.
public private(set) var available: String?
Expand All @@ -35,7 +35,7 @@ public class Card: Mappable {
Constructor.

- parameter id: The id of the card.
- parameter addresses: The list of address for the card.
- parameter address: The card's primary address dictionary.
- parameter available: The balance available for withdrawal/usage.
- parameter balance: The total balance of the card, including all pending transactions.
- parameter currency: The currency of the card.
Expand All @@ -44,9 +44,9 @@ public class Card: Mappable {
- parameter normalized: The list with the normalized fields.
- parameter settings: The Settings of the card.
*/
public init(id: String, addresses: [Address], available: String, balance: String, currency: String, label: String, lastTransactionAt: String?, normalized: [Normalized], settings: CardSettings) {
public init(id: String, address: [String : String], available: String, balance: String, currency: String, label: String, lastTransactionAt: String?, normalized: [Normalized], settings: CardSettings) {
self.id = id;
self.addresses = addresses
self.address = address
self.available = available
self.balance = balance
self.currency = currency
Expand All @@ -67,7 +67,7 @@ public class Card: Mappable {
/// Maps the JSON to the Object.
public func mapping(map: Map) {
self.id <- map["id"]
self.addresses <- map["addresses"]
self.address <- map["address"]
self.available <- map["available"]
self.balance <- map["balance"]
self.currency <- map["currency"]
Expand Down
6 changes: 3 additions & 3 deletions Tests/Integration/Model/CardTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class CardTest: XCTestCase {
let card = Mapper<Card>().map("{ \"address\": { \"bitcoin\": \"fuzbuz\" }, \"available\": \"87.52\", \"balance\": \"87.52\", \"currency\": \"EUR\", \"id\": \"foobar\", \"label\": \"Foo card\", \"lastTransactionAt\": \"foobiz\", \"settings\": { \"position\": 4, \"starred\": true }, \"addresses\": [ { \"id\": \"fiz\", \"network\": \"biz\" } ], \"normalized\": [ { \"available\": \"99.04\", \"balance\": \"99.04\", \"currency\": \"USD\" } ] }")

XCTAssertEqual(card!.id!, "foobar", "Failed: Card id didn't match.")
XCTAssertEqual(card!.addresses!.count, 1, "Failed: Addresses didn't match.")
XCTAssertEqual(card!.addresses![0].id!, "fiz", "Failed: Addresses didn't match.")
XCTAssertEqual(card!.addresses![0].network!, "biz", "Failed: Addresses didn't match.")
XCTAssertFalse(card!.address!.isEmpty, "Failed: Address didn't match.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Please validate that the dictionary only have one element.

XCTAssertEqual(card!.address!.count, 1, "Failed: Address didn't match.")
XCTAssertEqual(card!.address!["bitcoin"]!, "fuzbuz", "Failed: Address didn't match.")
XCTAssertEqual(card!.available!, "87.52", "Failed: Available didn't match.")
XCTAssertEqual(card!.balance!, "87.52", "Failed: Balance didn't match.")
XCTAssertEqual(card!.currency!, "EUR", "Failed: Currency didn't match.")
Expand Down