Created
March 13, 2015 18:10
-
-
Save moudy/7fbdc6448ce7b9c0341a 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
extension DataStore { | |
enum Endpoint { | |
case OrganizationPosts(String) | |
case LikePost(Int) | |
case CreatePost | |
case CreatePostComment(Int) | |
case GetPostComments(Int) | |
var path: (method: Alamofire.Method, url:String) { | |
switch self { | |
case .CreatePost: | |
return (.POST, "organizations/me/posts") | |
case .OrganizationPosts(let organizationId): | |
return (.GET, "organizations/\(organizationId)/posts") | |
case .GetPostComments(let postId): | |
return (.GET, "posts/\(postId)/comments") | |
case .CreatePostComment(let postId): | |
return (.POST, "posts/\(postId)/comments") | |
case .LikePost(let postId): | |
return (.POST, "posts/\(postId)/like") | |
default: | |
return (.GET, "error") | |
} | |
} | |
func route(origin: String) -> (Alamofire.Method, String) { | |
return (path.method, "\(origin)/\(path.url)") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment