forked from andrew/node-lanyrd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lanyrd.js
69 lines (68 loc) · 2.05 KB
/
lanyrd.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
var request = require('request')
var getRows = function(rows){
var merged = [];
if ( typeof rows !== 'undefined' && rows )
{
for(var i=0; i<rows.length; i++) {
merged = merged.concat(rows[i]['rows']);
}
}
return merged
}
var Lanyrd = {
get: function (path, cb){
var opts = {
url: 'http://lanyrd.com/mobile/ios2/'+path,
json: true,
headers: {
'X-Lanyrd-Auth': Math.random().toString()
}}
request(opts, cb)
},
popular: function (cb){
this.get('search/', function(error, response, body){
cb(error, response, body['sections'][0]['rows'])
})
},
search: function (query, cb){
this.get('search/?query='+query, function(error, response, body){
cb(error, response, body['sections'][0]['rows'])
})
},
event: function (slug, year, cb){
this.get(year +'/' + slug + '/', function(error, response, body){
cb(error, response, body)
})
},
speakers: function (slug, year, cb){
this.get(year +'/' + slug + '/speakers/', function(error, response, body){
cb(error, response, getRows(body['sections']))
})
},
attendees: function (slug, year, cb){
this.get(year +'/' + slug + '/attendees/', function(error, response, body){
cb(error, response, getRows(body['sections']))
})
},
schedule: function (slug, year, cb){
this.get(year +'/' + slug + '/schedule/', function(error, response, body){
cb(error, response, getRows(body['sections']))
})
},
scheduleDetail: function (date, slug, year, cb){
this.get(year +'/' + slug + '/schedule/' + date, function(error, response, body){
cb(error, response, getRows(body['sections']))
})
},
profile: function (username, cb){
this.get('profile/' + username + '/', function(error, response, body){
cb(error, response, body)
})
},
futureEvents: function (username, cb){
this.get('profile/' + username + '/action/', function(error, response, body){
cb(error, response, body['events'])
})
}
}
module.exports = Lanyrd