-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.js
120 lines (104 loc) · 2.92 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// Copyright 2014 CodingHouse Winter Cohort
request = require('request'),
urlHelper = require('./util/url_helper');
function init(apikey) {
urlHelper.init(apikey);
}
function getOrganizations(params, callback) {
var url = urlHelper.getOrganizationsUrl(params);
createRequest(url, callback);
}
function getOrganization(permalink, callback) {
var url = urlHelper.getOrganizationUrl(permalink);
createRequest(url, callback);
}
function getPeople(page, callback){
var url = urlHelper.getPeopleUrl(page);
createRequest(url, callback);
}
function getPerson(permalink, callback){
var url = urlHelper.getPersonUrl(permalink);
createRequest(url, callback);
}
function getProducts(params, callback) {
var url = urlHelper.getProductsUrl(params);
createRequest(url, callback);
}
function getProduct(permalink, callback) {
var url = urlHelper.getProductUrl(permalink);
createRequest(url, callback);
}
function getFundingRound(uuid, callback) {
var url = urlHelper.getFundingRoundUrl(uuid);
createRequest(url, callback);
}
function getAcquisition(uuid, callback) {
var url = urlHelper.getAcquisitionUrl(uuid);
createRequest(url, callback);
}
function getIPO(uuid, callback) {
var url = urlHelper.getIPOUrl(uuid);
createRequest(url, callback);
}
function getFundRaise(uuid, callback) {
var url = urlHelper.getFundRaiseUrl(uuid);
createRequest(url, callback);
}
function getLocations(params, callback) {
var url = urlHelper.getLocationsUrl(params);
createRequest(url, callback);
}
function getCatagories(params, callback) {
var url = urlHelper.getCatagoriesUrl(params);
createRequest(url, callback);
}
function createRequest(url, callback) {
request(url, function (error, response, body) {
try {
callback(error, JSON.parse(body));
} catch (error) {
callback(error, body);
}
});
}
module.exports = {
init: function(apikey) {
return init(apikey);
},
organizations: function(params, callback) {
return getOrganizations(params, callback);
},
organization: function(permalink, callback) {
return getOrganization(permalink, callback);
},
people: function(page, callback) {
return getPeople(page, callback);
},
person: function(permalink, callback) {
return getPerson(permalink, callback);
},
products: function(params, callback) {
return getProducts(params, callback);
},
product: function(permalink, callback) {
return getProduct(permalink, callback);
},
fundingRound: function(uuid, callback) {
return getFundingRound(uuid, callback);
},
acquisition: function(uuid, callback) {
return getAcquisition(uuid, callback);
},
ipo: function(uuid, callback) {
return getIPO(uuid, callback);
},
fundRaise: function(uuid, callback) {
return getFundRaise(uuid, callback);
},
locations: function(params, callback) {
return getLocations(params, callback);
},
catagories: function(params) {
return getCatagories(params);
}
}