{"action":"created","comment":{"url":"https://api.github.com/repos/bogusAvinash/On-The-Map/pulls/comments/60358844","id":60358844,"diff_hunk":"@@ -0,0 +1,192 @@\n+//\n+//  OTMClient.swift\n+//  On The Map\n+//\n+//  Created by Avinash Mudivedu on 4/12/16.\n+//  Copyright © 2016 Avinash Mudivedu. All rights reserved.\n+//\n+\n+import Foundation\n+\n+class OTMClient: NSObject {\n+    \n+    // MARK: Properties\n+    \n+    // shared session\n+    var session = NSURLSession.sharedSession()\n+    \n+    // authentication state\n+    var sessionID: String? = nil\n+    var uniqueKey: String? = nil\n+    var currentStudent: StudentInformation? = nil\n+    var students: [StudentInformation]? = nil\n+    \n+    // Store the data in a central spot\n+    var studentInformation: [StudentInformation] = [StudentInformation]()\n+    \n+    // MARK: Initializers\n+    \n+    override init() {\n+        super.init()\n+    }\n+    \n+    // MARK: - POST\n+    \n+    func taskForPOSTMethod(method: String, udacity: Bool, parameters: [String:AnyObject]?, jsonBody: [String:AnyObject], completionHandlerForPOST: (result: AnyObject!, error: NSError?) -> Void) -> NSURLSessionDataTask {\n+        \n+        /* 1. Set the parameters */\n+        var urlString: String\n+        \n+        if let methodParameters = parameters {\n+            urlString = method + OTMClient.escapedParameters(methodParameters)\n+        } else {\n+            urlString = method\n+        }\n+        \n+        /* 2/3. Build the URL, Configure the request */\n+        let url = NSURL(string: urlString)!\n+        let request = NSMutableURLRequest(URL: url)\n+        request.HTTPMethod = \"POST\"\n+        \n+        /* Is the request Udacity or Parse? */\n+        if udacity {\n+            request.addValue(\"application/json\", forHTTPHeaderField: \"Accept\")\n+            request.addValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\n+            \n+        } else {\n+            request.addValue(\"QrX47CA9cyuGewLdsL7o5Eb8iug6Em8ye0dnAbIr\", forHTTPHeaderField: \"X-Parse-Application-Id\")\n+            request.addValue(\"QuWThTdiRmTux3YaDseUSEpUKo7aBYM737yKd4gY\", forHTTPHeaderField: \"X-Parse-REST-API-Key\")\n+        }\n+        \n+        do {\n+            request.HTTPBody = try NSJSONSerialization.dataWithJSONObject(jsonBody, options: [])\n+        } catch _ as NSError {\n+            request.HTTPBody = nil\n+        }\n+        \n+    \n+        /* 4. Make the request */\n+        let task = session.dataTaskWithRequest(request) { (data, response, error) in\n+            \n+            if let JSONError = error {\n+                \n+                _ = OTMClient.errorForData(data, response: response, error: JSONError)\n+                print(error)\n+                completionHandlerForPOST(result: nil, error: error)\n+            } else {\n+                var newData = data\n+                if(udacity){\n+                    newData = data!.subdataWithRange(NSMakeRange(5, data!.length - 5)) \n+                }\n+                /* 5/6. Parse the data and use the data (happens in completion handler) */\n+                self.convertDataWithCompletionHandler(newData!, completionHandlerForConvertData: completionHandlerForPOST)\n+            }\n+            \n+        }\n+        \n+        /* 7. Start the request */\n+        task.resume()\n+        \n+        return task\n+    }\n+    \n+    // MARK: - GET\n+    \n+    func taskForGETMethod(method: String, udacity: Bool, parameters: [String:AnyObject]?, completionHandlerForGET: (result: AnyObject!, error: NSError?) -> Void) -> NSURLSessionDataTask {","path":"On The Map/OTMClient.swift","position":95,"original_position":95,"commit_id":"b57d385448d5cb2eec46374af4987ac7888a4113","original_commit_id":"b57d385448d5cb2eec46374af4987ac7888a4113","user":{"login":"roshkosh","id":18567540,"avatar_url":"https://avatars.githubusercontent.com/u/18567540?v=3","gravatar_id":"","url":"https://api.github.com/users/roshkosh","html_url":"https://github.com/roshkosh","followers_url":"https://api.github.com/users/roshkosh/followers","following_url":"https://api.github.com/users/roshkosh/following{/other_user}","gists_url":"https://api.github.com/users/roshkosh/gists{/gist_id}","starred_url":"https://api.github.com/users/roshkosh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roshkosh/subscriptions","organizations_url":"https://api.github.com/users/roshkosh/orgs","repos_url":"https://api.github.com/users/roshkosh/repos","events_url":"https://api.github.com/users/roshkosh/events{/privacy}","received_events_url":"https://api.github.com/users/roshkosh/received_events","type":"User","site_admin":false},"body":"Does the completion handler get an array of String dictionaries? Or an array of StudentInformations? Consider making result more specific than AnyObject 😄 ","created_at":"2016-04-20T07:08:34Z","updated_at":"2016-04-20T07:08:34Z","html_url":"https://github.com/bogusAvinash/On-The-Map/pull/1#discussion_r60358844","pull_request_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/bogusAvinash/On-The-Map/pulls/comments/60358844"},"html":{"href":"https://github.com/bogusAvinash/On-The-Map/pull/1#discussion_r60358844"},"pull_request":{"href":"https://api.github.com/repos/bogusAvinash/On-The-Map/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/bogusAvinash/On-The-Map/pulls/1","id":67133098,"html_url":"https://github.com/bogusAvinash/On-The-Map/pull/1","diff_url":"https://github.com/bogusAvinash/On-The-Map/pull/1.diff","patch_url":"https://github.com/bogusAvinash/On-The-Map/pull/1.patch","issue_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/issues/1","number":1,"state":"open","locked":false,"title":"huge first commit","user":{"login":"bogusAvinash","id":18566999,"avatar_url":"https://avatars.githubusercontent.com/u/18566999?v=3","gravatar_id":"","url":"https://api.github.com/users/bogusAvinash","html_url":"https://github.com/bogusAvinash","followers_url":"https://api.github.com/users/bogusAvinash/followers","following_url":"https://api.github.com/users/bogusAvinash/following{/other_user}","gists_url":"https://api.github.com/users/bogusAvinash/gists{/gist_id}","starred_url":"https://api.github.com/users/bogusAvinash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bogusAvinash/subscriptions","organizations_url":"https://api.github.com/users/bogusAvinash/orgs","repos_url":"https://api.github.com/users/bogusAvinash/repos","events_url":"https://api.github.com/users/bogusAvinash/events{/privacy}","received_events_url":"https://api.github.com/users/bogusAvinash/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-20T06:09:39Z","updated_at":"2016-04-20T07:08:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"62c22bc0fa344eedbb5a465323232aeed6a809d1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/pulls/1/commits","review_comments_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/pulls/1/comments","review_comment_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/issues/1/comments","statuses_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/statuses/b57d385448d5cb2eec46374af4987ac7888a4113","head":{"label":"bogusAvinash:first-branch","ref":"first-branch","sha":"b57d385448d5cb2eec46374af4987ac7888a4113","user":{"login":"bogusAvinash","id":18566999,"avatar_url":"https://avatars.githubusercontent.com/u/18566999?v=3","gravatar_id":"","url":"https://api.github.com/users/bogusAvinash","html_url":"https://github.com/bogusAvinash","followers_url":"https://api.github.com/users/bogusAvinash/followers","following_url":"https://api.github.com/users/bogusAvinash/following{/other_user}","gists_url":"https://api.github.com/users/bogusAvinash/gists{/gist_id}","starred_url":"https://api.github.com/users/bogusAvinash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bogusAvinash/subscriptions","organizations_url":"https://api.github.com/users/bogusAvinash/orgs","repos_url":"https://api.github.com/users/bogusAvinash/repos","events_url":"https://api.github.com/users/bogusAvinash/events{/privacy}","received_events_url":"https://api.github.com/users/bogusAvinash/received_events","type":"User","site_admin":false},"repo":{"id":56657183,"name":"On-The-Map","full_name":"bogusAvinash/On-The-Map","owner":{"login":"bogusAvinash","id":18566999,"avatar_url":"https://avatars.githubusercontent.com/u/18566999?v=3","gravatar_id":"","url":"https://api.github.com/users/bogusAvinash","html_url":"https://github.com/bogusAvinash","followers_url":"https://api.github.com/users/bogusAvinash/followers","following_url":"https://api.github.com/users/bogusAvinash/following{/other_user}","gists_url":"https://api.github.com/users/bogusAvinash/gists{/gist_id}","starred_url":"https://api.github.com/users/bogusAvinash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bogusAvinash/subscriptions","organizations_url":"https://api.github.com/users/bogusAvinash/orgs","repos_url":"https://api.github.com/users/bogusAvinash/repos","events_url":"https://api.github.com/users/bogusAvinash/events{/privacy}","received_events_url":"https://api.github.com/users/bogusAvinash/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bogusAvinash/On-The-Map","description":"","fork":false,"url":"https://api.github.com/repos/bogusAvinash/On-The-Map","forks_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/forks","keys_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/teams","hooks_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/hooks","issue_events_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/issues/events{/number}","events_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/events","assignees_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/assignees{/user}","branches_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/branches{/branch}","tags_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/tags","blobs_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/git/refs{/sha}","trees_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/statuses/{sha}","languages_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/languages","stargazers_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/stargazers","contributors_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/contributors","subscribers_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/subscribers","subscription_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/subscription","commits_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/commits{/sha}","git_commits_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/git/commits{/sha}","comments_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/comments{/number}","issue_comment_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/issues/comments{/number}","contents_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/contents/{+path}","compare_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/merges","archive_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/downloads","issues_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/issues{/number}","pulls_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/pulls{/number}","milestones_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/milestones{/number}","notifications_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/labels{/name}","releases_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/releases{/id}","deployments_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/deployments","created_at":"2016-04-20T05:12:21Z","updated_at":"2016-04-20T05:12:21Z","pushed_at":"2016-04-20T06:09:39Z","git_url":"git://github.com/bogusAvinash/On-The-Map.git","ssh_url":"git@github.com:bogusAvinash/On-The-Map.git","clone_url":"https://github.com/bogusAvinash/On-The-Map.git","svn_url":"https://github.com/bogusAvinash/On-The-Map","homepage":null,"size":140,"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":"bogusAvinash:master","ref":"master","sha":"988447e7ee90edd9f601a423213926dde76c1e78","user":{"login":"bogusAvinash","id":18566999,"avatar_url":"https://avatars.githubusercontent.com/u/18566999?v=3","gravatar_id":"","url":"https://api.github.com/users/bogusAvinash","html_url":"https://github.com/bogusAvinash","followers_url":"https://api.github.com/users/bogusAvinash/followers","following_url":"https://api.github.com/users/bogusAvinash/following{/other_user}","gists_url":"https://api.github.com/users/bogusAvinash/gists{/gist_id}","starred_url":"https://api.github.com/users/bogusAvinash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bogusAvinash/subscriptions","organizations_url":"https://api.github.com/users/bogusAvinash/orgs","repos_url":"https://api.github.com/users/bogusAvinash/repos","events_url":"https://api.github.com/users/bogusAvinash/events{/privacy}","received_events_url":"https://api.github.com/users/bogusAvinash/received_events","type":"User","site_admin":false},"repo":{"id":56657183,"name":"On-The-Map","full_name":"bogusAvinash/On-The-Map","owner":{"login":"bogusAvinash","id":18566999,"avatar_url":"https://avatars.githubusercontent.com/u/18566999?v=3","gravatar_id":"","url":"https://api.github.com/users/bogusAvinash","html_url":"https://github.com/bogusAvinash","followers_url":"https://api.github.com/users/bogusAvinash/followers","following_url":"https://api.github.com/users/bogusAvinash/following{/other_user}","gists_url":"https://api.github.com/users/bogusAvinash/gists{/gist_id}","starred_url":"https://api.github.com/users/bogusAvinash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bogusAvinash/subscriptions","organizations_url":"https://api.github.com/users/bogusAvinash/orgs","repos_url":"https://api.github.com/users/bogusAvinash/repos","events_url":"https://api.github.com/users/bogusAvinash/events{/privacy}","received_events_url":"https://api.github.com/users/bogusAvinash/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bogusAvinash/On-The-Map","description":"","fork":false,"url":"https://api.github.com/repos/bogusAvinash/On-The-Map","forks_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/forks","keys_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/teams","hooks_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/hooks","issue_events_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/issues/events{/number}","events_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/events","assignees_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/assignees{/user}","branches_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/branches{/branch}","tags_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/tags","blobs_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/git/refs{/sha}","trees_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/statuses/{sha}","languages_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/languages","stargazers_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/stargazers","contributors_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/contributors","subscribers_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/subscribers","subscription_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/subscription","commits_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/commits{/sha}","git_commits_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/git/commits{/sha}","comments_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/comments{/number}","issue_comment_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/issues/comments{/number}","contents_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/contents/{+path}","compare_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/merges","archive_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/downloads","issues_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/issues{/number}","pulls_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/pulls{/number}","milestones_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/milestones{/number}","notifications_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/labels{/name}","releases_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/releases{/id}","deployments_url":"https://api.github.com/repos/bogusAvinash/On-The-Map/deployments","created_at":"2016-04-20T05:12:21Z","updated_at":"2016-04-20T05:12:21Z","pushed_at":"2016-04-20T06:09:39Z","git_url":"git://github.com/bogusAvinash/On-The-Map.git","ssh_url":"git@github.com:bogusAvinash/On-The-Map.git","clone_url":"https://github.com/bogusAvinash/On-The-Map.git","svn_url":"https://github.com/bogusAvinash/On-The-Map","homepage":null,"size":140,"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/bogusAvinash/On-The-Map/pulls/1"},"html":{"href":"https://github.com/bogusAvinash/On-The-Map/pull/1"},"issue":{"href":"https://api.github.com/repos/bogusAvinash/On-The-Map/issues/1"},"comments":{"href":"https://api.github.com/repos/bogusAvinash/On-The-Map/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/bogusAvinash/On-The-Map/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/bogusAvinash/On-The-Map/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bogusAvinash/On-The-Map/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/bogusAvinash/On-The-Map/statuses/b57d385448d5cb2eec46374af4987ac7888a4113"}}}}