initial protocol and implementation

Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
Matt Bruce 2025-01-20 17:23:07 -06:00
parent 9bc63d31cd
commit a517ced1cc
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,10 @@
//
// EmployeeServiceable.swift
// EmployeeDirectory
//
// Created by Matt Bruce on 1/20/25.
//
public protocol EmployeeServiceProtocol {
func getEmployees() async throws -> [Employee]
}

View 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
}
}