-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
58 lines (48 loc) · 1.39 KB
/
index.js
File metadata and controls
58 lines (48 loc) · 1.39 KB
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
'use strict';
const customerInvoiceDraftsModule = require('./src/CustomerInvoiceDrafts');
const ArticlesModule = require('./src/Articles');
const CustomersModule = require('./src/Customers');
module.exports = (environment) => {
if(typeof environment == 'undefined'){
var APIURL = 'https://eaccountingapi-sandbox.test.vismaonline.com';
var AUTHURL = 'https://auth-sandbox.test.vismaonline.com/eaccountingapi/oauth';
} else if (environment == 'production'){
var APIURL = 'https://eaccounting.vismaonline.com/api/';
var AUTHURL = 'https://auth.vismaonline.com/eaccountingapi/oauth/token';
}
const globalOptions = {
http: {
uri: ''
},
apiVersion: 'v1',
};
const globalCredentials = {
auth: {
tokenHost: '',
tokenPath: '/eaccountingapi/oauth/token',
revokePath: '/eaccountingapi/oauth/revoke',
authorizePath: '/eaccountingapi/oauth/authorize'
}
}
return {
auth(credentials) {
credentials = Object.assign({}, credentials, globalCredentials);
return require('simple-oauth2').create(credentials);
},
/**
* @param {Object}
* @return {Object}
*/
create(options) {
options = Object.assign({}, globalOptions, options);
return {
customerInvoiceDrafts: customerInvoiceDraftsModule(options),
customers: CustomersModule(options),
articles: CustomersModule(options)
};
},
};
};
// 1. authenticate
// 2. make a request
// 3. parse it