{"action":"created","comment":{"url":"https://api.github.com/repos/mschead/upcoming-movies/pulls/comments/171015342","pull_request_review_id":99794574,"id":171015342,"diff_hunk":"@@ -0,0 +1,75 @@\n+//\n+//  MovieRequest.swift\n+//  upcoming-movies\n+//\n+//  Created by Marcos Schead on 23/02/18.\n+//  Copyright © 2018 Marcos Schead. All rights reserved.\n+//\n+\n+import Foundation\n+import Alamofire\n+\n+class MoviesRequester {\n+    \n+    let API_KEY: String = \"1f54bd990f1cdfb230adb312546d765d\"\n+    var genres: [GenreWrapper] = []\n+    \n+    func makeMovieRequest(page: Int = 1, completion: ((Result<ResultsPage>) -> Void)?) {\n+        \n+        let parameters: Parameters = [\n+            \"api_key\": API_KEY,\n+            \"language\": \"en-US\",\n+            \"page\": String(page)\n+        ]\n+        \n+        let url = URL(string: \"https://api.themoviedb.org/3/movie/upcoming\")\n+        Alamofire.request(url!, parameters: parameters).responseJSON { response in\n+            do {\n+                let pages = try JSONDecoder().decode(ResultsPage.self, from: response.data!)\n+                completion?(.success(pages))\n+            } catch {\n+                completion?(.failure(error))\n+            }\n+        }\n+    }\n+    \n+    func makeFirstPageRequest(page: Int = 1, completion: ((Result<ResultsPage>) -> Void)?) {\n+        \n+        makeGenresRequest { (result) in\n+            switch result {\n+            case .success(let resultsGenre):\n+                self.genres = resultsGenre.genres\n+                self.makeMovieRequest(completion: completion)\n+                \n+            case .failure(let error):\n+                print(\"error: \\(error.localizedDescription)\")\n+            }\n+        }\n+        \n+    }\n+    \n+    func makeGenresRequest(completion: ((Result<ResultsGenre>) -> Void)?) {\n+        let parameters: Parameters = [","path":"upcoming-movies/Services/MoviesRequester.swift","position":52,"original_position":52,"commit_id":"5447a70843669ef0c69b7fcfeff9cd820e394847","original_commit_id":"5447a70843669ef0c69b7fcfeff9cd820e394847","user":{"login":"mschead","id":9833524,"avatar_url":"https://avatars0.githubusercontent.com/u/9833524?v=4","gravatar_id":"","url":"https://api.github.com/users/mschead","html_url":"https://github.com/mschead","followers_url":"https://api.github.com/users/mschead/followers","following_url":"https://api.github.com/users/mschead/following{/other_user}","gists_url":"https://api.github.com/users/mschead/gists{/gist_id}","starred_url":"https://api.github.com/users/mschead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mschead/subscriptions","organizations_url":"https://api.github.com/users/mschead/orgs","repos_url":"https://api.github.com/users/mschead/repos","events_url":"https://api.github.com/users/mschead/events{/privacy}","received_events_url":"https://api.github.com/users/mschead/received_events","type":"User","site_admin":false},"body":"I could make the params an object attribute. Then, when it gets necessary, just create a new array on the method with the other attributes. In this code, the makeMovieRequest would create an new array with the page. This avoid code repetition (DRY principle) and it's better for changing some global information, like an API update, for instance.","created_at":"2018-02-27T18:10:25Z","updated_at":"2018-02-27T18:10:25Z","html_url":"https://github.com/mschead/upcoming-movies/pull/1#discussion_r171015342","pull_request_url":"https://api.github.com/repos/mschead/upcoming-movies/pulls/1","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/mschead/upcoming-movies/pulls/comments/171015342"},"html":{"href":"https://github.com/mschead/upcoming-movies/pull/1#discussion_r171015342"},"pull_request":{"href":"https://api.github.com/repos/mschead/upcoming-movies/pulls/1"}},"in_reply_to_id":170942669},"pull_request":{"url":"https://api.github.com/repos/mschead/upcoming-movies/pulls/1","id":171360387,"html_url":"https://github.com/mschead/upcoming-movies/pull/1","diff_url":"https://github.com/mschead/upcoming-movies/pull/1.diff","patch_url":"https://github.com/mschead/upcoming-movies/pull/1.patch","issue_url":"https://api.github.com/repos/mschead/upcoming-movies/issues/1","number":1,"state":"open","locked":false,"title":"Upcoming Movies app development","user":{"login":"mschead","id":9833524,"avatar_url":"https://avatars0.githubusercontent.com/u/9833524?v=4","gravatar_id":"","url":"https://api.github.com/users/mschead","html_url":"https://github.com/mschead","followers_url":"https://api.github.com/users/mschead/followers","following_url":"https://api.github.com/users/mschead/following{/other_user}","gists_url":"https://api.github.com/users/mschead/gists{/gist_id}","starred_url":"https://api.github.com/users/mschead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mschead/subscriptions","organizations_url":"https://api.github.com/users/mschead/orgs","repos_url":"https://api.github.com/users/mschead/repos","events_url":"https://api.github.com/users/mschead/events{/privacy}","received_events_url":"https://api.github.com/users/mschead/received_events","type":"User","site_admin":false},"body":"Pull request made to receive feedbacks","created_at":"2018-02-26T12:25:26Z","updated_at":"2018-02-27T18:10:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eaec071f6ffaf7287235e7bf19fea9f1d3db3bf2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mschead/upcoming-movies/pulls/1/commits","review_comments_url":"https://api.github.com/repos/mschead/upcoming-movies/pulls/1/comments","review_comment_url":"https://api.github.com/repos/mschead/upcoming-movies/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mschead/upcoming-movies/issues/1/comments","statuses_url":"https://api.github.com/repos/mschead/upcoming-movies/statuses/5447a70843669ef0c69b7fcfeff9cd820e394847","head":{"label":"mschead:development","ref":"development","sha":"5447a70843669ef0c69b7fcfeff9cd820e394847","user":{"login":"mschead","id":9833524,"avatar_url":"https://avatars0.githubusercontent.com/u/9833524?v=4","gravatar_id":"","url":"https://api.github.com/users/mschead","html_url":"https://github.com/mschead","followers_url":"https://api.github.com/users/mschead/followers","following_url":"https://api.github.com/users/mschead/following{/other_user}","gists_url":"https://api.github.com/users/mschead/gists{/gist_id}","starred_url":"https://api.github.com/users/mschead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mschead/subscriptions","organizations_url":"https://api.github.com/users/mschead/orgs","repos_url":"https://api.github.com/users/mschead/repos","events_url":"https://api.github.com/users/mschead/events{/privacy}","received_events_url":"https://api.github.com/users/mschead/received_events","type":"User","site_admin":false},"repo":{"id":122513685,"name":"upcoming-movies","full_name":"mschead/upcoming-movies","owner":{"login":"mschead","id":9833524,"avatar_url":"https://avatars0.githubusercontent.com/u/9833524?v=4","gravatar_id":"","url":"https://api.github.com/users/mschead","html_url":"https://github.com/mschead","followers_url":"https://api.github.com/users/mschead/followers","following_url":"https://api.github.com/users/mschead/following{/other_user}","gists_url":"https://api.github.com/users/mschead/gists{/gist_id}","starred_url":"https://api.github.com/users/mschead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mschead/subscriptions","organizations_url":"https://api.github.com/users/mschead/orgs","repos_url":"https://api.github.com/users/mschead/repos","events_url":"https://api.github.com/users/mschead/events{/privacy}","received_events_url":"https://api.github.com/users/mschead/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mschead/upcoming-movies","description":null,"fork":false,"url":"https://api.github.com/repos/mschead/upcoming-movies","forks_url":"https://api.github.com/repos/mschead/upcoming-movies/forks","keys_url":"https://api.github.com/repos/mschead/upcoming-movies/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mschead/upcoming-movies/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mschead/upcoming-movies/teams","hooks_url":"https://api.github.com/repos/mschead/upcoming-movies/hooks","issue_events_url":"https://api.github.com/repos/mschead/upcoming-movies/issues/events{/number}","events_url":"https://api.github.com/repos/mschead/upcoming-movies/events","assignees_url":"https://api.github.com/repos/mschead/upcoming-movies/assignees{/user}","branches_url":"https://api.github.com/repos/mschead/upcoming-movies/branches{/branch}","tags_url":"https://api.github.com/repos/mschead/upcoming-movies/tags","blobs_url":"https://api.github.com/repos/mschead/upcoming-movies/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mschead/upcoming-movies/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mschead/upcoming-movies/git/refs{/sha}","trees_url":"https://api.github.com/repos/mschead/upcoming-movies/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mschead/upcoming-movies/statuses/{sha}","languages_url":"https://api.github.com/repos/mschead/upcoming-movies/languages","stargazers_url":"https://api.github.com/repos/mschead/upcoming-movies/stargazers","contributors_url":"https://api.github.com/repos/mschead/upcoming-movies/contributors","subscribers_url":"https://api.github.com/repos/mschead/upcoming-movies/subscribers","subscription_url":"https://api.github.com/repos/mschead/upcoming-movies/subscription","commits_url":"https://api.github.com/repos/mschead/upcoming-movies/commits{/sha}","git_commits_url":"https://api.github.com/repos/mschead/upcoming-movies/git/commits{/sha}","comments_url":"https://api.github.com/repos/mschead/upcoming-movies/comments{/number}","issue_comment_url":"https://api.github.com/repos/mschead/upcoming-movies/issues/comments{/number}","contents_url":"https://api.github.com/repos/mschead/upcoming-movies/contents/{+path}","compare_url":"https://api.github.com/repos/mschead/upcoming-movies/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mschead/upcoming-movies/merges","archive_url":"https://api.github.com/repos/mschead/upcoming-movies/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mschead/upcoming-movies/downloads","issues_url":"https://api.github.com/repos/mschead/upcoming-movies/issues{/number}","pulls_url":"https://api.github.com/repos/mschead/upcoming-movies/pulls{/number}","milestones_url":"https://api.github.com/repos/mschead/upcoming-movies/milestones{/number}","notifications_url":"https://api.github.com/repos/mschead/upcoming-movies/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mschead/upcoming-movies/labels{/name}","releases_url":"https://api.github.com/repos/mschead/upcoming-movies/releases{/id}","deployments_url":"https://api.github.com/repos/mschead/upcoming-movies/deployments","created_at":"2018-02-22T17:47:42Z","updated_at":"2018-02-22T17:53:44Z","pushed_at":"2018-02-27T01:56:48Z","git_url":"git://github.com/mschead/upcoming-movies.git","ssh_url":"git@github.com:mschead/upcoming-movies.git","clone_url":"https://github.com/mschead/upcoming-movies.git","svn_url":"https://github.com/mschead/upcoming-movies","homepage":null,"size":1665,"stargazers_count":0,"watchers_count":0,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"mschead:master","ref":"master","sha":"16054c443722ba6c51d2a1ea1f9294991b0d9430","user":{"login":"mschead","id":9833524,"avatar_url":"https://avatars0.githubusercontent.com/u/9833524?v=4","gravatar_id":"","url":"https://api.github.com/users/mschead","html_url":"https://github.com/mschead","followers_url":"https://api.github.com/users/mschead/followers","following_url":"https://api.github.com/users/mschead/following{/other_user}","gists_url":"https://api.github.com/users/mschead/gists{/gist_id}","starred_url":"https://api.github.com/users/mschead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mschead/subscriptions","organizations_url":"https://api.github.com/users/mschead/orgs","repos_url":"https://api.github.com/users/mschead/repos","events_url":"https://api.github.com/users/mschead/events{/privacy}","received_events_url":"https://api.github.com/users/mschead/received_events","type":"User","site_admin":false},"repo":{"id":122513685,"name":"upcoming-movies","full_name":"mschead/upcoming-movies","owner":{"login":"mschead","id":9833524,"avatar_url":"https://avatars0.githubusercontent.com/u/9833524?v=4","gravatar_id":"","url":"https://api.github.com/users/mschead","html_url":"https://github.com/mschead","followers_url":"https://api.github.com/users/mschead/followers","following_url":"https://api.github.com/users/mschead/following{/other_user}","gists_url":"https://api.github.com/users/mschead/gists{/gist_id}","starred_url":"https://api.github.com/users/mschead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mschead/subscriptions","organizations_url":"https://api.github.com/users/mschead/orgs","repos_url":"https://api.github.com/users/mschead/repos","events_url":"https://api.github.com/users/mschead/events{/privacy}","received_events_url":"https://api.github.com/users/mschead/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mschead/upcoming-movies","description":null,"fork":false,"url":"https://api.github.com/repos/mschead/upcoming-movies","forks_url":"https://api.github.com/repos/mschead/upcoming-movies/forks","keys_url":"https://api.github.com/repos/mschead/upcoming-movies/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mschead/upcoming-movies/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mschead/upcoming-movies/teams","hooks_url":"https://api.github.com/repos/mschead/upcoming-movies/hooks","issue_events_url":"https://api.github.com/repos/mschead/upcoming-movies/issues/events{/number}","events_url":"https://api.github.com/repos/mschead/upcoming-movies/events","assignees_url":"https://api.github.com/repos/mschead/upcoming-movies/assignees{/user}","branches_url":"https://api.github.com/repos/mschead/upcoming-movies/branches{/branch}","tags_url":"https://api.github.com/repos/mschead/upcoming-movies/tags","blobs_url":"https://api.github.com/repos/mschead/upcoming-movies/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mschead/upcoming-movies/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mschead/upcoming-movies/git/refs{/sha}","trees_url":"https://api.github.com/repos/mschead/upcoming-movies/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mschead/upcoming-movies/statuses/{sha}","languages_url":"https://api.github.com/repos/mschead/upcoming-movies/languages","stargazers_url":"https://api.github.com/repos/mschead/upcoming-movies/stargazers","contributors_url":"https://api.github.com/repos/mschead/upcoming-movies/contributors","subscribers_url":"https://api.github.com/repos/mschead/upcoming-movies/subscribers","subscription_url":"https://api.github.com/repos/mschead/upcoming-movies/subscription","commits_url":"https://api.github.com/repos/mschead/upcoming-movies/commits{/sha}","git_commits_url":"https://api.github.com/repos/mschead/upcoming-movies/git/commits{/sha}","comments_url":"https://api.github.com/repos/mschead/upcoming-movies/comments{/number}","issue_comment_url":"https://api.github.com/repos/mschead/upcoming-movies/issues/comments{/number}","contents_url":"https://api.github.com/repos/mschead/upcoming-movies/contents/{+path}","compare_url":"https://api.github.com/repos/mschead/upcoming-movies/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mschead/upcoming-movies/merges","archive_url":"https://api.github.com/repos/mschead/upcoming-movies/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mschead/upcoming-movies/downloads","issues_url":"https://api.github.com/repos/mschead/upcoming-movies/issues{/number}","pulls_url":"https://api.github.com/repos/mschead/upcoming-movies/pulls{/number}","milestones_url":"https://api.github.com/repos/mschead/upcoming-movies/milestones{/number}","notifications_url":"https://api.github.com/repos/mschead/upcoming-movies/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mschead/upcoming-movies/labels{/name}","releases_url":"https://api.github.com/repos/mschead/upcoming-movies/releases{/id}","deployments_url":"https://api.github.com/repos/mschead/upcoming-movies/deployments","created_at":"2018-02-22T17:47:42Z","updated_at":"2018-02-22T17:53:44Z","pushed_at":"2018-02-27T01:56:48Z","git_url":"git://github.com/mschead/upcoming-movies.git","ssh_url":"git@github.com:mschead/upcoming-movies.git","clone_url":"https://github.com/mschead/upcoming-movies.git","svn_url":"https://github.com/mschead/upcoming-movies","homepage":null,"size":1665,"stargazers_count":0,"watchers_count":0,"language":"Swift","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mschead/upcoming-movies/pulls/1"},"html":{"href":"https://github.com/mschead/upcoming-movies/pull/1"},"issue":{"href":"https://api.github.com/repos/mschead/upcoming-movies/issues/1"},"comments":{"href":"https://api.github.com/repos/mschead/upcoming-movies/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/mschead/upcoming-movies/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/mschead/upcoming-movies/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mschead/upcoming-movies/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/mschead/upcoming-movies/statuses/5447a70843669ef0c69b7fcfeff9cd820e394847"}},"author_association":"OWNER"}}
{"actor":{"display_login":"mschead"}}