Created
May 24, 2016 21:09
-
-
Save joetemp/2bef1476682f12333cb4d301839dba15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = function (API_KEY, deals) { | |
| const request = require('request-promise'); | |
| var junk = 'nothing'; | |
| var dealsObj = {}; | |
| function getIt (url) { | |
| return request(url).then(function (body) { | |
| return JSON.parse(body).data; | |
| }); | |
| } | |
| deals.forEach(function(deal) { | |
| dealsObj[deal.id] = deal; | |
| }); | |
| var dealsArr = Object.keys(dealsObj).map(function(deal){ | |
| return Number(deal); | |
| }); | |
| dealsArr.forEach(function(deal){ | |
| var url = 'https://api.pipedrive.com/v1/deals/' + deal + '/participants?start=0&api_token=' + API_KEY; | |
| Promise.all([getIt(url), junk]).then(function(results) { | |
| var people = results[0]; | |
| console.log('Participants of deal ' + deal); | |
| people.forEach(function(person) { | |
| console.log(person.person_id.value); | |
| }); | |
| }); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment