{"action":"created","comment":{"url":"https://api.github.com/repos/2600hz/kazoo/pulls/comments/28732839","id":28732839,"diff_hunk":"@@ -310,6 +309,82 @@ settings_datetime(JObj) ->\n              ),\n     wh_json:from_list(Props).\n \n+-spec settings_feature_keys(wh_json:object()) -> wh_json:object().\n+settings_feature_keys(JObj) ->\n+    FeatureKeys = wh_json:get_value([<<\"provision\">>, <<\"feature_keys\">>], JObj, wh_json:new()),\n+    Brand = get_brand(JObj),\n+    Family = get_family(JObj),\n+    AccountId = wh_json:get_value(<<\"pvt_account_id\">>, JObj),\n+    wh_json:foldl(\n+        fun(Key, Value, Acc) ->\n+            Type = wh_json:get_binary_value(<<\"type\">>, Value),\n+            V = wh_json:get_binary_value(<<\"value\">>, Value),\n+            FeatureKey = get_feature_key(Type, V, Brand, Family, AccountId),\n+            maybe_add_feature_key(Key, FeatureKey, Acc)\n+        end\n+        ,wh_json:new()\n+        ,FeatureKeys\n+    ).\n+\n+-spec get_feature_key(ne_binary(), wh_json:object(), ne_binary(), ne_binary(), ne_binary()) -> wh_json:object().\n+get_feature_key(<<\"presence\">> = Type, Value, Brand, Family, AccountId) ->\n+    {'ok', UserJObj} = get_user(AccountId, Value),\n+    First = wh_json:get_value(<<\"first_name\">>, UserJObj),\n+    Last = wh_json:get_value(<<\"last_name\">>, UserJObj),\n+    case wh_json:get_value(<<\"presence_id\">>, UserJObj) of\n+        'undefined' -> 'undefined';\n+        Presence ->\n+            wh_json:from_list([\n+                {<<\"label\">>, <<First/binary, \" \", Last/binary>>}\n+                ,{<<\"value\">>, Presence}\n+                ,{<<\"type\">>, get_feature_key_type(Type, Brand, Family)}\n+            ])\n+    end;\n+get_feature_key(<<\"speed_dial\">> = Type, Value, Brand, Family, _AccountId) ->\n+    wh_json:from_list([\n+        {<<\"label\">>, Value}\n+        ,{<<\"value\">>, Value}\n+        ,{<<\"type\">>, get_feature_key_type(Type, Brand, Family)}\n+    ]);\n+get_feature_key(<<\"personal_parking\">> = Type, Value, Brand, Family, AccountId) ->\n+    {'ok', UserJObj} = get_user(AccountId, Value),\n+    First = wh_json:get_value(<<\"first_name\">>, UserJObj),\n+    Last = wh_json:get_value(<<\"last_name\">>, UserJObj),\n+    Presence = wh_json:get_value(<<\"presence_id\">>, UserJObj),\n+    case wh_json:get_value(<<\"presence_id\">>, UserJObj) of\n+        'undefined' -> 'undefined';\n+        Presence ->\n+            wh_json:from_list([\n+                {<<\"label\">>, <<\"Park \", First/binary, \" \", Last/binary>>}\n+                ,{<<\"value\">>, <<\"*3\", Presence/binary>>}\n+                ,{<<\"type\">>, get_feature_key_type(Type, Brand, Family)}\n+            ])\n+    end;\n+get_feature_key(<<\"parking\">> = Type, Value, Brand, Family, _AccountId) ->\n+    wh_json:from_list([\n+        {<<\"label\">>, <<\"Park \", Value/binary>>}\n+        ,{<<\"value\">>, <<\"*3\", Value/binary>>}\n+        ,{<<\"type\">>, get_feature_key_type(Type, Brand, Family)}\n+    ]).\n+\n+-spec get_feature_key_type(ne_binary(), ne_binary(), ne_binary()) -> wh_json:object().\n+get_feature_key_type(Type, Brand, Family) ->\n+    wh_json:get_first_defined([[Brand, Family, Type], [Brand, <<\"_\">>, Type]], ?FEATURE_KEYS).\n+\n+-spec get_user(ne_binary(), ne_binary()) -> wh_json:object().\n+get_user(AccountId, UserId) ->\n+    AccountDb = wh_util:format_account_id(AccountId, 'encoded'),\n+    couch_mgr:open_doc(AccountDb, UserId).","path":"applications/crossbar/src/modules/provisioner_v5.erl","position":88,"original_position":88,"commit_id":"35434e05bb3d5ce9dbdfb71078c594c192cb021e","original_commit_id":"35434e05bb3d5ce9dbdfb71078c594c192cb021e","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":"Should probably use `open_cache_doc/2`","created_at":"2015-04-20T21:46:38Z","updated_at":"2015-04-20T21:46:38Z","html_url":"https://github.com/2600hz/kazoo/pull/961#discussion_r28732839","pull_request_url":"https://api.github.com/repos/2600hz/kazoo/pulls/961","_links":{"self":{"href":"https://api.github.com/repos/2600hz/kazoo/pulls/comments/28732839"},"html":{"href":"https://github.com/2600hz/kazoo/pull/961#discussion_r28732839"},"pull_request":{"href":"https://api.github.com/repos/2600hz/kazoo/pulls/961"}}},"pull_request":{"url":"https://api.github.com/repos/2600hz/kazoo/pulls/961","id":33686382,"html_url":"https://github.com/2600hz/kazoo/pull/961","diff_url":"https://github.com/2600hz/kazoo/pull/961.diff","patch_url":"https://github.com/2600hz/kazoo/pull/961.patch","issue_url":"https://api.github.com/repos/2600hz/kazoo/issues/961","number":961,"state":"open","locked":false,"title":"Kazoo 3496","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-04-20T17:16:02Z","updated_at":"2015-04-20T21:46:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5f3bfffcf8f4d22c75625b4a03dd211cff7104b9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/2600hz/kazoo/pulls/961/commits","review_comments_url":"https://api.github.com/repos/2600hz/kazoo/pulls/961/comments","review_comment_url":"https://api.github.com/repos/2600hz/kazoo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/2600hz/kazoo/issues/961/comments","statuses_url":"https://api.github.com/repos/2600hz/kazoo/statuses/35434e05bb3d5ce9dbdfb71078c594c192cb021e","head":{"label":"2600hz:KAZOO-3496","ref":"KAZOO-3496","sha":"35434e05bb3d5ce9dbdfb71078c594c192cb021e","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-04-20T20:14:11Z","pushed_at":"2015-04-20T20:14:10Z","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":515709,"stargazers_count":248,"watchers_count":248,"language":"Erlang","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":128,"mirror_url":null,"open_issues_count":10,"forks":128,"open_issues":10,"watchers":248,"default_branch":"master"}},"base":{"label":"2600hz:master","ref":"master","sha":"551353ce6bb2ad389def575c64e66ea27d9cc714","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-04-20T20:14:11Z","pushed_at":"2015-04-20T20:14:10Z","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":515709,"stargazers_count":248,"watchers_count":248,"language":"Erlang","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":128,"mirror_url":null,"open_issues_count":10,"forks":128,"open_issues":10,"watchers":248,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/2600hz/kazoo/pulls/961"},"html":{"href":"https://github.com/2600hz/kazoo/pull/961"},"issue":{"href":"https://api.github.com/repos/2600hz/kazoo/issues/961"},"comments":{"href":"https://api.github.com/repos/2600hz/kazoo/issues/961/comments"},"review_comments":{"href":"https://api.github.com/repos/2600hz/kazoo/pulls/961/comments"},"review_comment":{"href":"https://api.github.com/repos/2600hz/kazoo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/2600hz/kazoo/pulls/961/commits"},"statuses":{"href":"https://api.github.com/repos/2600hz/kazoo/statuses/35434e05bb3d5ce9dbdfb71078c594c192cb021e"}}}}