{"action":"closed","number":125,"pull_request":{"url":"https://api.github.com/repos/intercom/intercom-node/pulls/125","id":90189866,"html_url":"https://github.com/intercom/intercom-node/pull/125","diff_url":"https://github.com/intercom/intercom-node/pull/125.diff","patch_url":"https://github.com/intercom/intercom-node/pull/125.patch","issue_url":"https://api.github.com/repos/intercom/intercom-node/issues/125","number":125,"state":"closed","locked":false,"title":"Make users.scroll return a promise and wait for inner promises","user":{"login":"louisremi","id":39374,"avatar_url":"https://avatars.githubusercontent.com/u/39374?v=3","gravatar_id":"","url":"https://api.github.com/users/louisremi","html_url":"https://github.com/louisremi","followers_url":"https://api.github.com/users/louisremi/followers","following_url":"https://api.github.com/users/louisremi/following{/other_user}","gists_url":"https://api.github.com/users/louisremi/gists{/gist_id}","starred_url":"https://api.github.com/users/louisremi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/louisremi/subscriptions","organizations_url":"https://api.github.com/users/louisremi/orgs","repos_url":"https://api.github.com/users/louisremi/repos","events_url":"https://api.github.com/users/louisremi/events{/privacy}","received_events_url":"https://api.github.com/users/louisremi/received_events","type":"User","site_admin":false},"body":"I've started using users.scroll but I had a few issues with this method.\r\n\r\nFirst, unlike other methods of the API, this one didn't return a promise, which is inconsistent and made my life harder :-)\r\n\r\nSecondly, this method gives me no control on when it will scroll. Basically, once started, it will scroll until the end of the list of users. In my use-case, I wanted to store in a DB a few info about the users I retrieved:\r\n```js\r\nclient.users.scroll.each({}, function (res) {\r\n  res.body.users.forEach((user) => {\r\n    remoteDb.store(user.id, user.email);\r\n  });\r\n});\r\n```\r\nDoing this means that I will have a potentially HUGE number of concurrent queries to my database, and large memory consumption as well.\r\n\r\nThis patch makes it possible to return a Promise from the callback, and users.scroll will wait for this promise to resolve before scrolling:\r\n```js\r\nclient.users.scroll.each({}, function (res) {\r\n  return Promise.all(res.body.users.map((user) => {\r\n    return remoteDb.store(user.id, user.email);\r\n  }));\r\n});\r\n```\r\n\r\nThank you in advance!","created_at":"2016-10-20T12:25:30Z","updated_at":"2016-10-20T14:38:37Z","closed_at":"2016-10-20T14:38:37Z","merged_at":"2016-10-20T14:38:37Z","merge_commit_sha":"dfa020f030d8cae0ee16ffc590c85b90ce8be18d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/intercom/intercom-node/pulls/125/commits","review_comments_url":"https://api.github.com/repos/intercom/intercom-node/pulls/125/comments","review_comment_url":"https://api.github.com/repos/intercom/intercom-node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/intercom/intercom-node/issues/125/comments","statuses_url":"https://api.github.com/repos/intercom/intercom-node/statuses/dfa020f030d8cae0ee16ffc590c85b90ce8be18d","head":{"label":"louisremi:feat/scroll-promises","ref":"feat/scroll-promises","sha":"dfa020f030d8cae0ee16ffc590c85b90ce8be18d","user":{"login":"louisremi","id":39374,"avatar_url":"https://avatars.githubusercontent.com/u/39374?v=3","gravatar_id":"","url":"https://api.github.com/users/louisremi","html_url":"https://github.com/louisremi","followers_url":"https://api.github.com/users/louisremi/followers","following_url":"https://api.github.com/users/louisremi/following{/other_user}","gists_url":"https://api.github.com/users/louisremi/gists{/gist_id}","starred_url":"https://api.github.com/users/louisremi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/louisremi/subscriptions","organizations_url":"https://api.github.com/users/louisremi/orgs","repos_url":"https://api.github.com/users/louisremi/repos","events_url":"https://api.github.com/users/louisremi/events{/privacy}","received_events_url":"https://api.github.com/users/louisremi/received_events","type":"User","site_admin":false},"repo":{"id":71447321,"name":"intercom-node","full_name":"louisremi/intercom-node","owner":{"login":"louisremi","id":39374,"avatar_url":"https://avatars.githubusercontent.com/u/39374?v=3","gravatar_id":"","url":"https://api.github.com/users/louisremi","html_url":"https://github.com/louisremi","followers_url":"https://api.github.com/users/louisremi/followers","following_url":"https://api.github.com/users/louisremi/following{/other_user}","gists_url":"https://api.github.com/users/louisremi/gists{/gist_id}","starred_url":"https://api.github.com/users/louisremi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/louisremi/subscriptions","organizations_url":"https://api.github.com/users/louisremi/orgs","repos_url":"https://api.github.com/users/louisremi/repos","events_url":"https://api.github.com/users/louisremi/events{/privacy}","received_events_url":"https://api.github.com/users/louisremi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/louisremi/intercom-node","description":"Node.js bindings for the Intercom API ","fork":true,"url":"https://api.github.com/repos/louisremi/intercom-node","forks_url":"https://api.github.com/repos/louisremi/intercom-node/forks","keys_url":"https://api.github.com/repos/louisremi/intercom-node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/louisremi/intercom-node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/louisremi/intercom-node/teams","hooks_url":"https://api.github.com/repos/louisremi/intercom-node/hooks","issue_events_url":"https://api.github.com/repos/louisremi/intercom-node/issues/events{/number}","events_url":"https://api.github.com/repos/louisremi/intercom-node/events","assignees_url":"https://api.github.com/repos/louisremi/intercom-node/assignees{/user}","branches_url":"https://api.github.com/repos/louisremi/intercom-node/branches{/branch}","tags_url":"https://api.github.com/repos/louisremi/intercom-node/tags","blobs_url":"https://api.github.com/repos/louisremi/intercom-node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/louisremi/intercom-node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/louisremi/intercom-node/git/refs{/sha}","trees_url":"https://api.github.com/repos/louisremi/intercom-node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/louisremi/intercom-node/statuses/{sha}","languages_url":"https://api.github.com/repos/louisremi/intercom-node/languages","stargazers_url":"https://api.github.com/repos/louisremi/intercom-node/stargazers","contributors_url":"https://api.github.com/repos/louisremi/intercom-node/contributors","subscribers_url":"https://api.github.com/repos/louisremi/intercom-node/subscribers","subscription_url":"https://api.github.com/repos/louisremi/intercom-node/subscription","commits_url":"https://api.github.com/repos/louisremi/intercom-node/commits{/sha}","git_commits_url":"https://api.github.com/repos/louisremi/intercom-node/git/commits{/sha}","comments_url":"https://api.github.com/repos/louisremi/intercom-node/comments{/number}","issue_comment_url":"https://api.github.com/repos/louisremi/intercom-node/issues/comments{/number}","contents_url":"https://api.github.com/repos/louisremi/intercom-node/contents/{+path}","compare_url":"https://api.github.com/repos/louisremi/intercom-node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/louisremi/intercom-node/merges","archive_url":"https://api.github.com/repos/louisremi/intercom-node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/louisremi/intercom-node/downloads","issues_url":"https://api.github.com/repos/louisremi/intercom-node/issues{/number}","pulls_url":"https://api.github.com/repos/louisremi/intercom-node/pulls{/number}","milestones_url":"https://api.github.com/repos/louisremi/intercom-node/milestones{/number}","notifications_url":"https://api.github.com/repos/louisremi/intercom-node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/louisremi/intercom-node/labels{/name}","releases_url":"https://api.github.com/repos/louisremi/intercom-node/releases{/id}","deployments_url":"https://api.github.com/repos/louisremi/intercom-node/deployments","created_at":"2016-10-20T09:34:07Z","updated_at":"2016-10-20T09:34:09Z","pushed_at":"2016-10-20T12:08:49Z","git_url":"git://github.com/louisremi/intercom-node.git","ssh_url":"git@github.com:louisremi/intercom-node.git","clone_url":"https://github.com/louisremi/intercom-node.git","svn_url":"https://github.com/louisremi/intercom-node","homepage":"https://developers.intercom.io/reference","size":135,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"intercom:master","ref":"master","sha":"411fdc20acf17606726d9143c14a301c24b72a8d","user":{"login":"intercom","id":6585,"avatar_url":"https://avatars.githubusercontent.com/u/6585?v=3","gravatar_id":"","url":"https://api.github.com/users/intercom","html_url":"https://github.com/intercom","followers_url":"https://api.github.com/users/intercom/followers","following_url":"https://api.github.com/users/intercom/following{/other_user}","gists_url":"https://api.github.com/users/intercom/gists{/gist_id}","starred_url":"https://api.github.com/users/intercom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intercom/subscriptions","organizations_url":"https://api.github.com/users/intercom/orgs","repos_url":"https://api.github.com/users/intercom/repos","events_url":"https://api.github.com/users/intercom/events{/privacy}","received_events_url":"https://api.github.com/users/intercom/received_events","type":"Organization","site_admin":false},"repo":{"id":24102687,"name":"intercom-node","full_name":"intercom/intercom-node","owner":{"login":"intercom","id":6585,"avatar_url":"https://avatars.githubusercontent.com/u/6585?v=3","gravatar_id":"","url":"https://api.github.com/users/intercom","html_url":"https://github.com/intercom","followers_url":"https://api.github.com/users/intercom/followers","following_url":"https://api.github.com/users/intercom/following{/other_user}","gists_url":"https://api.github.com/users/intercom/gists{/gist_id}","starred_url":"https://api.github.com/users/intercom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intercom/subscriptions","organizations_url":"https://api.github.com/users/intercom/orgs","repos_url":"https://api.github.com/users/intercom/repos","events_url":"https://api.github.com/users/intercom/events{/privacy}","received_events_url":"https://api.github.com/users/intercom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/intercom/intercom-node","description":"Node.js bindings for the Intercom API ","fork":false,"url":"https://api.github.com/repos/intercom/intercom-node","forks_url":"https://api.github.com/repos/intercom/intercom-node/forks","keys_url":"https://api.github.com/repos/intercom/intercom-node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/intercom/intercom-node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/intercom/intercom-node/teams","hooks_url":"https://api.github.com/repos/intercom/intercom-node/hooks","issue_events_url":"https://api.github.com/repos/intercom/intercom-node/issues/events{/number}","events_url":"https://api.github.com/repos/intercom/intercom-node/events","assignees_url":"https://api.github.com/repos/intercom/intercom-node/assignees{/user}","branches_url":"https://api.github.com/repos/intercom/intercom-node/branches{/branch}","tags_url":"https://api.github.com/repos/intercom/intercom-node/tags","blobs_url":"https://api.github.com/repos/intercom/intercom-node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/intercom/intercom-node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/intercom/intercom-node/git/refs{/sha}","trees_url":"https://api.github.com/repos/intercom/intercom-node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/intercom/intercom-node/statuses/{sha}","languages_url":"https://api.github.com/repos/intercom/intercom-node/languages","stargazers_url":"https://api.github.com/repos/intercom/intercom-node/stargazers","contributors_url":"https://api.github.com/repos/intercom/intercom-node/contributors","subscribers_url":"https://api.github.com/repos/intercom/intercom-node/subscribers","subscription_url":"https://api.github.com/repos/intercom/intercom-node/subscription","commits_url":"https://api.github.com/repos/intercom/intercom-node/commits{/sha}","git_commits_url":"https://api.github.com/repos/intercom/intercom-node/git/commits{/sha}","comments_url":"https://api.github.com/repos/intercom/intercom-node/comments{/number}","issue_comment_url":"https://api.github.com/repos/intercom/intercom-node/issues/comments{/number}","contents_url":"https://api.github.com/repos/intercom/intercom-node/contents/{+path}","compare_url":"https://api.github.com/repos/intercom/intercom-node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/intercom/intercom-node/merges","archive_url":"https://api.github.com/repos/intercom/intercom-node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/intercom/intercom-node/downloads","issues_url":"https://api.github.com/repos/intercom/intercom-node/issues{/number}","pulls_url":"https://api.github.com/repos/intercom/intercom-node/pulls{/number}","milestones_url":"https://api.github.com/repos/intercom/intercom-node/milestones{/number}","notifications_url":"https://api.github.com/repos/intercom/intercom-node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/intercom/intercom-node/labels{/name}","releases_url":"https://api.github.com/repos/intercom/intercom-node/releases{/id}","deployments_url":"https://api.github.com/repos/intercom/intercom-node/deployments","created_at":"2014-09-16T14:21:30Z","updated_at":"2016-10-14T15:31:47Z","pushed_at":"2016-10-20T14:38:37Z","git_url":"git://github.com/intercom/intercom-node.git","ssh_url":"git@github.com:intercom/intercom-node.git","clone_url":"https://github.com/intercom/intercom-node.git","svn_url":"https://github.com/intercom/intercom-node","homepage":"https://developers.intercom.io/reference","size":144,"stargazers_count":86,"watchers_count":86,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"open_issues_count":6,"forks":28,"open_issues":6,"watchers":86,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/intercom/intercom-node/pulls/125"},"html":{"href":"https://github.com/intercom/intercom-node/pull/125"},"issue":{"href":"https://api.github.com/repos/intercom/intercom-node/issues/125"},"comments":{"href":"https://api.github.com/repos/intercom/intercom-node/issues/125/comments"},"review_comments":{"href":"https://api.github.com/repos/intercom/intercom-node/pulls/125/comments"},"review_comment":{"href":"https://api.github.com/repos/intercom/intercom-node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/intercom/intercom-node/pulls/125/commits"},"statuses":{"href":"https://api.github.com/repos/intercom/intercom-node/statuses/dfa020f030d8cae0ee16ffc590c85b90ce8be18d"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"Skaelv","id":5072452,"avatar_url":"https://avatars.githubusercontent.com/u/5072452?v=3","gravatar_id":"","url":"https://api.github.com/users/Skaelv","html_url":"https://github.com/Skaelv","followers_url":"https://api.github.com/users/Skaelv/followers","following_url":"https://api.github.com/users/Skaelv/following{/other_user}","gists_url":"https://api.github.com/users/Skaelv/gists{/gist_id}","starred_url":"https://api.github.com/users/Skaelv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Skaelv/subscriptions","organizations_url":"https://api.github.com/users/Skaelv/orgs","repos_url":"https://api.github.com/users/Skaelv/repos","events_url":"https://api.github.com/users/Skaelv/events{/privacy}","received_events_url":"https://api.github.com/users/Skaelv/received_events","type":"User","site_admin":false},"comments":2,"review_comments":0,"commits":4,"additions":74,"deletions":12,"changed_files":3}}
{"actor":{"display_login":"Skaelv"}}