initial protocol and implementation
Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
9bc63d31cd
commit
a517ced1cc
10
EmployeeDirectory/Protocols/EmployeeServiceProtocol.swift
Normal file
10
EmployeeDirectory/Protocols/EmployeeServiceProtocol.swift
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
//
|
||||||
|
// EmployeeServiceable.swift
|
||||||
|
// EmployeeDirectory
|
||||||
|
//
|
||||||
|
// Created by Matt Bruce on 1/20/25.
|
||||||
|
//
|
||||||
|
|
||||||
|
public protocol EmployeeServiceProtocol {
|
||||||
|
func getEmployees() async throws -> [Employee]
|
||||||
|
}
|
||||||
19
EmployeeDirectory/Services/EmployeeService.swift
Normal file
19
EmployeeDirectory/Services/EmployeeService.swift
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
//
|
||||||
|
// EmployeeService.swift
|
||||||
|
// EmployeeDirectory
|
||||||
|
//
|
||||||
|
// Created by Matt Bruce on 1/20/25.
|
||||||
|
//
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
/// Service Layer for Employees
|
||||||
|
public class EmployeeService: EmployeeServiceProtocol {
|
||||||
|
|
||||||
|
/// Service to get Employees
|
||||||
|
/// - Returns: Array of Employee Structs
|
||||||
|
public func getEmployees() async throws -> [Employee] {
|
||||||
|
let employees: Employees = try await NetworkService.shared.fetchData(from: "https://jsonplaceholder.typicode.com/users", as: Employees.self)
|
||||||
|
return employees.employees
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user