@vouchfor/sdk 1.0.3 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,6 +13,7 @@ class BaseService {
|
|
|
13
13
|
async _callApi({
|
|
14
14
|
apiKey = '',
|
|
15
15
|
integrationKey = '',
|
|
16
|
+
method,
|
|
16
17
|
body,
|
|
17
18
|
url,
|
|
18
19
|
}) {
|
|
@@ -26,7 +27,12 @@ class BaseService {
|
|
|
26
27
|
headers['x-integration-key'] = integrationKey;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
return utils.request({
|
|
30
|
+
return utils.request({
|
|
31
|
+
body,
|
|
32
|
+
headers,
|
|
33
|
+
method,
|
|
34
|
+
url,
|
|
35
|
+
});
|
|
30
36
|
}
|
|
31
37
|
}
|
|
32
38
|
|
|
@@ -11,10 +11,11 @@ class BaseIntegrationService extends BaseService {
|
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
_request({ body, path }) {
|
|
14
|
+
_request({ body, method, path }) {
|
|
15
15
|
return this._callApi({
|
|
16
16
|
apiKey: this._apiKey,
|
|
17
17
|
body,
|
|
18
|
+
method,
|
|
18
19
|
url: `${this._baseUrl}/${path}`,
|
|
19
20
|
});
|
|
20
21
|
}
|
|
@@ -12,11 +12,12 @@ class BaseRestService extends BaseService {
|
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
_request({ apiKey, body, path }) {
|
|
15
|
+
_request({ apiKey, body, method, path }) {
|
|
16
16
|
return this._callApi({
|
|
17
17
|
apiKey: apiKey || this._apiKey,
|
|
18
18
|
integrationKey: this._integrationKey,
|
|
19
19
|
body,
|
|
20
|
+
method,
|
|
20
21
|
url: `${this._baseUrl}/${path}`,
|
|
21
22
|
});
|
|
22
23
|
}
|
package/lib/shared/utils.js
CHANGED
|
@@ -5,17 +5,17 @@ module.exports = {
|
|
|
5
5
|
const isProd = env === 'prod';
|
|
6
6
|
return isProd ? '' : `-${env}`;
|
|
7
7
|
},
|
|
8
|
-
request({ body, headers, url }) {
|
|
9
|
-
const { host, pathname } = new URL(url);
|
|
8
|
+
request({ body, headers, method, url }) {
|
|
9
|
+
const { host, pathname, search = '' } = new URL(url);
|
|
10
10
|
|
|
11
11
|
return new Promise((resolve, reject) => {
|
|
12
12
|
let result = '';
|
|
13
13
|
const req = https
|
|
14
14
|
.request({
|
|
15
15
|
host,
|
|
16
|
-
path: pathname
|
|
16
|
+
path: `${pathname}${search}`,
|
|
17
17
|
headers,
|
|
18
|
-
method: body ? 'POST' : 'GET',
|
|
18
|
+
method: method ? method : body ? 'POST' : 'GET',
|
|
19
19
|
},
|
|
20
20
|
(res) => {
|
|
21
21
|
res.on('data', (chunk) => {
|
|
@@ -27,7 +27,7 @@ module.exports = {
|
|
|
27
27
|
reject(res.statusMessage || 'error');
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const data = JSON.parse(result);
|
|
30
|
+
const data = !!result ? JSON.parse(result) : result;
|
|
31
31
|
resolve(data);
|
|
32
32
|
} catch (err) {
|
|
33
33
|
reject(err);
|
package/package.json
CHANGED
package/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const Vouch = require('./lib');
|
|
2
|
-
|
|
3
|
-
async function test() {
|
|
4
|
-
const client = new Vouch({
|
|
5
|
-
// apiKey: 'RVzB3aYVnL-mZvrgrKAc1npPuTBpafD6CmibDU7D217QugllFknGJbWVosoKF',
|
|
6
|
-
integrationKey: `ae0c85d5-bcca-4ad1-aa38-2860f9abf3e2-jG3gzsOne4UrZUvSxZxGbWcBDcQbuuGJlq7axF85tC53f7TxGz`,
|
|
7
|
-
env: 'dev',
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
const t = await client.integrations.authenticate({ entityId: 'RVzB3aYVnL' });
|
|
11
|
-
const vouches = await client.vouches.list('RVzB3aYVnL-mZvrgrKAc1npPuTBpafD6CmibDU7D217QugllFknGJbWVosoKF');
|
|
12
|
-
const vouch = await client.vouches.get('ieoacN59sY', 'RVzB3aYVnL-mZvrgrKAc1npPuTBpafD6CmibDU7D217QugllFknGJbWVosoKF');
|
|
13
|
-
const campaigns = await client.campaigns.list('RVzB3aYVnL-mZvrgrKAc1npPuTBpafD6CmibDU7D217QugllFknGJbWVosoKF');
|
|
14
|
-
const campaign = await client.campaigns.get('AndHUTxj82', 'RVzB3aYVnL-mZvrgrKAc1npPuTBpafD6CmibDU7D217QugllFknGJbWVosoKF');
|
|
15
|
-
const application = await client.applications.get('9ZOk1FkBoH', 'RVzB3aYVnL-mZvrgrKAc1npPuTBpafD6CmibDU7D217QugllFknGJbWVosoKF');
|
|
16
|
-
console.log(application)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
test()
|
|
20
|
-
|