-
-
Save Juanpe/8c902c8c0c5f342767a67ee62308d5e2 to your computer and use it in GitHub Desktop.
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
//This defines the type of HTTP method used to perform the request | |
enum HTTPMethod: String { | |
case post = "POST" | |
case put = "PUT" | |
case get = "GET" | |
case delete = "DELETE" | |
case patch = "PATCH" | |
} | |
//This defines the parameters to pass along with the request | |
enum RequestParams { | |
case body(_: [String: Any]?) | |
case url(_: [String: Any]?) | |
} | |
//This is the `APIRequest` protocol you may implement other classes can conform | |
protocol APIRequest { | |
associatedtype Resource: Decodable | |
var baseURL: URL { get } | |
var path: String { get } | |
var method: HTTPMethod { get } | |
var parameters: RequestParams { get } | |
var headers: [String: Any]? { get } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment