{"action":"created","comment":{"url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/pulls/comments/85949138","pull_request_review_id":6627716,"id":85949138,"diff_hunk":"@@ -0,0 +1,118 @@\n+//\n+//  MovieService.swift\n+//  ArcTouch\n+//\n+//  Created by Rodrigo Kieffer on 10/29/16.\n+//  Copyright © 2016 Rodrigo Kieffer. All rights reserved.\n+//\n+\n+import UIKit\n+import Alamofire\n+import Mantle\n+\n+class MovieService: NSObject {\n+\n+    private let apiKey = \"1f54bd990f1cdfb230adb312546d765d\"\n+    \n+    func genres(success: (([Genre]) -> Void)?, failure: ((NSError?) -> Void)?) {\n+        let url = \"https://api.themoviedb.org/3/genre/movie/list?api_key=\\(apiKey)\"\n+        \n+        Alamofire.request(url, method: .get, parameters: nil, encoding: JSONEncoding.default)\n+            .validate()\n+            .responseJSON { response in\n+                debugPrint(response)\n+                \n+                switch response.result {\n+                case .success:\n+                    do {\n+                        if let json = response.result.value as? [String : AnyObject] {\n+                            let genres = try MTLJSONAdapter.models(of: Genre.self, fromJSONArray: json[\"genres\"] as! [[String : AnyObject]])\n+                            if success != nil {\n+                                success!(genres as! [Genre])\n+                            }\n+                        }\n+                    } catch {\n+                        if failure != nil {\n+                            print(\"MovieService - genres : Error when parsing JSON\")\n+                            let error = ErrorHelper.createError(errorCode: Error.code.undefined, message: Error.message.undefined)\n+                            failure!(error)\n+                        }\n+                    }\n+                case .failure:\n+                    if failure != nil {\n+                        let error = ErrorHelper.createError(errorCode: Error.code.genres, message: Error.message.genres)\n+                        failure!(error)\n+                    }\n+                }\n+        }\n+\n+    }\n+    \n+    func upcomingMovies(page: Int, success: ((UpcomingMovies) -> Void)?, failure: ((NSError?) -> Void)?) {\n+        let url = \"https://api.themoviedb.org/3/movie/upcoming?api_key=\\(apiKey)&page=\\(page)\"\n+        \n+        Alamofire.request(url, method: .get, parameters: nil, encoding: JSONEncoding.default)\n+            .validate()\n+            .responseJSON { response in\n+                debugPrint(response)\n+                \n+                switch response.result {\n+                case .success:\n+                    do {\n+                        if let json = response.result.value as? [String : AnyObject] {\n+                            let upcoming = try MTLJSONAdapter.model(of: UpcomingMovies.self, fromJSONDictionary: json)\n+                            if success != nil {\n+                                success!(upcoming as! UpcomingMovies)\n+                            }\n+                        }\n+                    } catch {\n+                        if failure != nil {\n+                            print(\"MovieService - upcomingMovies : Error when parsing JSON\")\n+                            let error = ErrorHelper.createError(errorCode: Error.code.undefined, message: Error.message.undefined)\n+                            failure!(error)\n+                        }\n+                    }\n+                case .failure:\n+                    if failure != nil {\n+                        let error = ErrorHelper.createError(errorCode: Error.code.upcomingMovies, message: Error.message.upcomingMovies)\n+                        failure!(error)\n+                    }\n+                }\n+        }\n+\n+    }\n+    \n+    func detail(movieId: Int, success: ((Movie) -> Void)?, failure: ((NSError?) -> Void)?) {","path":"ArcTouch/Services/MovieService.swift","position":85,"original_position":85,"commit_id":"5eb2b604b32591896f493f2c8b631de448537724","original_commit_id":"5eb2b604b32591896f493f2c8b631de448537724","user":{"login":"arctouch-julioflores","id":18124471,"avatar_url":"https://avatars.githubusercontent.com/u/18124471?v=3","gravatar_id":"","url":"https://api.github.com/users/arctouch-julioflores","html_url":"https://github.com/arctouch-julioflores","followers_url":"https://api.github.com/users/arctouch-julioflores/followers","following_url":"https://api.github.com/users/arctouch-julioflores/following{/other_user}","gists_url":"https://api.github.com/users/arctouch-julioflores/gists{/gist_id}","starred_url":"https://api.github.com/users/arctouch-julioflores/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arctouch-julioflores/subscriptions","organizations_url":"https://api.github.com/users/arctouch-julioflores/orgs","repos_url":"https://api.github.com/users/arctouch-julioflores/repos","events_url":"https://api.github.com/users/arctouch-julioflores/events{/privacy}","received_events_url":"https://api.github.com/users/arctouch-julioflores/received_events","type":"User","site_admin":false},"body":"I can see that the two methods above look very like to this one. Is it worth to figure out a way to avoid this code duplication?","created_at":"2016-11-01T15:17:39Z","updated_at":"2016-11-01T15:17:39Z","html_url":"https://github.com/rodrigokieffer/ArcTouch/pull/1#discussion_r85949138","pull_request_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/rodrigokieffer/ArcTouch/pulls/comments/85949138"},"html":{"href":"https://github.com/rodrigokieffer/ArcTouch/pull/1#discussion_r85949138"},"pull_request":{"href":"https://api.github.com/repos/rodrigokieffer/ArcTouch/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/pulls/1","id":91531199,"html_url":"https://github.com/rodrigokieffer/ArcTouch/pull/1","diff_url":"https://github.com/rodrigokieffer/ArcTouch/pull/1.diff","patch_url":"https://github.com/rodrigokieffer/ArcTouch/pull/1.patch","issue_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/issues/1","number":1,"state":"open","locked":false,"title":"ArcTouch Challenge","user":{"login":"rodrigokieffer","id":723727,"avatar_url":"https://avatars.githubusercontent.com/u/723727?v=3","gravatar_id":"","url":"https://api.github.com/users/rodrigokieffer","html_url":"https://github.com/rodrigokieffer","followers_url":"https://api.github.com/users/rodrigokieffer/followers","following_url":"https://api.github.com/users/rodrigokieffer/following{/other_user}","gists_url":"https://api.github.com/users/rodrigokieffer/gists{/gist_id}","starred_url":"https://api.github.com/users/rodrigokieffer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rodrigokieffer/subscriptions","organizations_url":"https://api.github.com/users/rodrigokieffer/orgs","repos_url":"https://api.github.com/users/rodrigokieffer/repos","events_url":"https://api.github.com/users/rodrigokieffer/events{/privacy}","received_events_url":"https://api.github.com/users/rodrigokieffer/received_events","type":"User","site_admin":false},"body":"Arctouch challenge pull request.\n","created_at":"2016-10-30T18:40:36Z","updated_at":"2016-11-01T15:30:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"56060f706dad6d912e615fbe7d12fe8c1b5ac225","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/pulls/1/commits","review_comments_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/pulls/1/comments","review_comment_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/issues/1/comments","statuses_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/statuses/5eb2b604b32591896f493f2c8b631de448537724","head":{"label":"rodrigokieffer:development","ref":"development","sha":"5eb2b604b32591896f493f2c8b631de448537724","user":{"login":"rodrigokieffer","id":723727,"avatar_url":"https://avatars.githubusercontent.com/u/723727?v=3","gravatar_id":"","url":"https://api.github.com/users/rodrigokieffer","html_url":"https://github.com/rodrigokieffer","followers_url":"https://api.github.com/users/rodrigokieffer/followers","following_url":"https://api.github.com/users/rodrigokieffer/following{/other_user}","gists_url":"https://api.github.com/users/rodrigokieffer/gists{/gist_id}","starred_url":"https://api.github.com/users/rodrigokieffer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rodrigokieffer/subscriptions","organizations_url":"https://api.github.com/users/rodrigokieffer/orgs","repos_url":"https://api.github.com/users/rodrigokieffer/repos","events_url":"https://api.github.com/users/rodrigokieffer/events{/privacy}","received_events_url":"https://api.github.com/users/rodrigokieffer/received_events","type":"User","site_admin":false},"repo":{"id":72312732,"name":"ArcTouch","full_name":"rodrigokieffer/ArcTouch","owner":{"login":"rodrigokieffer","id":723727,"avatar_url":"https://avatars.githubusercontent.com/u/723727?v=3","gravatar_id":"","url":"https://api.github.com/users/rodrigokieffer","html_url":"https://github.com/rodrigokieffer","followers_url":"https://api.github.com/users/rodrigokieffer/followers","following_url":"https://api.github.com/users/rodrigokieffer/following{/other_user}","gists_url":"https://api.github.com/users/rodrigokieffer/gists{/gist_id}","starred_url":"https://api.github.com/users/rodrigokieffer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rodrigokieffer/subscriptions","organizations_url":"https://api.github.com/users/rodrigokieffer/orgs","repos_url":"https://api.github.com/users/rodrigokieffer/repos","events_url":"https://api.github.com/users/rodrigokieffer/events{/privacy}","received_events_url":"https://api.github.com/users/rodrigokieffer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rodrigokieffer/ArcTouch","description":null,"fork":false,"url":"https://api.github.com/repos/rodrigokieffer/ArcTouch","forks_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/forks","keys_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/teams","hooks_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/hooks","issue_events_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/issues/events{/number}","events_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/events","assignees_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/assignees{/user}","branches_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/branches{/branch}","tags_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/tags","blobs_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/git/refs{/sha}","trees_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/statuses/{sha}","languages_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/languages","stargazers_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/stargazers","contributors_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/contributors","subscribers_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/subscribers","subscription_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/subscription","commits_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/commits{/sha}","git_commits_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/git/commits{/sha}","comments_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/comments{/number}","issue_comment_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/issues/comments{/number}","contents_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/contents/{+path}","compare_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/merges","archive_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/downloads","issues_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/issues{/number}","pulls_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/pulls{/number}","milestones_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/milestones{/number}","notifications_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/labels{/name}","releases_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/releases{/id}","deployments_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/deployments","created_at":"2016-10-29T22:29:47Z","updated_at":"2016-10-29T22:29:47Z","pushed_at":"2016-10-30T18:40:37Z","git_url":"git://github.com/rodrigokieffer/ArcTouch.git","ssh_url":"git@github.com:rodrigokieffer/ArcTouch.git","clone_url":"https://github.com/rodrigokieffer/ArcTouch.git","svn_url":"https://github.com/rodrigokieffer/ArcTouch","homepage":null,"size":791,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"rodrigokieffer:master","ref":"master","sha":"d0cbb91c09572ad9adf4fb268c4e5447a11b61ef","user":{"login":"rodrigokieffer","id":723727,"avatar_url":"https://avatars.githubusercontent.com/u/723727?v=3","gravatar_id":"","url":"https://api.github.com/users/rodrigokieffer","html_url":"https://github.com/rodrigokieffer","followers_url":"https://api.github.com/users/rodrigokieffer/followers","following_url":"https://api.github.com/users/rodrigokieffer/following{/other_user}","gists_url":"https://api.github.com/users/rodrigokieffer/gists{/gist_id}","starred_url":"https://api.github.com/users/rodrigokieffer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rodrigokieffer/subscriptions","organizations_url":"https://api.github.com/users/rodrigokieffer/orgs","repos_url":"https://api.github.com/users/rodrigokieffer/repos","events_url":"https://api.github.com/users/rodrigokieffer/events{/privacy}","received_events_url":"https://api.github.com/users/rodrigokieffer/received_events","type":"User","site_admin":false},"repo":{"id":72312732,"name":"ArcTouch","full_name":"rodrigokieffer/ArcTouch","owner":{"login":"rodrigokieffer","id":723727,"avatar_url":"https://avatars.githubusercontent.com/u/723727?v=3","gravatar_id":"","url":"https://api.github.com/users/rodrigokieffer","html_url":"https://github.com/rodrigokieffer","followers_url":"https://api.github.com/users/rodrigokieffer/followers","following_url":"https://api.github.com/users/rodrigokieffer/following{/other_user}","gists_url":"https://api.github.com/users/rodrigokieffer/gists{/gist_id}","starred_url":"https://api.github.com/users/rodrigokieffer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rodrigokieffer/subscriptions","organizations_url":"https://api.github.com/users/rodrigokieffer/orgs","repos_url":"https://api.github.com/users/rodrigokieffer/repos","events_url":"https://api.github.com/users/rodrigokieffer/events{/privacy}","received_events_url":"https://api.github.com/users/rodrigokieffer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rodrigokieffer/ArcTouch","description":null,"fork":false,"url":"https://api.github.com/repos/rodrigokieffer/ArcTouch","forks_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/forks","keys_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/teams","hooks_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/hooks","issue_events_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/issues/events{/number}","events_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/events","assignees_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/assignees{/user}","branches_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/branches{/branch}","tags_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/tags","blobs_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/git/refs{/sha}","trees_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/statuses/{sha}","languages_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/languages","stargazers_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/stargazers","contributors_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/contributors","subscribers_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/subscribers","subscription_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/subscription","commits_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/commits{/sha}","git_commits_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/git/commits{/sha}","comments_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/comments{/number}","issue_comment_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/issues/comments{/number}","contents_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/contents/{+path}","compare_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/merges","archive_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/downloads","issues_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/issues{/number}","pulls_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/pulls{/number}","milestones_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/milestones{/number}","notifications_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/labels{/name}","releases_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/releases{/id}","deployments_url":"https://api.github.com/repos/rodrigokieffer/ArcTouch/deployments","created_at":"2016-10-29T22:29:47Z","updated_at":"2016-10-29T22:29:47Z","pushed_at":"2016-10-30T18:40:37Z","git_url":"git://github.com/rodrigokieffer/ArcTouch.git","ssh_url":"git@github.com:rodrigokieffer/ArcTouch.git","clone_url":"https://github.com/rodrigokieffer/ArcTouch.git","svn_url":"https://github.com/rodrigokieffer/ArcTouch","homepage":null,"size":791,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rodrigokieffer/ArcTouch/pulls/1"},"html":{"href":"https://github.com/rodrigokieffer/ArcTouch/pull/1"},"issue":{"href":"https://api.github.com/repos/rodrigokieffer/ArcTouch/issues/1"},"comments":{"href":"https://api.github.com/repos/rodrigokieffer/ArcTouch/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/rodrigokieffer/ArcTouch/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/rodrigokieffer/ArcTouch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rodrigokieffer/ArcTouch/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/rodrigokieffer/ArcTouch/statuses/5eb2b604b32591896f493f2c8b631de448537724"}}}}
{"actor":{"display_login":"arctouch-julioflores"}}