created Models for the objects returned from the services
Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
255356ff19
commit
9bc63d31cd
70
EmployeeDirectory/Models/Employee.swift
Normal file
70
EmployeeDirectory/Models/Employee.swift
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
//
|
||||||
|
// Employee.swift
|
||||||
|
// EmployeeDirectory
|
||||||
|
//
|
||||||
|
// Created by Matt Bruce on 1/20/25.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
/// EmployeeType enum
|
||||||
|
/// - How the employee is classified.
|
||||||
|
public enum EmployeeType: String, Codable, CustomStringConvertible {
|
||||||
|
case fullTime = "FULL_TIME"
|
||||||
|
case partTime = "PART_TIME"
|
||||||
|
case contractor = "CONTRACTOR"
|
||||||
|
|
||||||
|
/// Format the employee type for display
|
||||||
|
public var description: String {
|
||||||
|
switch self {
|
||||||
|
case .fullTime: return "Full-Time"
|
||||||
|
case .partTime: return "Part-Time"
|
||||||
|
case .contractor: return "Contractor"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Employee Object
|
||||||
|
/// JSON Object defintion
|
||||||
|
/// - https://square.github.io/microsite/mobile-interview-project/
|
||||||
|
public struct Employee: Codable {
|
||||||
|
|
||||||
|
/// The unique identifier for the employee. Represented as a UUID.
|
||||||
|
public let uuid: UUID
|
||||||
|
|
||||||
|
/// The full name of the employee.
|
||||||
|
public let fullName: String
|
||||||
|
|
||||||
|
/// The phone number of the employee, sent as an unformatted string (eg, 5556661234).
|
||||||
|
public let phoneNumber: String?
|
||||||
|
|
||||||
|
/// The email address of the employee.
|
||||||
|
public let emailAddress: String
|
||||||
|
|
||||||
|
/// A short, tweet-length (~300 chars) string that the employee provided to describe themselves.
|
||||||
|
public let biography: String?
|
||||||
|
|
||||||
|
/// The URL of the employee’s small photo. Useful for list view.
|
||||||
|
public let photoURLSmall: String?
|
||||||
|
|
||||||
|
/// The URL of the employee’s full-size photo.
|
||||||
|
public let photoURLLarge: String?
|
||||||
|
|
||||||
|
/// The team they are on, represented as a human readable string.
|
||||||
|
public let team: String
|
||||||
|
|
||||||
|
/// How the employee is classified.
|
||||||
|
public let employeeType: EmployeeType
|
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case uuid
|
||||||
|
case fullName = "full_name"
|
||||||
|
case phoneNumber = "phone_number"
|
||||||
|
case emailAddress = "email_address"
|
||||||
|
case biography
|
||||||
|
case photoURLSmall = "photo_url_small"
|
||||||
|
case photoURLLarge = "photo_url_large"
|
||||||
|
case team
|
||||||
|
case employeeType = "employee_type"
|
||||||
|
}
|
||||||
|
}
|
||||||
16
EmployeeDirectory/Models/Employees.swift
Normal file
16
EmployeeDirectory/Models/Employees.swift
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// Employees.swift
|
||||||
|
// EmployeeDirectory
|
||||||
|
//
|
||||||
|
// Created by Matt Bruce on 1/20/25.
|
||||||
|
//
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
/// Wrapper JSON Class for the Employees
|
||||||
|
public struct Employees: Codable {
|
||||||
|
public var employees: [Employee]
|
||||||
|
|
||||||
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
case employees
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user