Last active
August 28, 2015 09:18
-
-
Save kuroyam/74b105f8826b460f14a8 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
class APIClient { | |
static func request(endpoint: Endpoint, parameters: Dictionary<String, String>?, handler: (result: Result) -> Void) { | |
// ここで通信 | |
} | |
} | |
enum Endpoint { | |
case Login | |
case Feed(String, Method) | |
func path() -> String { | |
switch self { | |
case .Login: return "/login" | |
case .Feed(let id, let method): return "/users/\(id)/feed" | |
} | |
} | |
func method() -> Method { | |
switch self { | |
case .Login: return .POST | |
case .Feed(let id, let method): return method | |
} | |
} | |
} | |
enum Method { | |
case GET | |
case POST | |
case PUT | |
case DELETE | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment