Skip to content

Instantly share code, notes, and snippets.

@TheiOSDude
Created April 11, 2021 20:49
Show Gist options
  • Save TheiOSDude/9fb26d2f5b4e3c8bdd430b2f64adf48d to your computer and use it in GitHub Desktop.
Save TheiOSDude/9fb26d2f5b4e3c8bdd430b2f64adf48d to your computer and use it in GitHub Desktop.
NameService.swift
struct PersonName: Codable {
var firstName: String
var lastName: String
}
final class NameService {
private var apiClient: APIClientProtocol
init(apiClient: APIClientProtocol) {
self.apiClient = apiClient
}
func getNames(_ completion: @escaping (Result<[PersonName], NetworkLoaderError>) -> ()) throws {
let request = try APIRequest(root: "https://theiosdude.api.com", path: "test", method: "GET").urlRequest()
self.apiClient.request(request) { (result: Result<[PersonName], NetworkLoaderError> ) in
completion(result)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment