Skip to content

Commit

Permalink
Merge pull request #8 from UseAlloy/feature/sc-118545/add-additional-…
Browse files Browse the repository at this point in the history
…items-and-open-keys-on-the

Feature/sc-118545/add-additional-items-and-open-keys-on-the
  • Loading branch information
mrestuccia authored May 10, 2023
2 parents 160f1a4 + f95a783 commit e8d4bf5
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 8 deletions.
10 changes: 5 additions & 5 deletions Example/AlloyCodelessLiteiOSDemo/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct ContentView: View {
// *** this key is part of a working example ***
// You should obtain your key from the alloy dashboard
// On settings > SDK Config
apiKey: "7db38092-3df1-4e56-8d01-3a92478485ba",
apiKey: "9ca83767-f213-4aaf-bc1b-1ed0a89eaf23",
production: false,
realProduction: true,
codelessFinalValidation: false
Expand Down Expand Up @@ -68,13 +68,13 @@ struct ContentView: View {
resumeJourney.toggle()
// We are creating 2 entities for the journey application using only first and last name.
// The Entity data needed will vary depending on the services associated to your workflows.
let entityDataPerson = Entity.EntityData(nameFirst: "John", nameLast: "Doe")
let entityDataPerson2 = Entity.EntityData(nameFirst: "Julie", nameLast: "Tam")
let entityDataPerson = Entity.EntityData(nameFirst: "John", nameLast: "Doe", phoneNumber: "5555555555", emailAddress: "[email protected]", documentSsn: "111111112")
let entityDataPerson2 = Entity.EntityData(nameFirst: "Julie", nameLast: "Tam", addressCountryCode: "US", documentSsn: "111111111")
// We add the entity data to an entity structure. Entity type can be person or business
// The branch name needs to match the branch names on your journey.
// If you only have one branch, you don't need to pass a branch name.
let entityPerson = Entity(entityData: entityDataPerson, entityType: "person", branchName: "vouched")
let entityPerson2 = Entity(entityData: entityDataPerson2, entityType: "person", branchName: "veriff")
let entityPerson = Entity(entityData: entityDataPerson, entityType: "person", branchName: "vouched", externalEntityId: "EX-1234x")
let entityPerson2 = Entity(entityData: entityDataPerson2, entityType: "person", branchName: "veriff", externalEntityId: "EX-5678x")

let entities = EntityData(entities: [entityPerson, entityPerson2], additionalEntities: false)
// *** this key is part of a working example ***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,127 @@ public struct Entity: Codable {
public struct EntityData: Codable {
public let nameFirst: String
public let nameLast: String
public let nameMiddle: String?
public let phoneNumber: String?
public let emailAddress: String?
public let addressLine1: String?
public let addressLine2: String?
public let addressCity: String?
public let addressState: String?
public let addressPostalCode: String?
public let addressCountryCode: String?
public let birthDate: String?
public let documentSsn: String?
public let documentIdCard: String?
public let documentLicense: String?
public let documentPassport: String?
public let gender: String?

// MARK: CodingKeys

public enum CodingKeys: String, CodingKey {
case nameFirst = "name_first"
case nameLast = "name_last"
case nameMiddle = "name_middle"
case phoneNumber = "phone_number"
case emailAddress = "email_address"
case addressLine1 = "address_line_1"
case addressLine2 = "address_line_2"
case addressCity = "address_city"
case addressState = "address_state"
case addressPostalCode = "address_postal_code"
case addressCountryCode = "address_country_code"
case birthDate = "birth_date"
case documentSsn = "document_ssn"
case documentIdCard = "document_id_card"
case documentLicense = "document_license"
case documentPassport = "document_passport"
case gender = "gender"
}

// MARK: Initializers

public init(nameFirst: String, nameLast: String) {
public init(
nameFirst: String,
nameLast: String,
nameMiddle: String? = nil,
phoneNumber: String? = nil,
emailAddress: String? = nil,
addressLine1: String? = nil,
addressLine2: String? = nil,
addressCity: String? = nil,
addressState: String? = nil,
addressPostalCode: String? = nil,
addressCountryCode: String? = nil,
birthDate: String? = nil,
documentSsn: String? = nil,
documentIdCard: String? = nil,
documentLicense: String? = nil,
documentPassport: String? = nil,
gender: String? = nil) {
self.nameFirst = nameFirst
self.nameLast = nameLast
self.nameMiddle = nameMiddle
self.phoneNumber = phoneNumber
self.emailAddress = emailAddress
self.addressLine1 = addressLine1
self.addressLine2 = addressLine2
self.addressCity = addressCity
self.addressState = addressState
self.addressPostalCode = addressPostalCode
self.addressCountryCode = addressCountryCode
self.birthDate = birthDate
self.documentSsn = documentSsn
self.documentIdCard = documentIdCard
self.documentLicense = documentLicense
self.documentPassport = documentPassport
self.gender = gender
}

public init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)

nameFirst = try values.decode(String.self, forKey: .nameFirst)
nameLast = try values.decode(String.self, forKey: .nameLast)
nameMiddle = try values.decodeIfPresent(String.self, forKey: .nameMiddle)
phoneNumber = try values.decodeIfPresent(String.self, forKey: .phoneNumber)
emailAddress = try values.decodeIfPresent(String.self, forKey: .emailAddress)
addressLine1 = try values.decodeIfPresent(String.self, forKey: .addressLine1)
addressLine2 = try values.decodeIfPresent(String.self, forKey: .addressLine2)
addressCity = try values.decodeIfPresent(String.self, forKey: .addressCity)
addressState = try values.decodeIfPresent(String.self, forKey: .addressState)
addressPostalCode = try values.decodeIfPresent(String.self, forKey: .addressPostalCode)
addressCountryCode = try values.decodeIfPresent(String.self, forKey: .addressCountryCode)
birthDate = try values.decodeIfPresent(String.self, forKey: .birthDate)
documentSsn = try values.decodeIfPresent(String.self, forKey: .documentSsn)
documentIdCard = try values.decodeIfPresent(String.self, forKey: .documentIdCard)
documentLicense = try values.decodeIfPresent(String.self, forKey: .documentLicense)
documentPassport = try values.decodeIfPresent(String.self, forKey: .documentPassport)
gender = try values.decodeIfPresent(String.self, forKey: .gender)
}
}

let entityData: EntityData
let entityType: String
let branchName: String
let externalEntityId: String?


// MARK: CodingKeys

public enum CodingKeys: String, CodingKey {
case entityData = "data"
case entityType = "entity_type"
case branchName = "branch_name"
case externalEntityId = "external_entity_id"
}

// MARK: Initializers

public init(entityData: EntityData, entityType: String, branchName: String) {
public init(entityData: EntityData, entityType: String, branchName: String, externalEntityId: String? = nil) {
self.entityData = entityData
self.entityType = entityType
self.branchName = branchName
self.externalEntityId = externalEntityId
}

public init(from decoder: Decoder) throws {
Expand All @@ -60,6 +140,7 @@ public struct Entity: Codable {
entityData = try values.decode(EntityData.self, forKey: .entityData)
entityType = try values.decode(String.self, forKey: .entityType)
branchName = try values.decode(String.self, forKey: .branchName)
externalEntityId = try values.decodeIfPresent(String.self, forKey: .externalEntityId)
}

public func encode(to encoder: Encoder) throws {
Expand All @@ -69,6 +150,7 @@ public struct Entity: Codable {
try container.encode(entityData, forKey: .entityData)
try container.encode(entityType, forKey: .entityType)
try container.encode(branchName, forKey: .branchName)
try container.encodeIfPresent(externalEntityId, forKey: .externalEntityId)
}

}

0 comments on commit e8d4bf5

Please sign in to comment.