Skip to content

Commit

Permalink
Update card model
Browse files Browse the repository at this point in the history
  • Loading branch information
diogoguimaraes committed Oct 7, 2015
1 parent 6233226 commit 1470e67
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
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.")
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

0 comments on commit 1470e67

Please sign in to comment.