diff --git a/Source/Model/Card/CardSettings.swift b/Source/Model/Card/CardSettings.swift index e888bab..30d9584 100644 --- a/Source/Model/Card/CardSettings.swift +++ b/Source/Model/Card/CardSettings.swift @@ -7,6 +7,9 @@ public class CardSettings: Mappable { /// The position of the card. public private(set) final var position: Int? + /// A boolean indicating if the card is protected. + public private(set) final var protected: Bool? + /// A boolean indicating if the card is starred. public private(set) final var starred: Bool? @@ -14,10 +17,12 @@ public class CardSettings: Mappable { Constructor. - parameter position: The position of the card. + - parameter protected: A boolean indicating if the card is protected. - parameter starred: A boolean indicating if the card is starred. */ - public init(position: Int, starred: Bool) { + public init(position: Int, protected: Bool, starred: Bool) { self.position = position + self.protected = protected self.starred = starred } @@ -38,6 +43,7 @@ public class CardSettings: Mappable { */ public func mapping(map: Map) { position <- map["position"] + protected <- map["protected"] starred <- map["starred"] } diff --git a/Tests/Integration/Model/CardTest.swift b/Tests/Integration/Model/CardTest.swift index c565be1..3555105 100644 --- a/Tests/Integration/Model/CardTest.swift +++ b/Tests/Integration/Model/CardTest.swift @@ -19,6 +19,7 @@ class CardTest: UpholdTestCase { "\"lastTransactionAt\": \"foobiz\"," + "\"settings\": {" + "\"position\": 4," + + "\"protected\": true," + "\"starred\": true" + "}," + "\"addresses\": [{" + @@ -47,6 +48,7 @@ class CardTest: UpholdTestCase { XCTAssertEqual(card!.normalized![0].balance!, "99.04", "Failed: Balance didn't match.") XCTAssertEqual(card!.normalized![0].currency!, "USD", "Failed: Currency didn't match.") XCTAssertEqual(card!.settings!.position!, 4, "Failed: Position didn't match.") + XCTAssertTrue(card!.settings!.protected!, "Failed: Protected didn't match.") XCTAssertTrue(card!.settings!.starred!, "Failed: Starred didn't match.") } diff --git a/Tests/Integration/Model/UserTest.swift b/Tests/Integration/Model/UserTest.swift index 5d38efd..47534b6 100644 --- a/Tests/Integration/Model/UserTest.swift +++ b/Tests/Integration/Model/UserTest.swift @@ -23,7 +23,7 @@ class UserTest: UpholdTestCase { } func testCreateCardWithSettingsShouldReturnTheCard() { - let cardSettings: CardSettings = CardSettings(position: 1, starred: true) + let cardSettings: CardSettings = CardSettings(position: 1, protected: true, starred: true) let expectation = expectationWithDescription("User test: create card.") let user: User = Fixtures.loadUser() user.adapter = MockRestAdapter(body: Mapper().toJSONString(Fixtures.loadCard(["id": "foobar"]))!) diff --git a/Tests/Util/Fixtures.swift b/Tests/Util/Fixtures.swift index 27bfeb5..0467857 100644 --- a/Tests/Util/Fixtures.swift +++ b/Tests/Util/Fixtures.swift @@ -71,6 +71,7 @@ public class Fixtures { "normalizedBalance": String(format: "%@,%@,%@", faker.lorem.numerify("123456789"), faker.lorem.numerify("123456789"), faker.lorem.numerify("123456789")), "normalizedCurrencies": String(format: "%@,%@,%@", faker.lorem.characters(amount: 3), faker.lorem.characters(amount: 3), faker.lorem.characters(amount: 3)), "settingsPosition": faker.lorem.numerify("#"), + "settingsProtected": "true", "settingsStarred": "true" ] @@ -90,7 +91,7 @@ public class Fixtures { normalized.append(NormalizedCard(available: available, balance: fakerFields["normalizedBalance"]!.componentsSeparatedByString(",")[index], currency: fakerFields["normalizedCurrencies"]!.componentsSeparatedByString(",")[index])) } - let cardSettings = CardSettings(position: NSString(string: fakerFields["settingsPosition"]!).integerValue, starred: NSString(string: fakerFields["settingsStarred"]!).boolValue) + let cardSettings = CardSettings(position: NSString(string: fakerFields["settingsPosition"]!).integerValue, protected: NSString(string: fakerFields["settingsProtected"]!).boolValue, starred: NSString(string: fakerFields["settingsStarred"]!).boolValue) return Card(id: fakerFields["id"]!, address: address, available: fakerFields["available"]!, balance: fakerFields["balance"]!, currency: fakerFields["currency"]!, label: fakerFields["label"]!, lastTransactionAt: fakerFields["lastTransactionAt"], normalized: normalized, settings: cardSettings) }