{"action":"created","comment":{"url":"https://api.github.com/repos/2600hz/kazoo/pulls/comments/45492900","id":45492900,"diff_hunk":"@@ -0,0 +1,94 @@\n+%%%-------------------------------------------------------------------\n+%%% @copyright (C) 2010-2015, 2600Hz\n+%%% @doc\n+%%%\n+%%% @end\n+%%% @contributors\n+%%%   Peter Defebvre\n+%%%-------------------------------------------------------------------\n+-module(cb_mobile_manager).\n+\n+-export([delete_account/1]).\n+\n+-include(\"./crossbar.hrl\").\n+\n+-define(MOD_CONFIG_CAT, <<\"mobile_manager\">>).\n+\n+%%--------------------------------------------------------------------\n+%% @public\n+%% @doc\n+%%\n+%% @end\n+%%--------------------------------------------------------------------\n+delete_account(Context) ->\n+    AccountId = cb_context:account_id(Context),\n+    AuthToken = cb_context:auth_token(Context),\n+\n+    UrlString = req_uri([<<\"accounts\">>, AccountId]),\n+    Headers = req_headers(AuthToken),\n+\n+    lager:debug(\"mobile_manager delete via ~s\", [UrlString]),\n+\n+    Resp = ibrowse:send_req(UrlString, Headers, 'delete'),\n+    handle_resp(Resp).\n+\n+%%%===================================================================\n+%%% Internal functions\n+%%%===================================================================\n+\n+\n+%%--------------------------------------------------------------------\n+%% @private\n+%% @doc\n+%%\n+%% @end\n+%%--------------------------------------------------------------------\n+-spec handle_resp(ibrowse_ret()) -> 'ok'.\n+handle_resp({'ok', \"200\", _, Resp}) ->\n+    lager:debug(\"mobile_manager success ~s\", [decode(Resp)]);\n+handle_resp({'ok', Code, _, Resp}) ->\n+    lager:warning(\"mobile_manager error ~p. ~s\", [Code, decode(Resp)]);\n+handle_resp(_Error) ->\n+    lager:error(\"mobile_manager fatal error ~p\", [_Error]).\n+\n+%%--------------------------------------------------------------------\n+%% @private\n+%% @doc\n+%%\n+%% @end\n+%%--------------------------------------------------------------------\n+-spec decode(string()) -> ne_binary().\n+decode(JSON) ->\n+    try wh_json:encode(JSON) of","path":"applications/crossbar/src/cb_mobile_manager.erl","position":62,"original_position":62,"commit_id":"e698096ce66a8620fc193124326becb17a358f14","original_commit_id":"e698096ce66a8620fc193124326becb17a358f14","user":{"login":"jamesaimonetti","id":160921,"avatar_url":"https://avatars.githubusercontent.com/u/160921?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesaimonetti","html_url":"https://github.com/jamesaimonetti","followers_url":"https://api.github.com/users/jamesaimonetti/followers","following_url":"https://api.github.com/users/jamesaimonetti/following{/other_user}","gists_url":"https://api.github.com/users/jamesaimonetti/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesaimonetti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesaimonetti/subscriptions","organizations_url":"https://api.github.com/users/jamesaimonetti/orgs","repos_url":"https://api.github.com/users/jamesaimonetti/repos","events_url":"https://api.github.com/users/jamesaimonetti/events{/privacy}","received_events_url":"https://api.github.com/users/jamesaimonetti/received_events","type":"User","site_admin":false},"body":"I truly don't understand the point of this function. In `handle_resp`, the last element in the tuple will be the response body as a string (I believe that's the default in ibrowse). So the first thing tried with that string is to encode it to JSON? Why not just log the response body directly above? The response is unused aside from logging it so why bother doing anything to it?","created_at":"2015-11-20T17:14:15Z","updated_at":"2015-11-20T17:14:15Z","html_url":"https://github.com/2600hz/kazoo/pull/1452#discussion_r45492900","pull_request_url":"https://api.github.com/repos/2600hz/kazoo/pulls/1452","_links":{"self":{"href":"https://api.github.com/repos/2600hz/kazoo/pulls/comments/45492900"},"html":{"href":"https://github.com/2600hz/kazoo/pull/1452#discussion_r45492900"},"pull_request":{"href":"https://api.github.com/repos/2600hz/kazoo/pulls/1452"}}},"pull_request":{"url":"https://api.github.com/repos/2600hz/kazoo/pulls/1452","id":51268246,"html_url":"https://github.com/2600hz/kazoo/pull/1452","diff_url":"https://github.com/2600hz/kazoo/pull/1452.diff","patch_url":"https://github.com/2600hz/kazoo/pull/1452.patch","issue_url":"https://api.github.com/repos/2600hz/kazoo/issues/1452","number":1452,"state":"open","locked":false,"title":"KAZOO-4350: Send delete req to mobile manager when you delete an account","user":{"login":"macpie","id":778101,"avatar_url":"https://avatars.githubusercontent.com/u/778101?v=3","gravatar_id":"","url":"https://api.github.com/users/macpie","html_url":"https://github.com/macpie","followers_url":"https://api.github.com/users/macpie/followers","following_url":"https://api.github.com/users/macpie/following{/other_user}","gists_url":"https://api.github.com/users/macpie/gists{/gist_id}","starred_url":"https://api.github.com/users/macpie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/macpie/subscriptions","organizations_url":"https://api.github.com/users/macpie/orgs","repos_url":"https://api.github.com/users/macpie/repos","events_url":"https://api.github.com/users/macpie/events{/privacy}","received_events_url":"https://api.github.com/users/macpie/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-11-19T19:24:32Z","updated_at":"2015-11-20T17:14:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fed1c9671c909f0e47974ce1fd70d59474415099","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/2600hz/kazoo/pulls/1452/commits","review_comments_url":"https://api.github.com/repos/2600hz/kazoo/pulls/1452/comments","review_comment_url":"https://api.github.com/repos/2600hz/kazoo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/2600hz/kazoo/issues/1452/comments","statuses_url":"https://api.github.com/repos/2600hz/kazoo/statuses/e698096ce66a8620fc193124326becb17a358f14","head":{"label":"2600hz:KAZOO-4350","ref":"KAZOO-4350","sha":"e698096ce66a8620fc193124326becb17a358f14","user":{"login":"2600hz","id":408801,"avatar_url":"https://avatars.githubusercontent.com/u/408801?v=3","gravatar_id":"","url":"https://api.github.com/users/2600hz","html_url":"https://github.com/2600hz","followers_url":"https://api.github.com/users/2600hz/followers","following_url":"https://api.github.com/users/2600hz/following{/other_user}","gists_url":"https://api.github.com/users/2600hz/gists{/gist_id}","starred_url":"https://api.github.com/users/2600hz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2600hz/subscriptions","organizations_url":"https://api.github.com/users/2600hz/orgs","repos_url":"https://api.github.com/users/2600hz/repos","events_url":"https://api.github.com/users/2600hz/events{/privacy}","received_events_url":"https://api.github.com/users/2600hz/received_events","type":"Organization","site_admin":false},"repo":{"id":2966241,"name":"kazoo","full_name":"2600hz/kazoo","owner":{"login":"2600hz","id":408801,"avatar_url":"https://avatars.githubusercontent.com/u/408801?v=3","gravatar_id":"","url":"https://api.github.com/users/2600hz","html_url":"https://github.com/2600hz","followers_url":"https://api.github.com/users/2600hz/followers","following_url":"https://api.github.com/users/2600hz/following{/other_user}","gists_url":"https://api.github.com/users/2600hz/gists{/gist_id}","starred_url":"https://api.github.com/users/2600hz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2600hz/subscriptions","organizations_url":"https://api.github.com/users/2600hz/orgs","repos_url":"https://api.github.com/users/2600hz/repos","events_url":"https://api.github.com/users/2600hz/events{/privacy}","received_events_url":"https://api.github.com/users/2600hz/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/2600hz/kazoo","description":"","fork":false,"url":"https://api.github.com/repos/2600hz/kazoo","forks_url":"https://api.github.com/repos/2600hz/kazoo/forks","keys_url":"https://api.github.com/repos/2600hz/kazoo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/2600hz/kazoo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/2600hz/kazoo/teams","hooks_url":"https://api.github.com/repos/2600hz/kazoo/hooks","issue_events_url":"https://api.github.com/repos/2600hz/kazoo/issues/events{/number}","events_url":"https://api.github.com/repos/2600hz/kazoo/events","assignees_url":"https://api.github.com/repos/2600hz/kazoo/assignees{/user}","branches_url":"https://api.github.com/repos/2600hz/kazoo/branches{/branch}","tags_url":"https://api.github.com/repos/2600hz/kazoo/tags","blobs_url":"https://api.github.com/repos/2600hz/kazoo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/2600hz/kazoo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/2600hz/kazoo/git/refs{/sha}","trees_url":"https://api.github.com/repos/2600hz/kazoo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/2600hz/kazoo/statuses/{sha}","languages_url":"https://api.github.com/repos/2600hz/kazoo/languages","stargazers_url":"https://api.github.com/repos/2600hz/kazoo/stargazers","contributors_url":"https://api.github.com/repos/2600hz/kazoo/contributors","subscribers_url":"https://api.github.com/repos/2600hz/kazoo/subscribers","subscription_url":"https://api.github.com/repos/2600hz/kazoo/subscription","commits_url":"https://api.github.com/repos/2600hz/kazoo/commits{/sha}","git_commits_url":"https://api.github.com/repos/2600hz/kazoo/git/commits{/sha}","comments_url":"https://api.github.com/repos/2600hz/kazoo/comments{/number}","issue_comment_url":"https://api.github.com/repos/2600hz/kazoo/issues/comments{/number}","contents_url":"https://api.github.com/repos/2600hz/kazoo/contents/{+path}","compare_url":"https://api.github.com/repos/2600hz/kazoo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/2600hz/kazoo/merges","archive_url":"https://api.github.com/repos/2600hz/kazoo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/2600hz/kazoo/downloads","issues_url":"https://api.github.com/repos/2600hz/kazoo/issues{/number}","pulls_url":"https://api.github.com/repos/2600hz/kazoo/pulls{/number}","milestones_url":"https://api.github.com/repos/2600hz/kazoo/milestones{/number}","notifications_url":"https://api.github.com/repos/2600hz/kazoo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/2600hz/kazoo/labels{/name}","releases_url":"https://api.github.com/repos/2600hz/kazoo/releases{/id}","created_at":"2011-12-12T18:08:02Z","updated_at":"2015-11-17T04:17:41Z","pushed_at":"2015-11-20T16:33:11Z","git_url":"git://github.com/2600hz/kazoo.git","ssh_url":"git@github.com:2600hz/kazoo.git","clone_url":"https://github.com/2600hz/kazoo.git","svn_url":"https://github.com/2600hz/kazoo","homepage":"","size":328564,"stargazers_count":307,"watchers_count":307,"language":"Erlang","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":156,"mirror_url":null,"open_issues_count":25,"forks":156,"open_issues":25,"watchers":307,"default_branch":"master"}},"base":{"label":"2600hz:master","ref":"master","sha":"01c440b59ea48fb7138192f2bea3a50b74ce1ff1","user":{"login":"2600hz","id":408801,"avatar_url":"https://avatars.githubusercontent.com/u/408801?v=3","gravatar_id":"","url":"https://api.github.com/users/2600hz","html_url":"https://github.com/2600hz","followers_url":"https://api.github.com/users/2600hz/followers","following_url":"https://api.github.com/users/2600hz/following{/other_user}","gists_url":"https://api.github.com/users/2600hz/gists{/gist_id}","starred_url":"https://api.github.com/users/2600hz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2600hz/subscriptions","organizations_url":"https://api.github.com/users/2600hz/orgs","repos_url":"https://api.github.com/users/2600hz/repos","events_url":"https://api.github.com/users/2600hz/events{/privacy}","received_events_url":"https://api.github.com/users/2600hz/received_events","type":"Organization","site_admin":false},"repo":{"id":2966241,"name":"kazoo","full_name":"2600hz/kazoo","owner":{"login":"2600hz","id":408801,"avatar_url":"https://avatars.githubusercontent.com/u/408801?v=3","gravatar_id":"","url":"https://api.github.com/users/2600hz","html_url":"https://github.com/2600hz","followers_url":"https://api.github.com/users/2600hz/followers","following_url":"https://api.github.com/users/2600hz/following{/other_user}","gists_url":"https://api.github.com/users/2600hz/gists{/gist_id}","starred_url":"https://api.github.com/users/2600hz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2600hz/subscriptions","organizations_url":"https://api.github.com/users/2600hz/orgs","repos_url":"https://api.github.com/users/2600hz/repos","events_url":"https://api.github.com/users/2600hz/events{/privacy}","received_events_url":"https://api.github.com/users/2600hz/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/2600hz/kazoo","description":"","fork":false,"url":"https://api.github.com/repos/2600hz/kazoo","forks_url":"https://api.github.com/repos/2600hz/kazoo/forks","keys_url":"https://api.github.com/repos/2600hz/kazoo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/2600hz/kazoo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/2600hz/kazoo/teams","hooks_url":"https://api.github.com/repos/2600hz/kazoo/hooks","issue_events_url":"https://api.github.com/repos/2600hz/kazoo/issues/events{/number}","events_url":"https://api.github.com/repos/2600hz/kazoo/events","assignees_url":"https://api.github.com/repos/2600hz/kazoo/assignees{/user}","branches_url":"https://api.github.com/repos/2600hz/kazoo/branches{/branch}","tags_url":"https://api.github.com/repos/2600hz/kazoo/tags","blobs_url":"https://api.github.com/repos/2600hz/kazoo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/2600hz/kazoo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/2600hz/kazoo/git/refs{/sha}","trees_url":"https://api.github.com/repos/2600hz/kazoo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/2600hz/kazoo/statuses/{sha}","languages_url":"https://api.github.com/repos/2600hz/kazoo/languages","stargazers_url":"https://api.github.com/repos/2600hz/kazoo/stargazers","contributors_url":"https://api.github.com/repos/2600hz/kazoo/contributors","subscribers_url":"https://api.github.com/repos/2600hz/kazoo/subscribers","subscription_url":"https://api.github.com/repos/2600hz/kazoo/subscription","commits_url":"https://api.github.com/repos/2600hz/kazoo/commits{/sha}","git_commits_url":"https://api.github.com/repos/2600hz/kazoo/git/commits{/sha}","comments_url":"https://api.github.com/repos/2600hz/kazoo/comments{/number}","issue_comment_url":"https://api.github.com/repos/2600hz/kazoo/issues/comments{/number}","contents_url":"https://api.github.com/repos/2600hz/kazoo/contents/{+path}","compare_url":"https://api.github.com/repos/2600hz/kazoo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/2600hz/kazoo/merges","archive_url":"https://api.github.com/repos/2600hz/kazoo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/2600hz/kazoo/downloads","issues_url":"https://api.github.com/repos/2600hz/kazoo/issues{/number}","pulls_url":"https://api.github.com/repos/2600hz/kazoo/pulls{/number}","milestones_url":"https://api.github.com/repos/2600hz/kazoo/milestones{/number}","notifications_url":"https://api.github.com/repos/2600hz/kazoo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/2600hz/kazoo/labels{/name}","releases_url":"https://api.github.com/repos/2600hz/kazoo/releases{/id}","created_at":"2011-12-12T18:08:02Z","updated_at":"2015-11-17T04:17:41Z","pushed_at":"2015-11-20T16:33:11Z","git_url":"git://github.com/2600hz/kazoo.git","ssh_url":"git@github.com:2600hz/kazoo.git","clone_url":"https://github.com/2600hz/kazoo.git","svn_url":"https://github.com/2600hz/kazoo","homepage":"","size":328564,"stargazers_count":307,"watchers_count":307,"language":"Erlang","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":156,"mirror_url":null,"open_issues_count":25,"forks":156,"open_issues":25,"watchers":307,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/2600hz/kazoo/pulls/1452"},"html":{"href":"https://github.com/2600hz/kazoo/pull/1452"},"issue":{"href":"https://api.github.com/repos/2600hz/kazoo/issues/1452"},"comments":{"href":"https://api.github.com/repos/2600hz/kazoo/issues/1452/comments"},"review_comments":{"href":"https://api.github.com/repos/2600hz/kazoo/pulls/1452/comments"},"review_comment":{"href":"https://api.github.com/repos/2600hz/kazoo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/2600hz/kazoo/pulls/1452/commits"},"statuses":{"href":"https://api.github.com/repos/2600hz/kazoo/statuses/e698096ce66a8620fc193124326becb17a358f14"}}}}