Created
July 8, 2019 06:26
-
-
Save satishbabariya/eee3138f0bc0ca02c4cc50fdb325728d 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
// MARK: - Resty Protocol Implementation | |
extension MyService: Resty { | |
var host: String { | |
return "https://jsonplaceholder.typicode.com/" | |
} | |
var path: String { | |
return "" | |
} | |
var endpoint: String { | |
switch self { | |
case .zen: | |
return "/zen" | |
case .showUser(let id), .updateUser(let id, _, _): | |
return "/users/\(id)" | |
case .createUser(_, _): | |
return "/users" | |
case .showAccounts: | |
return "/accounts" | |
} | |
} | |
var method: HTTPMethod { | |
switch self { | |
case .zen, .showUser, .showAccounts: | |
return .get | |
case .createUser, .updateUser: | |
return .post | |
} | |
} | |
var parameters: [String: Any]? { | |
return nil | |
} | |
var headers: [String: String]? { | |
return ["Content-type": "application/json"] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment