@vouchfor/sdk 1.1.2 → 1.1.4
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.
|
@@ -5,6 +5,14 @@ class IntegrationService extends BaseIntegrationService {
|
|
|
5
5
|
super(client, config, '');
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
get applications() {
|
|
9
|
+
return {
|
|
10
|
+
list: () => {
|
|
11
|
+
return this._request({ path: 'applications' });
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
authenticate({ applicationId, entityId }) {
|
|
9
17
|
if (applicationId) {
|
|
10
18
|
return this._request({ path: `applications/${applicationId}/entity` });
|
|
@@ -28,6 +28,14 @@ class VouchService extends BaseRestService {
|
|
|
28
28
|
list(apiKey) {
|
|
29
29
|
return this._request({ apiKey, path: '' });
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
upload(vouch, apiKey) {
|
|
33
|
+
return this._request({
|
|
34
|
+
apiKey,
|
|
35
|
+
body: vouch,
|
|
36
|
+
path: 'upload',
|
|
37
|
+
});
|
|
38
|
+
}
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
module.exports = VouchService;
|
package/package.json
CHANGED
package/test.js
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
const Vouch = require("./lib/vouch");
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const vouch = new Vouch({
|
|
3
|
+
const vouchClient = new Vouch({
|
|
5
4
|
env: 'dev',
|
|
6
|
-
apiKey: 'M0VEaIFvWm-l06giRVS4VwvMcWdVuo2ROPFc7rw9QmtprtvTLIkTu26zo94c9',
|
|
7
5
|
integrationKey: 'b0883f06-84af-4108-8543-31874c335c36-kkr3Wy4CLY8C2g65UT79sgUfOIR2ZzkA9uQam3bTs4ZNdlSs7M'
|
|
8
6
|
});
|
|
9
7
|
|
|
8
|
+
(async () => {
|
|
9
|
+
const response = await vouchClient.integrations.applications.list();
|
|
10
|
+
const items = await response.applications.reduce(async (ac, application) => {
|
|
11
|
+
const arr = await ac;
|
|
12
|
+
console.log(`id => ${application.id}`);
|
|
13
|
+
try {
|
|
14
|
+
const credentials = await vouchClient.integrations.authenticate({ entityId: application.entity.id });
|
|
15
|
+
arr.push(credentials);
|
|
16
|
+
} catch (err) {
|
|
17
|
+
console.error(`failed to get credentials ${err} - ${application.id}`);
|
|
18
|
+
}
|
|
10
19
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
{ test: true },
|
|
15
|
-
).then((result) => {
|
|
16
|
-
console.log(result);
|
|
17
|
-
})
|
|
20
|
+
return arr;
|
|
21
|
+
}, Promise.resolve([]));
|
|
22
|
+
})();
|