@vouchfor/sdk 1.1.28 → 1.1.29
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.
- package/lib/services/index.js +3 -0
- package/lib/services/rest/accountService.js +21 -0
- package/lib/services/rest/campaignService.js +29 -6
- package/lib/services/rest/compositionService.js +52 -0
- package/lib/services/rest/entityService.js +0 -8
- package/lib/services/rest/fileService.js +4 -2
- package/lib/services/rest/playlistService.js +51 -0
- package/lib/services/rest/vouchService.js +20 -16
- package/package.json +1 -1
- package/test-accounts.js +16 -0
- package/test-upload.js +17 -0
package/lib/services/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
module.exports = Object.freeze({
|
|
2
|
+
accounts: require('./rest/accountService'),
|
|
2
3
|
answers: require('./rest/answerService'),
|
|
3
4
|
assets: require('./rest/assetService'),
|
|
4
5
|
applications: require('./rest/applicationService'),
|
|
@@ -6,6 +7,8 @@ module.exports = Object.freeze({
|
|
|
6
7
|
entities: require('./rest/entityService'),
|
|
7
8
|
integrations: require('./integration/integrationService'),
|
|
8
9
|
vouches: require('./rest/vouchService'),
|
|
10
|
+
playlists: require('./rest/playlistService'),
|
|
11
|
+
compositions: require('./rest/compositionService'),
|
|
9
12
|
files: require('./rest/fileService'),
|
|
10
13
|
advocacy: require('./rest/advocacyService'),
|
|
11
14
|
utilities: require('./rest/utilityService'),
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const BaseRestService = require('./base');
|
|
2
|
+
|
|
3
|
+
class CompositionService extends BaseRestService {
|
|
4
|
+
constructor(client, config, logger) {
|
|
5
|
+
super(client, config, 'accounts', logger);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
get(id, apiKey, opts = {}) {
|
|
9
|
+
return this._request({
|
|
10
|
+
apiKey,
|
|
11
|
+
path: `${id}`+ this._utils.queryString(opts)
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
list(apiKey) {
|
|
16
|
+
return this._request({ apiKey, path: '' });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = CompositionService;
|
|
21
|
+
|
|
@@ -5,24 +5,31 @@ class CampaignService extends BaseRestService {
|
|
|
5
5
|
super(client, config, 'campaigns', logger);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
create(
|
|
8
|
+
create(payload, apiKey) {
|
|
9
9
|
return this._request({
|
|
10
10
|
apiKey,
|
|
11
|
-
body:
|
|
11
|
+
body: payload,
|
|
12
12
|
path: '',
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
update(id,
|
|
16
|
+
update(id, payload, apiKey) {
|
|
17
17
|
return this._request({
|
|
18
18
|
apiKey,
|
|
19
|
-
body:
|
|
19
|
+
body: payload,
|
|
20
20
|
path: `${id}`
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
get(id, apiKey) {
|
|
25
|
-
return this._request({
|
|
24
|
+
get(id, apiKey, opts = {}) {
|
|
25
|
+
return this._request({
|
|
26
|
+
apiKey,
|
|
27
|
+
path: `${id}`+ this._utils.queryString(opts)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
delete(id, apiKey) {
|
|
32
|
+
return this._request({ apiKey, path: `${id}/delete` });
|
|
26
33
|
}
|
|
27
34
|
|
|
28
35
|
list(apiKey) {
|
|
@@ -36,6 +43,22 @@ class CampaignService extends BaseRestService {
|
|
|
36
43
|
});
|
|
37
44
|
}
|
|
38
45
|
|
|
46
|
+
counts(id, apiKey) {
|
|
47
|
+
return this._request({ apiKey, path: `${id}/counts` });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
status(id, apiKey) {
|
|
51
|
+
return this._request({ apiKey, path: `${id}/status` });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
publish(id, apiKey) {
|
|
55
|
+
return this._request({ apiKey, path: `${id}/publish` });
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
pause(id, apiKey) {
|
|
59
|
+
return this._request({ apiKey, path: `${id}/pause` });
|
|
60
|
+
}
|
|
61
|
+
|
|
39
62
|
vouches(id, apiKey, opts = {}) {
|
|
40
63
|
return this._request({
|
|
41
64
|
apiKey,
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const BaseRestService = require('./base');
|
|
2
|
+
|
|
3
|
+
class CompositionService extends BaseRestService {
|
|
4
|
+
constructor(client, config, logger) {
|
|
5
|
+
super(client, config, 'compositions', logger);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
create(payload, apiKey) {
|
|
9
|
+
return this._request({
|
|
10
|
+
apiKey,
|
|
11
|
+
body: payload,
|
|
12
|
+
path: '',
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
update(id, payload, apiKey) {
|
|
17
|
+
return this._request({
|
|
18
|
+
apiKey,
|
|
19
|
+
body: payload,
|
|
20
|
+
path: `${id}`
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get(id, apiKey, opts = {}) {
|
|
25
|
+
return this._request({
|
|
26
|
+
apiKey,
|
|
27
|
+
path: `${id}`+ this._utils.queryString(opts)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
delete(id, apiKey) {
|
|
32
|
+
return this._request({ apiKey, path: `${id}/delete` });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
list(apiKey) {
|
|
36
|
+
return this._request({ apiKey, path: '' });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
search(params = {}, apiKey) {
|
|
40
|
+
return this._request({
|
|
41
|
+
apiKey,
|
|
42
|
+
path: 'search' + this._utils.queryString(params)
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
counts(id, apiKey) {
|
|
47
|
+
return this._request({ apiKey, path: `${id}/counts` });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = CompositionService;
|
|
52
|
+
|
|
@@ -48,14 +48,6 @@ class EntityService extends BaseRestService {
|
|
|
48
48
|
path: `${id}/quotes`
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
video(id, params, apiKey) {
|
|
53
|
-
return this._request({
|
|
54
|
-
apiKey,
|
|
55
|
-
body: params,
|
|
56
|
-
path: `${id}/video`
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
51
|
}
|
|
60
52
|
|
|
61
53
|
module.exports = EntityService;
|
|
@@ -13,12 +13,13 @@ class FileService extends BaseRestService {
|
|
|
13
13
|
return this._request({ apiKey, path: `${id}` });
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
upload(file, key, apiKey, { extract } = {}) {
|
|
16
|
+
upload(file, key, apiKey, { extract, extname } = {}) {
|
|
17
17
|
const input = fs.createReadStream(file);
|
|
18
18
|
const form = new FormData();
|
|
19
19
|
form.append('title', key);
|
|
20
20
|
form.append('file', input);
|
|
21
21
|
form.append('extract', !!extract);
|
|
22
|
+
form.append('extname', !!extname);
|
|
22
23
|
return this._request({
|
|
23
24
|
apiKey,
|
|
24
25
|
body: form,
|
|
@@ -54,12 +55,13 @@ class FileService extends BaseRestService {
|
|
|
54
55
|
}
|
|
55
56
|
///////////////////////////////////////////*/
|
|
56
57
|
|
|
57
|
-
proxy(url, key, apiKey, { extract, headers } = {}) {
|
|
58
|
+
proxy(url, key, apiKey, { extract, extname, headers } = {}) {
|
|
58
59
|
return this._request({
|
|
59
60
|
apiKey,
|
|
60
61
|
body: {
|
|
61
62
|
url,
|
|
62
63
|
extract,
|
|
64
|
+
extname,
|
|
63
65
|
headers
|
|
64
66
|
},
|
|
65
67
|
path: key
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const BaseRestService = require('./base');
|
|
2
|
+
|
|
3
|
+
class PlaylistService extends BaseRestService {
|
|
4
|
+
constructor(client, config, logger) {
|
|
5
|
+
super(client, config, 'playlists', logger);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
create(payload, apiKey) {
|
|
9
|
+
return this._request({
|
|
10
|
+
apiKey,
|
|
11
|
+
body: payload,
|
|
12
|
+
path: '',
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
update(id, payload, apiKey) {
|
|
17
|
+
return this._request({
|
|
18
|
+
apiKey,
|
|
19
|
+
body: payload,
|
|
20
|
+
path: `${id}`
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get(id, apiKey, opts = {}) {
|
|
25
|
+
return this._request({
|
|
26
|
+
apiKey,
|
|
27
|
+
path: `${id}`+ this._utils.queryString(opts)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
delete(id, apiKey) {
|
|
32
|
+
return this._request({ apiKey, path: `${id}/delete` });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
list(apiKey) {
|
|
36
|
+
return this._request({ apiKey, path: '' });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
search(params = {}, apiKey) {
|
|
40
|
+
return this._request({
|
|
41
|
+
apiKey,
|
|
42
|
+
path: 'search' + this._utils.queryString(params)
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
counts(id, apiKey) {
|
|
47
|
+
return this._request({ apiKey, path: `${id}/counts` });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = PlaylistService;
|
|
@@ -5,18 +5,18 @@ class VouchService extends BaseRestService {
|
|
|
5
5
|
super(client, config, 'vouches', logger);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
create(
|
|
8
|
+
create(payload, apiKey) {
|
|
9
9
|
return this._request({
|
|
10
10
|
apiKey,
|
|
11
|
-
body:
|
|
11
|
+
body: payload,
|
|
12
12
|
path: '',
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
update(id,
|
|
16
|
+
update(id, payload, apiKey) {
|
|
17
17
|
return this._request({
|
|
18
18
|
apiKey,
|
|
19
|
-
body:
|
|
19
|
+
body: payload,
|
|
20
20
|
path: `${id}`
|
|
21
21
|
});
|
|
22
22
|
}
|
|
@@ -28,12 +28,8 @@ class VouchService extends BaseRestService {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
return this._request({ apiKey, path: `${id}/
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
status(id, apiKey) {
|
|
36
|
-
return this._request({ apiKey, path: `${id}/status` });
|
|
31
|
+
delete(id, apiKey) {
|
|
32
|
+
return this._request({ apiKey, path: `${id}/delete` });
|
|
37
33
|
}
|
|
38
34
|
|
|
39
35
|
list(apiKey) {
|
|
@@ -47,10 +43,18 @@ class VouchService extends BaseRestService {
|
|
|
47
43
|
});
|
|
48
44
|
}
|
|
49
45
|
|
|
50
|
-
|
|
46
|
+
counts(id, apiKey) {
|
|
47
|
+
return this._request({ apiKey, path: `${id}/counts` });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
status(id, apiKey) {
|
|
51
|
+
return this._request({ apiKey, path: `${id}/status` });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
upload(payload, apiKey) {
|
|
51
55
|
return this._request({
|
|
52
56
|
apiKey,
|
|
53
|
-
body:
|
|
57
|
+
body: payload,
|
|
54
58
|
path: 'upload',
|
|
55
59
|
});
|
|
56
60
|
}
|
|
@@ -63,20 +67,20 @@ class VouchService extends BaseRestService {
|
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
return {
|
|
66
|
-
create: (
|
|
70
|
+
create: (payload, { id, ordinality }, apiKey) => {
|
|
67
71
|
const path = getPath(id, ordinality);
|
|
68
72
|
return this._request({
|
|
69
73
|
apiKey,
|
|
70
|
-
body:
|
|
74
|
+
body: payload,
|
|
71
75
|
path
|
|
72
76
|
});
|
|
73
77
|
},
|
|
74
78
|
|
|
75
|
-
delete: (
|
|
79
|
+
delete: (payload, { id, ordinality }, apiKey) => {
|
|
76
80
|
const path = getPath(id, ordinality);
|
|
77
81
|
return this._request({
|
|
78
82
|
apiKey,
|
|
79
|
-
body:
|
|
83
|
+
body: payload,
|
|
80
84
|
path: `${path}/delete`
|
|
81
85
|
});
|
|
82
86
|
},
|
package/package.json
CHANGED
package/test-accounts.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const Vouch = require("./lib/vouch");
|
|
2
|
+
|
|
3
|
+
const vouchClient = new Vouch({
|
|
4
|
+
env: 'dev',
|
|
5
|
+
integrationKey: 'b0883f06-84af-4108-8543-31874c335c36-kkr3Wy4CLY8C2g65UT79sgUfOIR2ZzkA9uQam3bTs4ZNdlSs7M',
|
|
6
|
+
}, console);
|
|
7
|
+
|
|
8
|
+
const apiKey = 'kTYGShoaeg-QvraTZk9LmHNsxP4dWcye82uJB6Rf0XtIsgq7UaEcYpVhMDl3z';
|
|
9
|
+
const id = 'WncEfS4KgY';
|
|
10
|
+
|
|
11
|
+
(async () => {
|
|
12
|
+
const accounts = await vouchClient.accounts.list(apiKey).catch(() => undefined);
|
|
13
|
+
console.log(accounts);
|
|
14
|
+
const account = await vouchClient.accounts.get(id, apiKey).catch(() => undefined);
|
|
15
|
+
console.log(account);
|
|
16
|
+
})();
|
package/test-upload.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const Vouch = require("./lib/vouch");
|
|
2
|
+
|
|
3
|
+
const vouchClient = new Vouch({
|
|
4
|
+
env: 'dev',
|
|
5
|
+
integrationKey: 'b0883f06-84af-4108-8543-31874c335c36-kkr3Wy4CLY8C2g65UT79sgUfOIR2ZzkA9uQam3bTs4ZNdlSs7M',
|
|
6
|
+
}, console);
|
|
7
|
+
|
|
8
|
+
const apiKey = 'kTYGShoaeg-QvraTZk9LmHNsxP4dWcye82uJB6Rf0XtIsgq7UaEcYpVhMDl3z';
|
|
9
|
+
const url = 'https://examplefiles.org/files/video/mp4-example-video-download-640x480.mp4'
|
|
10
|
+
const key1 = 'delete/file_example_MP4_480_1_5MG.mp4';
|
|
11
|
+
const key2 = 'delete/file_example_MP4_480_1_EXT';
|
|
12
|
+
|
|
13
|
+
(async () => {
|
|
14
|
+
const result = await vouchClient.files.proxy(url, key1, apiKey, { extract: true, extname: true }).catch(() => undefined);
|
|
15
|
+
console.log(result);
|
|
16
|
+
})();
|
|
17
|
+
|