{"action":"created","comment":{"url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/pulls/comments/42401851","id":42401851,"diff_hunk":"@@ -31,46 +39,83 @@ public static Promise login(String username, String password) {\n         NetworkRequest.Callback callback = new NetworkRequest.Callback() {\n             @Override\n             public void done(@Nullable JSONObject jsonObject) {\n+                Log.d(TAG, \"login jsonObject:\" + jsonObject);\n+                try {\n+                    String sessionToken = jsonObject.getString(JsonKeys.SESSION_TOKEN);\n+                    String username = jsonObject.getString(JsonKeys.USERNAME);\n+                    String userId = jsonObject.getString(JsonKeys.OBJECTID);\n+\n+                    Context context = MyApplication.getContext();\n+                    SharedPreferences sharedPreferences = context\n+                            .getSharedPreferences(context.getString(R.string.login_or_sign_up_session), 0);\n+                    SharedPreferences.Editor editor = sharedPreferences.edit();\n+                    editor.putString(JsonKeys.SESSION_TOKEN, sessionToken);\n+                    editor.putString(JsonKeys.USERNAME, username);\n+                    editor.putString(JsonKeys.USERID, userId);\n+\n+                    JSONObject groupIdObj = jsonObject.optJSONObject(JsonKeys.GROUPID);\n+                    if (groupIdObj != null) {\n+                        String groupId = groupIdObj.optString(JsonKeys.OBJECTID);\n+                        editor.putString(JsonKeys.GROUPID, groupId);\n+                    }\n+                    editor.commit();\n \n-                Log.d(TAG, \"login jsonObject:\" + jsonObject.toString());\n-                String sessionToken = jsonObject.optString(\"sessionToken\");\n-                String username = jsonObject.optString(\"username\");\n+                    promise.onSuccess();\n \n-                SharedPreferences sharedPreferences = MyApplication.getContext().getSharedPreferences(\"login\", 0);\n-                SharedPreferences.Editor editor = sharedPreferences.edit();\n-                editor.putString(\"sessionToken\", sessionToken);\n-                editor.putString(\"username\", username);\n-                editor.commit();\n+                } catch (JSONException e) {\n+                    Log.e(TAG, \"login failure\", e);\n+                    promise.onFailure();\n+                }\n+            }\n+        };\n \n-                //TODO: update realm\n+        UrlTemplate template = UrlTemplateCreator.login(username, password);\n+        new NetworkRequest(template, callback).execute();\n+        return promise;\n+    }\n \n-                //TODO: update user preferences\n+    public static Promise logout() {\n+        final Promise promise = new Promise();\n \n+        NetworkRequest.Callback callback = new NetworkRequest.Callback() {\n+            @Override\n+            public void done(@Nullable JSONObject jsonObject) {\n                 promise.onSuccess();\n-\n-                //or promise.onFailure() depending\n             }\n         };\n \n-        UrlTemplate template = UrlTemplateCreator.login(username, password);\n+        UrlTemplate template = UrlTemplateCreator.logout();\n         new NetworkRequest(template, callback).execute();\n         return promise;\n     }\n \n-    public static Promise logout() {\n+    public static Promise signUp(String username, String password) {\n+\n         final Promise promise = new Promise();\n \n         NetworkRequest.Callback callback = new NetworkRequest.Callback() {\n             @Override\n             public void done(@Nullable JSONObject jsonObject) {","path":"app/src/main/java/com/quarkworks/apartmentgroceries/service/SyncUser.java","position":105,"original_position":105,"commit_id":"c8eb38793c26b06ce99bd877ded4afb75403b51d","original_commit_id":"c8eb38793c26b06ce99bd877ded4afb75403b51d","user":{"login":"JacobMuchow","id":5720430,"avatar_url":"https://avatars.githubusercontent.com/u/5720430?v=3","gravatar_id":"","url":"https://api.github.com/users/JacobMuchow","html_url":"https://github.com/JacobMuchow","followers_url":"https://api.github.com/users/JacobMuchow/followers","following_url":"https://api.github.com/users/JacobMuchow/following{/other_user}","gists_url":"https://api.github.com/users/JacobMuchow/gists{/gist_id}","starred_url":"https://api.github.com/users/JacobMuchow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JacobMuchow/subscriptions","organizations_url":"https://api.github.com/users/JacobMuchow/orgs","repos_url":"https://api.github.com/users/JacobMuchow/repos","events_url":"https://api.github.com/users/JacobMuchow/events{/privacy}","received_events_url":"https://api.github.com/users/JacobMuchow/received_events","type":"User","site_admin":false},"body":"Do a null check on jsonObject","created_at":"2015-10-19T17:41:50Z","updated_at":"2015-10-19T17:41:50Z","html_url":"https://github.com/JacobMuchow/ApartmentGroceries/pull/5#discussion_r42401851","pull_request_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/pulls/comments/42401851"},"html":{"href":"https://github.com/JacobMuchow/ApartmentGroceries/pull/5#discussion_r42401851"},"pull_request":{"href":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/pulls/5","id":48093492,"html_url":"https://github.com/JacobMuchow/ApartmentGroceries/pull/5","diff_url":"https://github.com/JacobMuchow/ApartmentGroceries/pull/5.diff","patch_url":"https://github.com/JacobMuchow/ApartmentGroceries/pull/5.patch","issue_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/issues/5","number":5,"state":"open","locked":false,"title":"Zhao 1016","user":{"login":"JacobMuchow","id":5720430,"avatar_url":"https://avatars.githubusercontent.com/u/5720430?v=3","gravatar_id":"","url":"https://api.github.com/users/JacobMuchow","html_url":"https://github.com/JacobMuchow","followers_url":"https://api.github.com/users/JacobMuchow/followers","following_url":"https://api.github.com/users/JacobMuchow/following{/other_user}","gists_url":"https://api.github.com/users/JacobMuchow/gists{/gist_id}","starred_url":"https://api.github.com/users/JacobMuchow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JacobMuchow/subscriptions","organizations_url":"https://api.github.com/users/JacobMuchow/orgs","repos_url":"https://api.github.com/users/JacobMuchow/repos","events_url":"https://api.github.com/users/JacobMuchow/events{/privacy}","received_events_url":"https://api.github.com/users/JacobMuchow/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-19T16:18:48Z","updated_at":"2015-10-19T17:41:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0cfd31adeb1ba2a08e87b209f2c89cbb92953dc7","assignee":{"login":"JacobMuchow","id":5720430,"avatar_url":"https://avatars.githubusercontent.com/u/5720430?v=3","gravatar_id":"","url":"https://api.github.com/users/JacobMuchow","html_url":"https://github.com/JacobMuchow","followers_url":"https://api.github.com/users/JacobMuchow/followers","following_url":"https://api.github.com/users/JacobMuchow/following{/other_user}","gists_url":"https://api.github.com/users/JacobMuchow/gists{/gist_id}","starred_url":"https://api.github.com/users/JacobMuchow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JacobMuchow/subscriptions","organizations_url":"https://api.github.com/users/JacobMuchow/orgs","repos_url":"https://api.github.com/users/JacobMuchow/repos","events_url":"https://api.github.com/users/JacobMuchow/events{/privacy}","received_events_url":"https://api.github.com/users/JacobMuchow/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/pulls/5/commits","review_comments_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/pulls/5/comments","review_comment_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/issues/5/comments","statuses_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/statuses/c8eb38793c26b06ce99bd877ded4afb75403b51d","head":{"label":"JacobMuchow:zhao_1016","ref":"zhao_1016","sha":"c8eb38793c26b06ce99bd877ded4afb75403b51d","user":{"login":"JacobMuchow","id":5720430,"avatar_url":"https://avatars.githubusercontent.com/u/5720430?v=3","gravatar_id":"","url":"https://api.github.com/users/JacobMuchow","html_url":"https://github.com/JacobMuchow","followers_url":"https://api.github.com/users/JacobMuchow/followers","following_url":"https://api.github.com/users/JacobMuchow/following{/other_user}","gists_url":"https://api.github.com/users/JacobMuchow/gists{/gist_id}","starred_url":"https://api.github.com/users/JacobMuchow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JacobMuchow/subscriptions","organizations_url":"https://api.github.com/users/JacobMuchow/orgs","repos_url":"https://api.github.com/users/JacobMuchow/repos","events_url":"https://api.github.com/users/JacobMuchow/events{/privacy}","received_events_url":"https://api.github.com/users/JacobMuchow/received_events","type":"User","site_admin":false},"repo":{"id":44206121,"name":"ApartmentGroceries","full_name":"JacobMuchow/ApartmentGroceries","owner":{"login":"JacobMuchow","id":5720430,"avatar_url":"https://avatars.githubusercontent.com/u/5720430?v=3","gravatar_id":"","url":"https://api.github.com/users/JacobMuchow","html_url":"https://github.com/JacobMuchow","followers_url":"https://api.github.com/users/JacobMuchow/followers","following_url":"https://api.github.com/users/JacobMuchow/following{/other_user}","gists_url":"https://api.github.com/users/JacobMuchow/gists{/gist_id}","starred_url":"https://api.github.com/users/JacobMuchow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JacobMuchow/subscriptions","organizations_url":"https://api.github.com/users/JacobMuchow/orgs","repos_url":"https://api.github.com/users/JacobMuchow/repos","events_url":"https://api.github.com/users/JacobMuchow/events{/privacy}","received_events_url":"https://api.github.com/users/JacobMuchow/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JacobMuchow/ApartmentGroceries","description":"","fork":false,"url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries","forks_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/forks","keys_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/teams","hooks_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/hooks","issue_events_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/issues/events{/number}","events_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/events","assignees_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/assignees{/user}","branches_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/branches{/branch}","tags_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/tags","blobs_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/git/refs{/sha}","trees_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/statuses/{sha}","languages_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/languages","stargazers_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/stargazers","contributors_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/contributors","subscribers_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/subscribers","subscription_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/subscription","commits_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/commits{/sha}","git_commits_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/git/commits{/sha}","comments_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/comments{/number}","issue_comment_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/issues/comments{/number}","contents_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/contents/{+path}","compare_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/merges","archive_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/downloads","issues_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/issues{/number}","pulls_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/pulls{/number}","milestones_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/milestones{/number}","notifications_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/labels{/name}","releases_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/releases{/id}","created_at":"2015-10-13T21:31:13Z","updated_at":"2015-10-13T21:36:22Z","pushed_at":"2015-10-19T16:19:26Z","git_url":"git://github.com/JacobMuchow/ApartmentGroceries.git","ssh_url":"git@github.com:JacobMuchow/ApartmentGroceries.git","clone_url":"https://github.com/JacobMuchow/ApartmentGroceries.git","svn_url":"https://github.com/JacobMuchow/ApartmentGroceries","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"JacobMuchow:master","ref":"master","sha":"b84df99ae6c4af0985c2b2c93a1663f334ad9b5b","user":{"login":"JacobMuchow","id":5720430,"avatar_url":"https://avatars.githubusercontent.com/u/5720430?v=3","gravatar_id":"","url":"https://api.github.com/users/JacobMuchow","html_url":"https://github.com/JacobMuchow","followers_url":"https://api.github.com/users/JacobMuchow/followers","following_url":"https://api.github.com/users/JacobMuchow/following{/other_user}","gists_url":"https://api.github.com/users/JacobMuchow/gists{/gist_id}","starred_url":"https://api.github.com/users/JacobMuchow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JacobMuchow/subscriptions","organizations_url":"https://api.github.com/users/JacobMuchow/orgs","repos_url":"https://api.github.com/users/JacobMuchow/repos","events_url":"https://api.github.com/users/JacobMuchow/events{/privacy}","received_events_url":"https://api.github.com/users/JacobMuchow/received_events","type":"User","site_admin":false},"repo":{"id":44206121,"name":"ApartmentGroceries","full_name":"JacobMuchow/ApartmentGroceries","owner":{"login":"JacobMuchow","id":5720430,"avatar_url":"https://avatars.githubusercontent.com/u/5720430?v=3","gravatar_id":"","url":"https://api.github.com/users/JacobMuchow","html_url":"https://github.com/JacobMuchow","followers_url":"https://api.github.com/users/JacobMuchow/followers","following_url":"https://api.github.com/users/JacobMuchow/following{/other_user}","gists_url":"https://api.github.com/users/JacobMuchow/gists{/gist_id}","starred_url":"https://api.github.com/users/JacobMuchow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JacobMuchow/subscriptions","organizations_url":"https://api.github.com/users/JacobMuchow/orgs","repos_url":"https://api.github.com/users/JacobMuchow/repos","events_url":"https://api.github.com/users/JacobMuchow/events{/privacy}","received_events_url":"https://api.github.com/users/JacobMuchow/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JacobMuchow/ApartmentGroceries","description":"","fork":false,"url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries","forks_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/forks","keys_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/teams","hooks_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/hooks","issue_events_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/issues/events{/number}","events_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/events","assignees_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/assignees{/user}","branches_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/branches{/branch}","tags_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/tags","blobs_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/git/refs{/sha}","trees_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/statuses/{sha}","languages_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/languages","stargazers_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/stargazers","contributors_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/contributors","subscribers_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/subscribers","subscription_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/subscription","commits_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/commits{/sha}","git_commits_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/git/commits{/sha}","comments_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/comments{/number}","issue_comment_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/issues/comments{/number}","contents_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/contents/{+path}","compare_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/merges","archive_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/downloads","issues_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/issues{/number}","pulls_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/pulls{/number}","milestones_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/milestones{/number}","notifications_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/labels{/name}","releases_url":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/releases{/id}","created_at":"2015-10-13T21:31:13Z","updated_at":"2015-10-13T21:36:22Z","pushed_at":"2015-10-19T16:19:26Z","git_url":"git://github.com/JacobMuchow/ApartmentGroceries.git","ssh_url":"git@github.com:JacobMuchow/ApartmentGroceries.git","clone_url":"https://github.com/JacobMuchow/ApartmentGroceries.git","svn_url":"https://github.com/JacobMuchow/ApartmentGroceries","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Java","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/JacobMuchow/ApartmentGroceries/pulls/5"},"html":{"href":"https://github.com/JacobMuchow/ApartmentGroceries/pull/5"},"issue":{"href":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/issues/5"},"comments":{"href":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/JacobMuchow/ApartmentGroceries/statuses/c8eb38793c26b06ce99bd877ded4afb75403b51d"}}}}