-
-
Notifications
You must be signed in to change notification settings - Fork 144
/
index.js
43 lines (33 loc) · 1.04 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
'use strict';
require('promise-log')(Promise);
const R = require('ramda');
const STORES = {
'gplay': require('./lib/stores/gplay'),
'itunes': require('./lib/stores/itunes')
};
const constants = require('./lib/constants');
const buildApp = require('./lib/app');
const buildScores = require('./lib/scores');
const buildSuggest = require('./lib/suggest');
const buildVisibility = require('./lib/visibility');
function getClient (store, opts) {
// not forcing store to be a string anymore, in case someone wanats to pass
// a homebrew object, e.g. to disable memoization
if (R.is(String, store)) {
opts = Object.assign({
country: 'us',
throttle: 20
}, opts);
if (!(store in STORES)) {
throw Error(`the store name should be one of: ${Object.keys(STORES).join(', ')}`);
}
store = STORES[store](opts);
}
return Object.assign({
app: buildApp(store),
scores: buildScores(store),
suggest: buildSuggest(store),
visibility: buildVisibility(store)
}, constants);
}
module.exports = getClient;