-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathdata.js
52 lines (40 loc) · 898 Bytes
/
data.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
// https://xivapi.com/docs/Welcome#section-4
const Lib = require('./Lib')
class Content extends Lib {
constructor(parent) {
super(parent)
}
async content() {
return this.req('/content')
}
/*
{
limit
ids
}
*/
async list(name, params={}) {
if(typeof name==='undefined')
throw this.throwError('data.list()','a name')
if(params.ids)
params.ids = this.parent.utils.makeCSV(params.ids)
return this.req(`/${name}`, params)
}
async get(name, id) {
const missing_params = []
if(typeof name==='undefined')
missing_params.push('a name')
if(typeof id==='undefined')
missing_params.push('an ID')
if(missing_params.length>0)
throw this.throwError('data.get()', missing_params.join(','))
return this.req(`/${name}/${id}`)
}
servers() {
return this.req('/servers')
}
datacenters() {
return this.req('/servers/dc')
}
}
module.exports = Content