{"action":"created","comment":{"url":"https://api.github.com/repos/onfido/onfido-sdk-ui/pulls/comments/117941738","pull_request_review_id":39687216,"id":117941738,"diff_hunk":"@@ -0,0 +1,49 @@\n+import { events } from 'onfido-sdk-core'\n+import Tracker from '../../Tracker'\n+const SDK_SERVER_URL = 'https://sdk.onfido.com'\n+\n+const reduceObj = (object, callback, initialValue) =>\n+  Object.keys(object).reduce(\n+    (accumulator, key) => callback(accumulator, object[key], key, object),\n+    initialValue)\n+\n+const objectToFormData = (object) =>\n+  reduceObj(object, (formData, value, key) => {\n+    formData.append(key, value)\n+    return formData;\n+  }, new FormData())\n+\n+const errorMessage = (status) => {\n+  if (status === 401 || status === 403) return 'unauthorized'\n+  if (status >= 500) {\n+    'server error' }\n+  else {\n+    'request error'\n+  }\n+}\n+\n+const handleError = (status, callback) => {\n+  const message = errorMessage(status)\n+  Tracker.sendError(message)\n+  callback()\n+}\n+\n+export const postToServer = (payload, serverUrl, token, onSuccess, onError) => {\n+  const request = new XMLHttpRequest()\n+  const url = serverUrl ? serverUrl : SDK_SERVER_URL\n+  request.open('POST', `${url}/validate_document`)\n+  request.setRequestHeader('Content-Type', 'application/json')\n+  request.setRequestHeader('Authorization', token)\n+\n+  request.onload = () => {\n+    if (request.status === 200) {\n+      onSuccess(JSON.parse(request.response))}","path":"src/components/utils/http.js","position":40,"original_position":40,"commit_id":"94a7dee268a060f15687dc0d1468f5eb1271d4ca","original_commit_id":"94a7dee268a060f15687dc0d1468f5eb1271d4ca","user":{"login":"rfreitas","id":651348,"avatar_url":"https://avatars0.githubusercontent.com/u/651348?v=3","gravatar_id":"","url":"https://api.github.com/users/rfreitas","html_url":"https://github.com/rfreitas","followers_url":"https://api.github.com/users/rfreitas/followers","following_url":"https://api.github.com/users/rfreitas/following{/other_user}","gists_url":"https://api.github.com/users/rfreitas/gists{/gist_id}","starred_url":"https://api.github.com/users/rfreitas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rfreitas/subscriptions","organizations_url":"https://api.github.com/users/rfreitas/orgs","repos_url":"https://api.github.com/users/rfreitas/repos","events_url":"https://api.github.com/users/rfreitas/events{/privacy}","received_events_url":"https://api.github.com/users/rfreitas/received_events","type":"User","site_admin":false},"body":"definitely a good idea to add a comment","created_at":"2017-05-23T09:24:09Z","updated_at":"2017-05-23T09:24:09Z","html_url":"https://github.com/onfido/onfido-sdk-ui/pull/145#discussion_r117941738","pull_request_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/pulls/145","_links":{"self":{"href":"https://api.github.com/repos/onfido/onfido-sdk-ui/pulls/comments/117941738"},"html":{"href":"https://github.com/onfido/onfido-sdk-ui/pull/145#discussion_r117941738"},"pull_request":{"href":"https://api.github.com/repos/onfido/onfido-sdk-ui/pulls/145"}}},"pull_request":{"url":"https://api.github.com/repos/onfido/onfido-sdk-ui/pulls/145","id":121062176,"html_url":"https://github.com/onfido/onfido-sdk-ui/pull/145","diff_url":"https://github.com/onfido/onfido-sdk-ui/pull/145.diff","patch_url":"https://github.com/onfido/onfido-sdk-ui/pull/145.patch","issue_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/issues/145","number":145,"state":"closed","locked":false,"title":"Feature/use http cx 754","user":{"login":"stefaniacardenas","id":7127427,"avatar_url":"https://avatars2.githubusercontent.com/u/7127427?v=3","gravatar_id":"","url":"https://api.github.com/users/stefaniacardenas","html_url":"https://github.com/stefaniacardenas","followers_url":"https://api.github.com/users/stefaniacardenas/followers","following_url":"https://api.github.com/users/stefaniacardenas/following{/other_user}","gists_url":"https://api.github.com/users/stefaniacardenas/gists{/gist_id}","starred_url":"https://api.github.com/users/stefaniacardenas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefaniacardenas/subscriptions","organizations_url":"https://api.github.com/users/stefaniacardenas/orgs","repos_url":"https://api.github.com/users/stefaniacardenas/repos","events_url":"https://api.github.com/users/stefaniacardenas/events{/privacy}","received_events_url":"https://api.github.com/users/stefaniacardenas/received_events","type":"User","site_admin":false},"body":"Update the JS SDK to use HTTP protocol instead of websockets.\r\nUser will see the following error messages in the current UI:\r\n- connection errors (on file upload only)\r\n- validation errors\r\n- file type errors","created_at":"2017-05-17T13:49:14Z","updated_at":"2017-05-23T09:24:09Z","closed_at":"2017-05-22T17:30:28Z","merged_at":"2017-05-22T17:30:28Z","merge_commit_sha":"9427b8c36454465654e64792ea184e4e0f1607d0","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/pulls/145/commits","review_comments_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/pulls/145/comments","review_comment_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/issues/145/comments","statuses_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/statuses/94a7dee268a060f15687dc0d1468f5eb1271d4ca","head":{"label":"onfido:feature/use-http-cx-754","ref":"feature/use-http-cx-754","sha":"94a7dee268a060f15687dc0d1468f5eb1271d4ca","user":{"login":"onfido","id":6752448,"avatar_url":"https://avatars0.githubusercontent.com/u/6752448?v=3","gravatar_id":"","url":"https://api.github.com/users/onfido","html_url":"https://github.com/onfido","followers_url":"https://api.github.com/users/onfido/followers","following_url":"https://api.github.com/users/onfido/following{/other_user}","gists_url":"https://api.github.com/users/onfido/gists{/gist_id}","starred_url":"https://api.github.com/users/onfido/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onfido/subscriptions","organizations_url":"https://api.github.com/users/onfido/orgs","repos_url":"https://api.github.com/users/onfido/repos","events_url":"https://api.github.com/users/onfido/events{/privacy}","received_events_url":"https://api.github.com/users/onfido/received_events","type":"Organization","site_admin":false},"repo":{"id":59305266,"name":"onfido-sdk-ui","full_name":"onfido/onfido-sdk-ui","owner":{"login":"onfido","id":6752448,"avatar_url":"https://avatars0.githubusercontent.com/u/6752448?v=3","gravatar_id":"","url":"https://api.github.com/users/onfido","html_url":"https://github.com/onfido","followers_url":"https://api.github.com/users/onfido/followers","following_url":"https://api.github.com/users/onfido/following{/other_user}","gists_url":"https://api.github.com/users/onfido/gists{/gist_id}","starred_url":"https://api.github.com/users/onfido/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onfido/subscriptions","organizations_url":"https://api.github.com/users/onfido/orgs","repos_url":"https://api.github.com/users/onfido/repos","events_url":"https://api.github.com/users/onfido/events{/privacy}","received_events_url":"https://api.github.com/users/onfido/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/onfido/onfido-sdk-ui","description":"The Onfido SDK for Front-end JavaScript","fork":false,"url":"https://api.github.com/repos/onfido/onfido-sdk-ui","forks_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/forks","keys_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/teams","hooks_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/hooks","issue_events_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/issues/events{/number}","events_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/events","assignees_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/assignees{/user}","branches_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/branches{/branch}","tags_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/tags","blobs_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/languages","stargazers_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/stargazers","contributors_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/contributors","subscribers_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/subscribers","subscription_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/subscription","commits_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/contents/{+path}","compare_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/merges","archive_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/downloads","issues_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/issues{/number}","pulls_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/labels{/name}","releases_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/releases{/id}","deployments_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/deployments","created_at":"2016-05-20T15:25:36Z","updated_at":"2017-05-05T13:40:31Z","pushed_at":"2017-05-22T17:30:28Z","git_url":"git://github.com/onfido/onfido-sdk-ui.git","ssh_url":"git@github.com:onfido/onfido-sdk-ui.git","clone_url":"https://github.com/onfido/onfido-sdk-ui.git","svn_url":"https://github.com/onfido/onfido-sdk-ui","homepage":"","size":9131,"stargazers_count":11,"watchers_count":11,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":9,"forks":3,"open_issues":9,"watchers":11,"default_branch":"master"}},"base":{"label":"onfido:master","ref":"master","sha":"5bc40cb40c029be71e10a5a7233892fe414bc966","user":{"login":"onfido","id":6752448,"avatar_url":"https://avatars0.githubusercontent.com/u/6752448?v=3","gravatar_id":"","url":"https://api.github.com/users/onfido","html_url":"https://github.com/onfido","followers_url":"https://api.github.com/users/onfido/followers","following_url":"https://api.github.com/users/onfido/following{/other_user}","gists_url":"https://api.github.com/users/onfido/gists{/gist_id}","starred_url":"https://api.github.com/users/onfido/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onfido/subscriptions","organizations_url":"https://api.github.com/users/onfido/orgs","repos_url":"https://api.github.com/users/onfido/repos","events_url":"https://api.github.com/users/onfido/events{/privacy}","received_events_url":"https://api.github.com/users/onfido/received_events","type":"Organization","site_admin":false},"repo":{"id":59305266,"name":"onfido-sdk-ui","full_name":"onfido/onfido-sdk-ui","owner":{"login":"onfido","id":6752448,"avatar_url":"https://avatars0.githubusercontent.com/u/6752448?v=3","gravatar_id":"","url":"https://api.github.com/users/onfido","html_url":"https://github.com/onfido","followers_url":"https://api.github.com/users/onfido/followers","following_url":"https://api.github.com/users/onfido/following{/other_user}","gists_url":"https://api.github.com/users/onfido/gists{/gist_id}","starred_url":"https://api.github.com/users/onfido/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onfido/subscriptions","organizations_url":"https://api.github.com/users/onfido/orgs","repos_url":"https://api.github.com/users/onfido/repos","events_url":"https://api.github.com/users/onfido/events{/privacy}","received_events_url":"https://api.github.com/users/onfido/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/onfido/onfido-sdk-ui","description":"The Onfido SDK for Front-end JavaScript","fork":false,"url":"https://api.github.com/repos/onfido/onfido-sdk-ui","forks_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/forks","keys_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/teams","hooks_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/hooks","issue_events_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/issues/events{/number}","events_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/events","assignees_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/assignees{/user}","branches_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/branches{/branch}","tags_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/tags","blobs_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/statuses/{sha}","languages_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/languages","stargazers_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/stargazers","contributors_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/contributors","subscribers_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/subscribers","subscription_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/subscription","commits_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/contents/{+path}","compare_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/merges","archive_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/downloads","issues_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/issues{/number}","pulls_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/pulls{/number}","milestones_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/milestones{/number}","notifications_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/labels{/name}","releases_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/releases{/id}","deployments_url":"https://api.github.com/repos/onfido/onfido-sdk-ui/deployments","created_at":"2016-05-20T15:25:36Z","updated_at":"2017-05-05T13:40:31Z","pushed_at":"2017-05-22T17:30:28Z","git_url":"git://github.com/onfido/onfido-sdk-ui.git","ssh_url":"git@github.com:onfido/onfido-sdk-ui.git","clone_url":"https://github.com/onfido/onfido-sdk-ui.git","svn_url":"https://github.com/onfido/onfido-sdk-ui","homepage":"","size":9131,"stargazers_count":11,"watchers_count":11,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":9,"forks":3,"open_issues":9,"watchers":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/onfido/onfido-sdk-ui/pulls/145"},"html":{"href":"https://github.com/onfido/onfido-sdk-ui/pull/145"},"issue":{"href":"https://api.github.com/repos/onfido/onfido-sdk-ui/issues/145"},"comments":{"href":"https://api.github.com/repos/onfido/onfido-sdk-ui/issues/145/comments"},"review_comments":{"href":"https://api.github.com/repos/onfido/onfido-sdk-ui/pulls/145/comments"},"review_comment":{"href":"https://api.github.com/repos/onfido/onfido-sdk-ui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/onfido/onfido-sdk-ui/pulls/145/commits"},"statuses":{"href":"https://api.github.com/repos/onfido/onfido-sdk-ui/statuses/94a7dee268a060f15687dc0d1468f5eb1271d4ca"}}}}
{"actor":{"display_login":"rfreitas"}}