Skip to content

Commit

Permalink
Merge pull request #73 from uphold/feature/has-marketing-consent
Browse files Browse the repository at this point in the history
Add `hasMarketingConsent` setting
  • Loading branch information
d-moreira authored May 23, 2018
2 parents f51e3a3 + aefd8e4 commit 5ac89e4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Source/Model/User/UserSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ open class UserSettings: Mappable {
/// The user's default currency.
open private(set) var currency: String?

/// A boolean indicating if the user has the marketing consent enabled.
open private(set) var hasMarketingConsent: Bool?

/// A boolean indicating if the user has the news subscription enabled.
open private(set) var hasNewsSubscription: Bool?

Expand All @@ -23,12 +26,13 @@ open class UserSettings: Mappable {
Constructor.

- parameter currency: The user's default currency.
- parameter hasMarketingConsent: A boolean indicating if the user has the marketing consent enabled.
- parameter hasNewsSubscription: A boolean indicating if the user has the news subscription enabled.
- parameter intl: The user internationalization settings.
- parameter otp: The user otp settings.
- parameter theme: The user theme.
*/
public init(currency: String, hasNewsSubscription: Bool, intl: InternationalizationUserSettings, otp: Otp, theme: String) {
public init(currency: String, hasMarketingConsent: Bool, hasNewsSubscription: Bool, intl: InternationalizationUserSettings, otp: Otp, theme: String) {
self.currency = currency
self.hasNewsSubscription = hasNewsSubscription
self.intl = intl
Expand All @@ -53,6 +57,7 @@ open class UserSettings: Mappable {
*/
open func mapping(map: Map) {
currency <- map["currency"]
hasMarketingConsent <- map["hasMarketingConsent"]
hasNewsSubscription <- map["hasNewsSubscription"]
intl <- map["intl"]
otp <- map["otp"]
Expand Down
2 changes: 2 additions & 0 deletions Tests/IntegrationTests/ClientTests/UpholdClientTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class UpholdClientTest: UpholdTestCase {
"\"settings\": {" +
"\"theme\": \"minimalistic\"," +
"\"currency\": \"USD\"," +
"\"hasMarketingConsent\": true," +
"\"hasNewsSubscription\": true," +
"\"intl\": {" +
"\"language\": {" +
Expand Down Expand Up @@ -268,6 +269,7 @@ class UpholdClientTest: UpholdTestCase {
XCTAssertEqual(user.memberAt, "bizdev", "Failed: User memberAt didn't match.")
XCTAssertEqual(user.name, "Foo Bar", "Failed: User name didn't match.")
XCTAssertEqual(user.settings!.currency!, "USD", "Failed: User settings currency didn't match.")
XCTAssertTrue(user.settings!.hasMarketingConsent!, "Failed: User settings hasMarketingConsent didn't match.")
XCTAssertTrue(user.settings!.hasNewsSubscription!, "Failed: User settings hasNewsSubscription didn't match.")
XCTAssertEqual(user.settings!.intl!.dateTimeFormat!.locale!, "en-US", "Failed: User settings intl dateTimeFormat didn't match.")
XCTAssertEqual(user.settings!.intl!.language!.locale!, "en-US", "Failed: User settings intl language didn't match.")
Expand Down
2 changes: 2 additions & 0 deletions Tests/IntegrationTests/ModelTests/UserTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ class UserTest: UpholdTestCase {
"\"settings\": {" +
"\"theme\": \"minimalistic\"," +
"\"currency\": \"USD\"," +
"\"hasMarketingConsent\": true," +
"\"hasNewsSubscription\": true," +
"\"intl\": {" +
"\"language\": {" +
Expand Down Expand Up @@ -777,6 +778,7 @@ class UserTest: UpholdTestCase {
XCTAssertEqual(user!.lastName!, "bar", "Failed: User last name didn't match.")
XCTAssertEqual(user!.name!, "Foo Bar", "Failed: User name didn't match.")
XCTAssertEqual(user!.settings!.currency!, "USD", "Failed: User settings currency didn't match.")
XCTAssertTrue(user!.settings!.hasMarketingConsent!, "Failed: User settings hasMarketingConsent didn't match.")
XCTAssertTrue(user!.settings!.hasNewsSubscription!, "Failed: User settings hasNewsSubscription didn't match.")
XCTAssertEqual(user!.settings!.intl!.dateTimeFormat!.locale!, "en-US", "Failed: User settings intl dateTimeFormat didn't match.")
XCTAssertEqual(user!.settings!.intl!.language!.locale!, "en-US", "Failed: User settings intl language didn't match.")
Expand Down
3 changes: 2 additions & 1 deletion Tests/UtilTests/Fixtures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public class Fixtures {
"currency": faker.lorem.characters(amount: 3),
"email": faker.internet.email(),
"firstName": faker.name.firstName(),
"hasMarketingConsent": "true",
"hasNewsSubscription": "true",
"internationalizationUserSettingDateTimeFormat": faker.lorem.characters(amount: 5),
"internationalizationUserSettingLanguage": faker.lorem.characters(amount: 5),
Expand Down Expand Up @@ -285,7 +286,7 @@ public class Fixtures {
let internationalizationUserSettingNumberFormat = InternationalizationUserSetting(locale: fakerFields["internationalizationUserSettingNumberFormat"]!)
let internationalizationUserSettings = InternationalizationUserSettings(language: internationalizationUserSettingLanguage, dateTimeFormat: internationalizationUserSettingDateTimeFormat, numberFormat: internationalizationUserSettingNumberFormat)
let otp = Otp(login: Login(enabled: NSString(string: fakerFields["settingsOTPLogin"]!).boolValue), transactions: Transactions(send: Send(enabled: NSString(string: fakerFields["settingsOTPTransactionsSend"]!).boolValue), transfer: Transfer(enabled: NSString(string: fakerFields["settingsOTPTransactionsTransfer"]!).boolValue), withdraw: Withdraw(crypto: Crypto(enabled: NSString(string: fakerFields["settingsOTPTransactionsWithdrawCrypto"]!).boolValue))))
let userSettings = UserSettings(currency: fakerFields["currency"]!, hasNewsSubscription: NSString(string: fakerFields["hasNewsSubscription"]!).boolValue, intl: internationalizationUserSettings, otp: otp, theme: fakerFields["theme"]!)
let userSettings = UserSettings(currency: fakerFields["currency"]!, hasMarketingConsent: NSString(string: fakerFields["hasMarketingConsent"]!).boolValue, hasNewsSubscription: NSString(string: fakerFields["hasNewsSubscription"]!).boolValue, intl: internationalizationUserSettings, otp: otp, theme: fakerFields["theme"]!)
let addressVerifications = VerificationParameter(reason: fakerFields["verificationsReasonAddress"]!, status: fakerFields["verificationsStatusAddress"]!)
let birthdateVerifications = VerificationParameter(reason: fakerFields["verificationsReasonBirthdate"]!, status: fakerFields["verificationsStatusBirthdate"]!)
let documentsVerifications = VerificationParameter(reason: fakerFields["verificationsReasonDocuments"]!, status: fakerFields["verificationsStatusDocuments"]!)
Expand Down

0 comments on commit 5ac89e4

Please sign in to comment.