{"action":"created","comment":{"url":"https://api.github.com/repos/sparkplug/momoapi-node/pulls/comments/235353155","pull_request_review_id":177196312,"id":235353155,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNTM1MzE1NQ==","diff_hunk":"@@ -0,0 +1,40 @@\n+import axios, { AxiosInstance, AxiosRequestConfig } from \"axios\";\n+\n+import { Config } from \".\";\n+\n+import getTokenRefresher, { Authenticator, TokenRefresher } from \"./oauth\";\n+import { Subscription } from \"./users\";\n+\n+export function createBasicClient(config: Subscription): AxiosInstance {\n+  const baseURL = \"https://ericssonbasicapi2.azure-api.net\";\n+  return axios.create({\n+    baseURL,\n+    headers: {\n+      \"Content-Type\": \"application/json\",\n+      \"Ocp-Apim-Subscription-Key\": config.subscriptionKey\n+    }\n+  });\n+}\n+\n+export function createOAuthClient(\n+  config: Config,\n+  authenticator: Authenticator\n+): AxiosInstance {\n+  const instance = createBasicClient(config);\n+  const refresh: TokenRefresher = getTokenRefresher(authenticator, config);\n+\n+  instance.interceptors.request.use((request: AxiosRequestConfig) => {\n+    return refresh().then(({ accessToken }) => {\n+      return {\n+        ...request,\n+        headers: {\n+          ...request.headers,\n+          Authorization: `Bearer ${accessToken}`,\n+          \"X-Target-Environment\": \"sandbox\"","path":"src/client.ts","position":33,"original_position":33,"commit_id":"65afc174409d4903476b4714a142d8e9e2118798","original_commit_id":"65afc174409d4903476b4714a142d8e9e2118798","user":{"login":"ernest-okot","id":8332336,"node_id":"MDQ6VXNlcjgzMzIzMzY=","avatar_url":"https://avatars2.githubusercontent.com/u/8332336?v=4","gravatar_id":"","url":"https://api.github.com/users/ernest-okot","html_url":"https://github.com/ernest-okot","followers_url":"https://api.github.com/users/ernest-okot/followers","following_url":"https://api.github.com/users/ernest-okot/following{/other_user}","gists_url":"https://api.github.com/users/ernest-okot/gists{/gist_id}","starred_url":"https://api.github.com/users/ernest-okot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ernest-okot/subscriptions","organizations_url":"https://api.github.com/users/ernest-okot/orgs","repos_url":"https://api.github.com/users/ernest-okot/repos","events_url":"https://api.github.com/users/ernest-okot/events{/privacy}","received_events_url":"https://api.github.com/users/ernest-okot/received_events","type":"User","site_admin":false},"body":"substitute with config","created_at":"2018-11-21T11:37:48Z","updated_at":"2018-11-21T11:37:48Z","html_url":"https://github.com/sparkplug/momoapi-node/pull/6#discussion_r235353155","pull_request_url":"https://api.github.com/repos/sparkplug/momoapi-node/pulls/6","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/sparkplug/momoapi-node/pulls/comments/235353155"},"html":{"href":"https://github.com/sparkplug/momoapi-node/pull/6#discussion_r235353155"},"pull_request":{"href":"https://api.github.com/repos/sparkplug/momoapi-node/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/sparkplug/momoapi-node/pulls/6","id":232450931,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMyNDUwOTMx","html_url":"https://github.com/sparkplug/momoapi-node/pull/6","diff_url":"https://github.com/sparkplug/momoapi-node/pull/6.diff","patch_url":"https://github.com/sparkplug/momoapi-node/pull/6.patch","issue_url":"https://api.github.com/repos/sparkplug/momoapi-node/issues/6","number":6,"state":"open","locked":false,"title":"Proposal for user friendly interface","user":{"login":"ernest-okot","id":8332336,"node_id":"MDQ6VXNlcjgzMzIzMzY=","avatar_url":"https://avatars2.githubusercontent.com/u/8332336?v=4","gravatar_id":"","url":"https://api.github.com/users/ernest-okot","html_url":"https://github.com/ernest-okot","followers_url":"https://api.github.com/users/ernest-okot/followers","following_url":"https://api.github.com/users/ernest-okot/following{/other_user}","gists_url":"https://api.github.com/users/ernest-okot/gists{/gist_id}","starred_url":"https://api.github.com/users/ernest-okot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ernest-okot/subscriptions","organizations_url":"https://api.github.com/users/ernest-okot/orgs","repos_url":"https://api.github.com/users/ernest-okot/repos","events_url":"https://api.github.com/users/ernest-okot/events{/privacy}","received_events_url":"https://api.github.com/users/ernest-okot/received_events","type":"User","site_admin":false},"body":"This PR attempts to make things a little bit easier for the user;\r\n- Hides OAuth logic and uuid creation from the user\r\n- Adds a CLI tool for generating sandbox credentials\r\n- Supports different environments (\"sandbox\" and whatever)\r\n- Adds collections API structure that can be adopted for DIsbursements, Remittances, etc\r\n\r\nSee more on the proposed [README](https://github.com/ernest-okot/momoapi-node/blob/refactor/README.md)","created_at":"2018-11-20T20:33:55Z","updated_at":"2018-11-21T11:37:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8f949bac3f6f5a9614dfacfe5a27a12529498b12","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/sparkplug/momoapi-node/pulls/6/commits","review_comments_url":"https://api.github.com/repos/sparkplug/momoapi-node/pulls/6/comments","review_comment_url":"https://api.github.com/repos/sparkplug/momoapi-node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sparkplug/momoapi-node/issues/6/comments","statuses_url":"https://api.github.com/repos/sparkplug/momoapi-node/statuses/65afc174409d4903476b4714a142d8e9e2118798","head":{"label":"ernest-okot:refactor","ref":"refactor","sha":"65afc174409d4903476b4714a142d8e9e2118798","user":{"login":"ernest-okot","id":8332336,"node_id":"MDQ6VXNlcjgzMzIzMzY=","avatar_url":"https://avatars2.githubusercontent.com/u/8332336?v=4","gravatar_id":"","url":"https://api.github.com/users/ernest-okot","html_url":"https://github.com/ernest-okot","followers_url":"https://api.github.com/users/ernest-okot/followers","following_url":"https://api.github.com/users/ernest-okot/following{/other_user}","gists_url":"https://api.github.com/users/ernest-okot/gists{/gist_id}","starred_url":"https://api.github.com/users/ernest-okot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ernest-okot/subscriptions","organizations_url":"https://api.github.com/users/ernest-okot/orgs","repos_url":"https://api.github.com/users/ernest-okot/repos","events_url":"https://api.github.com/users/ernest-okot/events{/privacy}","received_events_url":"https://api.github.com/users/ernest-okot/received_events","type":"User","site_admin":false},"repo":{"id":158447648,"node_id":"MDEwOlJlcG9zaXRvcnkxNTg0NDc2NDg=","name":"momoapi-node","full_name":"ernest-okot/momoapi-node","private":false,"owner":{"login":"ernest-okot","id":8332336,"node_id":"MDQ6VXNlcjgzMzIzMzY=","avatar_url":"https://avatars2.githubusercontent.com/u/8332336?v=4","gravatar_id":"","url":"https://api.github.com/users/ernest-okot","html_url":"https://github.com/ernest-okot","followers_url":"https://api.github.com/users/ernest-okot/followers","following_url":"https://api.github.com/users/ernest-okot/following{/other_user}","gists_url":"https://api.github.com/users/ernest-okot/gists{/gist_id}","starred_url":"https://api.github.com/users/ernest-okot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ernest-okot/subscriptions","organizations_url":"https://api.github.com/users/ernest-okot/orgs","repos_url":"https://api.github.com/users/ernest-okot/repos","events_url":"https://api.github.com/users/ernest-okot/events{/privacy}","received_events_url":"https://api.github.com/users/ernest-okot/received_events","type":"User","site_admin":false},"html_url":"https://github.com/ernest-okot/momoapi-node","description":"MTN MoMo API Client for Node","fork":true,"url":"https://api.github.com/repos/ernest-okot/momoapi-node","forks_url":"https://api.github.com/repos/ernest-okot/momoapi-node/forks","keys_url":"https://api.github.com/repos/ernest-okot/momoapi-node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ernest-okot/momoapi-node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ernest-okot/momoapi-node/teams","hooks_url":"https://api.github.com/repos/ernest-okot/momoapi-node/hooks","issue_events_url":"https://api.github.com/repos/ernest-okot/momoapi-node/issues/events{/number}","events_url":"https://api.github.com/repos/ernest-okot/momoapi-node/events","assignees_url":"https://api.github.com/repos/ernest-okot/momoapi-node/assignees{/user}","branches_url":"https://api.github.com/repos/ernest-okot/momoapi-node/branches{/branch}","tags_url":"https://api.github.com/repos/ernest-okot/momoapi-node/tags","blobs_url":"https://api.github.com/repos/ernest-okot/momoapi-node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ernest-okot/momoapi-node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ernest-okot/momoapi-node/git/refs{/sha}","trees_url":"https://api.github.com/repos/ernest-okot/momoapi-node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ernest-okot/momoapi-node/statuses/{sha}","languages_url":"https://api.github.com/repos/ernest-okot/momoapi-node/languages","stargazers_url":"https://api.github.com/repos/ernest-okot/momoapi-node/stargazers","contributors_url":"https://api.github.com/repos/ernest-okot/momoapi-node/contributors","subscribers_url":"https://api.github.com/repos/ernest-okot/momoapi-node/subscribers","subscription_url":"https://api.github.com/repos/ernest-okot/momoapi-node/subscription","commits_url":"https://api.github.com/repos/ernest-okot/momoapi-node/commits{/sha}","git_commits_url":"https://api.github.com/repos/ernest-okot/momoapi-node/git/commits{/sha}","comments_url":"https://api.github.com/repos/ernest-okot/momoapi-node/comments{/number}","issue_comment_url":"https://api.github.com/repos/ernest-okot/momoapi-node/issues/comments{/number}","contents_url":"https://api.github.com/repos/ernest-okot/momoapi-node/contents/{+path}","compare_url":"https://api.github.com/repos/ernest-okot/momoapi-node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ernest-okot/momoapi-node/merges","archive_url":"https://api.github.com/repos/ernest-okot/momoapi-node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ernest-okot/momoapi-node/downloads","issues_url":"https://api.github.com/repos/ernest-okot/momoapi-node/issues{/number}","pulls_url":"https://api.github.com/repos/ernest-okot/momoapi-node/pulls{/number}","milestones_url":"https://api.github.com/repos/ernest-okot/momoapi-node/milestones{/number}","notifications_url":"https://api.github.com/repos/ernest-okot/momoapi-node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ernest-okot/momoapi-node/labels{/name}","releases_url":"https://api.github.com/repos/ernest-okot/momoapi-node/releases{/id}","deployments_url":"https://api.github.com/repos/ernest-okot/momoapi-node/deployments","created_at":"2018-11-20T20:31:28Z","updated_at":"2018-11-20T20:31:30Z","pushed_at":"2018-11-20T23:29:55Z","git_url":"git://github.com/ernest-okot/momoapi-node.git","ssh_url":"git@github.com:ernest-okot/momoapi-node.git","clone_url":"https://github.com/ernest-okot/momoapi-node.git","svn_url":"https://github.com/ernest-okot/momoapi-node","homepage":null,"size":1084,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sparkplug:master","ref":"master","sha":"978466fa1792a9ce0b60771d24a95d9e7cd963a2","user":{"login":"sparkplug","id":4108478,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDg0Nzg=","avatar_url":"https://avatars0.githubusercontent.com/u/4108478?v=4","gravatar_id":"","url":"https://api.github.com/users/sparkplug","html_url":"https://github.com/sparkplug","followers_url":"https://api.github.com/users/sparkplug/followers","following_url":"https://api.github.com/users/sparkplug/following{/other_user}","gists_url":"https://api.github.com/users/sparkplug/gists{/gist_id}","starred_url":"https://api.github.com/users/sparkplug/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sparkplug/subscriptions","organizations_url":"https://api.github.com/users/sparkplug/orgs","repos_url":"https://api.github.com/users/sparkplug/repos","events_url":"https://api.github.com/users/sparkplug/events{/privacy}","received_events_url":"https://api.github.com/users/sparkplug/received_events","type":"Organization","site_admin":false},"repo":{"id":154662871,"node_id":"MDEwOlJlcG9zaXRvcnkxNTQ2NjI4NzE=","name":"momoapi-node","full_name":"sparkplug/momoapi-node","private":false,"owner":{"login":"sparkplug","id":4108478,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQxMDg0Nzg=","avatar_url":"https://avatars0.githubusercontent.com/u/4108478?v=4","gravatar_id":"","url":"https://api.github.com/users/sparkplug","html_url":"https://github.com/sparkplug","followers_url":"https://api.github.com/users/sparkplug/followers","following_url":"https://api.github.com/users/sparkplug/following{/other_user}","gists_url":"https://api.github.com/users/sparkplug/gists{/gist_id}","starred_url":"https://api.github.com/users/sparkplug/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sparkplug/subscriptions","organizations_url":"https://api.github.com/users/sparkplug/orgs","repos_url":"https://api.github.com/users/sparkplug/repos","events_url":"https://api.github.com/users/sparkplug/events{/privacy}","received_events_url":"https://api.github.com/users/sparkplug/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/sparkplug/momoapi-node","description":"MTN MoMo API Client for Node","fork":false,"url":"https://api.github.com/repos/sparkplug/momoapi-node","forks_url":"https://api.github.com/repos/sparkplug/momoapi-node/forks","keys_url":"https://api.github.com/repos/sparkplug/momoapi-node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sparkplug/momoapi-node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sparkplug/momoapi-node/teams","hooks_url":"https://api.github.com/repos/sparkplug/momoapi-node/hooks","issue_events_url":"https://api.github.com/repos/sparkplug/momoapi-node/issues/events{/number}","events_url":"https://api.github.com/repos/sparkplug/momoapi-node/events","assignees_url":"https://api.github.com/repos/sparkplug/momoapi-node/assignees{/user}","branches_url":"https://api.github.com/repos/sparkplug/momoapi-node/branches{/branch}","tags_url":"https://api.github.com/repos/sparkplug/momoapi-node/tags","blobs_url":"https://api.github.com/repos/sparkplug/momoapi-node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sparkplug/momoapi-node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sparkplug/momoapi-node/git/refs{/sha}","trees_url":"https://api.github.com/repos/sparkplug/momoapi-node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sparkplug/momoapi-node/statuses/{sha}","languages_url":"https://api.github.com/repos/sparkplug/momoapi-node/languages","stargazers_url":"https://api.github.com/repos/sparkplug/momoapi-node/stargazers","contributors_url":"https://api.github.com/repos/sparkplug/momoapi-node/contributors","subscribers_url":"https://api.github.com/repos/sparkplug/momoapi-node/subscribers","subscription_url":"https://api.github.com/repos/sparkplug/momoapi-node/subscription","commits_url":"https://api.github.com/repos/sparkplug/momoapi-node/commits{/sha}","git_commits_url":"https://api.github.com/repos/sparkplug/momoapi-node/git/commits{/sha}","comments_url":"https://api.github.com/repos/sparkplug/momoapi-node/comments{/number}","issue_comment_url":"https://api.github.com/repos/sparkplug/momoapi-node/issues/comments{/number}","contents_url":"https://api.github.com/repos/sparkplug/momoapi-node/contents/{+path}","compare_url":"https://api.github.com/repos/sparkplug/momoapi-node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sparkplug/momoapi-node/merges","archive_url":"https://api.github.com/repos/sparkplug/momoapi-node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sparkplug/momoapi-node/downloads","issues_url":"https://api.github.com/repos/sparkplug/momoapi-node/issues{/number}","pulls_url":"https://api.github.com/repos/sparkplug/momoapi-node/pulls{/number}","milestones_url":"https://api.github.com/repos/sparkplug/momoapi-node/milestones{/number}","notifications_url":"https://api.github.com/repos/sparkplug/momoapi-node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sparkplug/momoapi-node/labels{/name}","releases_url":"https://api.github.com/repos/sparkplug/momoapi-node/releases{/id}","deployments_url":"https://api.github.com/repos/sparkplug/momoapi-node/deployments","created_at":"2018-10-25T11:55:49Z","updated_at":"2018-11-21T06:29:09Z","pushed_at":"2018-11-20T23:29:56Z","git_url":"git://github.com/sparkplug/momoapi-node.git","ssh_url":"git@github.com:sparkplug/momoapi-node.git","clone_url":"https://github.com/sparkplug/momoapi-node.git","svn_url":"https://github.com/sparkplug/momoapi-node","homepage":null,"size":1079,"stargazers_count":3,"watchers_count":3,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":4,"open_issues":3,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sparkplug/momoapi-node/pulls/6"},"html":{"href":"https://github.com/sparkplug/momoapi-node/pull/6"},"issue":{"href":"https://api.github.com/repos/sparkplug/momoapi-node/issues/6"},"comments":{"href":"https://api.github.com/repos/sparkplug/momoapi-node/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/sparkplug/momoapi-node/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/sparkplug/momoapi-node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sparkplug/momoapi-node/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/sparkplug/momoapi-node/statuses/65afc174409d4903476b4714a142d8e9e2118798"}},"author_association":"NONE"}}
{"actor":{"display_login":"ernest-okot"}}