Skip to content

Commit 1a38917

Browse files
committed
Make changes
1 parent bc81fa6 commit 1a38917

File tree

7 files changed

+55
-51
lines changed

7 files changed

+55
-51
lines changed

lib/character.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class Character extends Lib {
1414
*/
1515
async search(name, params={}) {
1616
if(!name)
17-
throw this.throwError('Character.search()', 'a name');
18-
return this.req(`/character/search`, Object.assign({}, params, {name}));
17+
throw this.throwError('character.search()', 'a name')
18+
return this.req('/character/search', Object.assign(params, {name}))
1919
}
2020

2121
/*
@@ -25,10 +25,10 @@ class Character extends Lib {
2525
}
2626
*/
2727
async get(id, params={}) {
28-
if(!id)
29-
throw this.throwError('Character.get()','an ID');
30-
31-
return this.req(`/character/${id}`, params);
28+
if(!id)
29+
throw this.throwError('character.get()','an ID')
30+
31+
return this.req(`/character/${id}`, params)
3232
}
3333
}
3434

lib/data.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Content extends Lib {
77
}
88

99
async content() {
10-
return this.req(`/content`);
10+
return this.req('/content')
1111
}
1212

1313
/*
@@ -17,32 +17,32 @@ class Content extends Lib {
1717
}
1818
*/
1919
async list(name, params={}) {
20-
if(typeof name==="undefined")
21-
throw this.throwError('Content.list()','a name');
22-
23-
params.ids = this.parent.utils.makeCSV(params.ids);
20+
if(typeof name==='undefined')
21+
throw this.throwError('data.list()','a name')
2422

25-
return this.req(`/${name}`, params);
23+
params.ids = this.parent.utils.makeCSV(params.ids)
24+
25+
return this.req(`/${name}`, params)
2626
}
2727

2828
async get(name, id) {
29-
const missing_params = [];
30-
if(typeof name==="undefined")
31-
missing_params.push('a name');
32-
if(typeof id==="undefined")
33-
missing_params.push('an ID');
29+
const missing_params = []
30+
if(typeof name==='undefined')
31+
missing_params.push('a name')
32+
if(typeof id==='undefined')
33+
missing_params.push('an ID')
3434
if(missing_params.length>0)
35-
throw this.throwError(`Content.get()`, missing_params.join(","));
36-
37-
return this.req(`/${name}/${id}`);
35+
throw this.throwError('data.get()', missing_params.join(','))
36+
37+
return this.req(`/${name}/${id}`)
3838
}
3939

4040
servers() {
41-
return this.req(`/servers`);
41+
return this.req('/servers')
4242
}
4343

4444
datacenters() {
45-
return this.req(`/servers/dc`);
45+
return this.req('/servers/dc')
4646
}
4747

4848

lib/freecompany.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class FreeCompany extends Lib {
1414
*/
1515
async search(name, params={}) {
1616
if(typeof(name) === 'undefined')
17-
throw this.throwError('FreeCompany.search()','a name');
18-
return this.req(`/freecompany/search`, Object.assign({}, params, {name}));
17+
throw this.throwError('freecompany.search()','a name')
18+
return this.req('/freecompany/search', Object.assign(params, {name}))
1919
}
2020

2121
/*
@@ -25,12 +25,12 @@ class FreeCompany extends Lib {
2525
}
2626
*/
2727
async get(id, params={}) {
28-
if(typeof(id) === 'undefined')
29-
throw this.throwError('FreeCompany.get()', 'an ID');
28+
if(typeof(id) === 'undefined')
29+
throw this.throwError('freecompany.get()', 'an ID')
3030

31-
params.data = this.makeCSV(params.data);
31+
params.data = this.makeCSV(params.data)
3232

33-
return this.req(`/freecompany/${id}`, params);
33+
return this.req(`/freecompany/${id}`, params)
3434
}
3535
}
3636

lib/linkshell.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ class Linkshell extends Lib {
1414
*/
1515
async search(name, params={}) {
1616
if(typeof(name) === 'undefined')
17-
throw this.throwError('LinkShell.search()','a name');
18-
return this.req(`/linkshell/search`, Object.assign({}, params, {name}));
17+
throw this.throwError('linkshell.search()','a name')
18+
return this.req('/linkshell/search', Object.assign(params, {name}))
1919
}
2020

2121
async get(id) {
22-
if(typeof(id) === 'undefined')
23-
throw this.throwError('LinkShell.get()', 'an ID');
24-
return this.req(`/linkshell/${id}`);
22+
if(typeof(id) === 'undefined')
23+
throw this.throwError('linkshell.get()', 'an ID')
24+
return this.req(`/linkshell/${id}`)
2525
}
2626
}
2727

lib/pvpteam.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ class PvPTeam extends Lib {
1313
}
1414
*/
1515
async search(name, params={}) {
16-
if(typeof name==="undefined")
17-
throw this.throwError(`PvPTeam.search()`, 'a name');
18-
19-
return this.req(`/pvpteam/search`,Object.assign({}, params, {name}));
16+
if(typeof name==='undefined')
17+
throw this.throwError('pvpteam.search()', 'a name')
18+
19+
return this.req('/pvpteam/search',Object.assign(params, {name}))
2020
}
2121

2222
async get(id) {
23-
if(typeof id==="undefined")
24-
throw this.throwError(`PvPTeam.get()`, 'an ID');
25-
26-
return this.req(`/pvpteam/${id}`);
23+
if(typeof id==='undefined')
24+
throw this.throwError('pvpteam.get()', 'an ID')
25+
26+
return this.req(`/pvpteam/${id}`)
2727
}
2828
}
2929

lib/search.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ let { req, reqJSON, makeCSV, throwError } = require('../utils')
1111
}
1212
*/
1313
module.exports = async function(input, params = {}) {
14-
req = req.bind(this);
15-
reqJSON = reqJSON.bind(this);
14+
req = req.bind(this)
15+
reqJSON = reqJSON.bind(this)
1616

1717
if(typeof(input) === 'undefined')
1818
throw throwError('search()', 'any input')
@@ -22,15 +22,15 @@ module.exports = async function(input, params = {}) {
2222
switch(typeof(input)) {
2323
// GET method
2424
case 'string':
25-
params.indexes = makeCSV(params.indexes);
26-
return req(path, Object.assign(params, {"string": input}));
25+
params.indexes = makeCSV(params.indexes)
26+
return req(path, Object.assign(params, {'string': input}))
2727

2828
// ElasticSearch JSON method
2929
case 'object':
30-
input.indexes = makeCSV(params.indexes);
31-
return reqJSON(path, input);
30+
input.indexes = makeCSV(params.indexes)
31+
return reqJSON(path, input)
3232

3333
default:
34-
throw new Error(`Unexpected input type for search: '${typeof(input)}'`);
34+
throw new Error(`Unexpected input type for search: '${typeof(input)}'`)
3535
}
3636
}

utils.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ const request = require('request-promise-native')
22

33
module.exports = {
44
//standard request function
5-
req(path, params) {
6-
if(params && typeof params.snake_case !== 'undefined')
7-
params.snake_case = params.snake_case ? 1 : 0
5+
req(path, params={}) {
6+
let convs = ['snake_case', 'extended']
7+
for (const c of convs) {
8+
if(typeof params[c] !== 'undefined')
9+
params[c] = params[c] ? 1 : 0
10+
}
11+
812

913
params = Object.assign({}, this.globalParams, params)
1014

0 commit comments

Comments
 (0)