Created
April 11, 2021 20:49
-
-
Save TheiOSDude/9fb26d2f5b4e3c8bdd430b2f64adf48d to your computer and use it in GitHub Desktop.
NameService.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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