Created
June 18, 2020 14:16
-
-
Save stevencurtis/2e94068bd1d8757b123775278b6c869b to your computer and use it in GitHub Desktop.
JSONPlaceHolderAPIAction
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
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