{"action":"created","issue":{"url":"https://api.github.com/repos/iic-ninjas/PSix-iOS/issues/4","labels_url":"https://api.github.com/repos/iic-ninjas/PSix-iOS/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/iic-ninjas/PSix-iOS/issues/4/comments","events_url":"https://api.github.com/repos/iic-ninjas/PSix-iOS/issues/4/events","html_url":"https://github.com/iic-ninjas/PSix-iOS/pull/4","id":69781001,"number":4,"title":"Facebook Requests Refactor","user":{"login":"avihut","id":821024,"avatar_url":"https://avatars.githubusercontent.com/u/821024?v=3","gravatar_id":"","url":"https://api.github.com/users/avihut","html_url":"https://github.com/avihut","followers_url":"https://api.github.com/users/avihut/followers","following_url":"https://api.github.com/users/avihut/following{/other_user}","gists_url":"https://api.github.com/users/avihut/gists{/gist_id}","starred_url":"https://api.github.com/users/avihut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avihut/subscriptions","organizations_url":"https://api.github.com/users/avihut/orgs","repos_url":"https://api.github.com/users/avihut/repos","events_url":"https://api.github.com/users/avihut/events{/privacy}","received_events_url":"https://api.github.com/users/avihut/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-21T08:23:04Z","updated_at":"2015-04-21T08:56:13Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/iic-ninjas/PSix-iOS/pulls/4","html_url":"https://github.com/iic-ninjas/PSix-iOS/pull/4","diff_url":"https://github.com/iic-ninjas/PSix-iOS/pull/4.diff","patch_url":"https://github.com/iic-ninjas/PSix-iOS/pull/4.patch"},"body":"There are no visual changes. This started as a refactor to simplify the interfaces between the different services and parsers, but grew into something bigger the merits its own pull request.\r\n\r\nI created a chainable Facebook request class that allows for better readability.\r\n\r\nCode like this:\r\n\r\n    let request = FBSDKGraphRequest(graphPath: \"me\", parameters[\"fields\": \"name,id\"])\r\n    request.startWithCompletionHandler() { /* handle response */ }\r\n\r\nTurns into this:\r\n\r\n    FBRequest(forResource: \"me\").addParam(\"fields\", \"name,id\").execute() { /* handle response */ }\r\n\r\nWhich I further simplified by subclassing `FBRequest` with request classes for specific resources:\r\n\r\n    FBUserRequest(fbId: \"me\").attributes([\"name\", \"id\"]).execute() { /* handle response */ }\r\n\r\nThough the biggest change comes to the events request as you'll be able to see in the diff of `FacebookService.swift`\r\n\r\nFurthermore the request execution accepts 2 callback handlers `success` and `failure`. `failure` is given only `NSError?`, and `success` is given an `FBResponse` object. `FBResponse` is wrap around the regular `JSON` response that gives the same basic read interface through `subscript` and also *drumroll* handles paginated requests. Just check if the response has a next page, and it will generate an `FBRequest` for that next page automatically."},"comment":{"url":"https://api.github.com/repos/iic-ninjas/PSix-iOS/issues/comments/94709585","html_url":"https://github.com/iic-ninjas/PSix-iOS/pull/4#issuecomment-94709585","issue_url":"https://api.github.com/repos/iic-ninjas/PSix-iOS/issues/4","id":94709585,"user":{"login":"agelber","id":2394509,"avatar_url":"https://avatars.githubusercontent.com/u/2394509?v=3","gravatar_id":"","url":"https://api.github.com/users/agelber","html_url":"https://github.com/agelber","followers_url":"https://api.github.com/users/agelber/followers","following_url":"https://api.github.com/users/agelber/following{/other_user}","gists_url":"https://api.github.com/users/agelber/gists{/gist_id}","starred_url":"https://api.github.com/users/agelber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agelber/subscriptions","organizations_url":"https://api.github.com/users/agelber/orgs","repos_url":"https://api.github.com/users/agelber/repos","events_url":"https://api.github.com/users/agelber/events{/privacy}","received_events_url":"https://api.github.com/users/agelber/received_events","type":"User","site_admin":false},"created_at":"2015-04-21T08:56:13Z","updated_at":"2015-04-21T08:56:13Z","body":"![](http://media1.giphy.com/media/RfzzO0Y4SKyJy/giphy.gif)"}}