Skip to content

Instantly share code, notes, and snippets.

@stevencurtis
Created June 18, 2020 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevencurtis/2e94068bd1d8757b123775278b6c869b to your computer and use it in GitHub Desktop.
Save stevencurtis/2e94068bd1d8757b123775278b6c869b to your computer and use it in GitHub Desktop.
JSONPlaceHolderAPIAction
import Foundation
import Alamofire
enum JSONPlaceHolderAPIAction {
case getToDo(id: Int)
}
extension JSONPlaceHolderAPIAction: APIRouter {
var actionParameters: [String : Any] {
[:]
}
var encoding: ParameterEncoding {
return URLEncoding.default
}
var authHeader: HTTPHeaders? {
return [:]
}
// HTTPMethod is declared by Alamofire
var method: HTTPMethod {
switch self {
case .getToDo:
return .get
}
}
var path: String {
switch self {
case .getToDo(let id):
return "todos/\(id)"
}
}
var baseURL: String {
return "https://jsonplaceholder.typicode.com/"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment