/
url_helper.js
61 lines (51 loc) · 1.71 KB
/
url_helper.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
var config = require('../config');
function getEntityUrl(entityType, name) {
// URL should look like: http://api.crunchbase.com/v/1/Entity/Name.js
return 'http://api.crunchbase.com/v/1/'
+ encodeURIComponent(entityType)
+ '/'
+ encodeURIComponent(name)
+ '.js?api_key='
+ config.apikey;
}
function getEntityListUrl(entityType) {
// URL should look like: http://api.crunchbase.com/v/1/Entity-Type.js
return 'http://api.crunchbase.com/v/1/'
+ entityType
+ '.js?api_key='
+ config.apikey;
}
function searchUrl(query) {
// URL should look like: http://api.crunchbase.com/v/1/search.js
return 'http://api.crunchbase.com/v/1/search.js?query='
+ encodeURIComponent(query)
+ '&api_key='
+ config.apikey;
}
function getPostsUrl(entityType, name, firstName, lastName) {
// URL should look like: http://api.crunchbase.com/v/1/companies/posts?name=NAME&first_name=FIRST_NAME&last_name=LAST_NAME&api_key=XXXX
return 'http://api.crunchbase.com/v/1/'
+ entityType
+ '/posts?name='
+ encodeURIComponent(name)
+ '&first_name='
+ encodeURIComponent(firstName)
+ '&last_name='
+ encodeURIComponent(lastName)
+ '&api_key='
+ config.apikey;
}
module.exports = {
getEntityUrl: function(entityType, name) {
return getEntityUrl(entityType, name);
},
getEntityListUrl: function(entityType) {
return getEntityListUrl(entityType);
},
searchUrl: function(query) {
return searchUrl(query);
},
getPostsUrl: function(entityType, name, firstName, lastName) {
return getPostsUrl(entityType, name, firstName, lastName);
}
}