@vouchfor/sdk 1.1.3 → 1.1.5

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,8 +5,12 @@ class IntegrationService extends BaseIntegrationService {
5
5
  super(client, config, '');
6
6
  }
7
7
 
8
- list() {
9
- return this._request({ apiKey, path: 'applications' });
8
+ get applications() {
9
+ return {
10
+ list: () => {
11
+ return this._request({ path: 'applications' });
12
+ }
13
+ }
10
14
  }
11
15
 
12
16
  authenticate({ applicationId, entityId }) {
@@ -36,6 +36,39 @@ class VouchService extends BaseRestService {
36
36
  path: 'upload',
37
37
  });
38
38
  }
39
+
40
+ get clips() {
41
+ function getPath(id, ordinality) {
42
+ return ordinality
43
+ ? `${id}/questions/${ordinality}/clips`
44
+ : `${id}clips`;
45
+ }
46
+
47
+ return {
48
+ create: (clips, { id, ordinality }, apiKey) => {
49
+ const path = getPath(id, ordinality);
50
+ return this._request({
51
+ apiKey,
52
+ body: clips,
53
+ path
54
+ });
55
+ },
56
+
57
+ delete: (clips, { id, ordinality }, apiKey) => {
58
+ const path = getPath(id, ordinality);
59
+ return this._request({
60
+ apiKey,
61
+ body: clips,
62
+ path: `${path}/delete`
63
+ });
64
+ },
65
+
66
+ list: ({ id, ordinality }, apiKey) => {
67
+ const path = getPath(id, ordinality);
68
+ return this._request({ apiKey, path });
69
+ }
70
+ }
71
+ }
39
72
  }
40
73
 
41
74
  module.exports = VouchService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vouchfor/sdk",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "Vouch API SDK",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
package/test.js CHANGED
@@ -1,17 +1,22 @@
1
1
  const Vouch = require("./lib/vouch");
2
2
 
3
- const APPLICATION_ID = ''
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
- vouch.applications.storage.set(
12
- 'e4KEvpqs33',
13
- 'sdk-test',
14
- { test: true },
15
- ).then((result) => {
16
- console.log(result);
17
- })
20
+ return arr;
21
+ }, Promise.resolve([]));
22
+ })();