Created
April 11, 2016 07:01
-
-
Save joetemp/6e2c166cd87c779b7e935eaa46eb78aa 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
| const request = require('request'); | |
| var urls = { deals: 'https://api.pipedrive.com/v1/deals?start=0&api_token=12345', | |
| activities : 'https://api.pipedrive.com/v1/activities?start=0&api_token=12345' }; | |
| var applications = []; | |
| var alreadyHave4506T = []; | |
| function getIt (url, callback) { | |
| request(url, function (error, response, body) { | |
| if (error) { | |
| return console.log(error); | |
| } | |
| var parse = JSON.parse(body).data; | |
| callback(parse); | |
| }); | |
| } | |
| function inStageTwo (deal) { | |
| if (deal.stage_id === 2) { | |
| applications.push(deal.id); | |
| } | |
| } | |
| function has4506T (activity) { | |
| if (activity.subject === '4506-T') { | |
| alreadyHave4506T.push(activity.deal_id); | |
| } | |
| } | |
| getIt (urls.deals, function (deals) { | |
| deals.forEach(inStageTwo); | |
| console.log (applications); | |
| }); | |
| getIt (urls.activities, function (activities) { | |
| activities.forEach(has4506T); | |
| console.log(alreadyHave4506T); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment