@vouchfor/sdk 1.1.30 → 1.1.32

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.
@@ -10,6 +10,9 @@ module.exports = Object.freeze({
10
10
  playlists: require('./rest/playlistService'),
11
11
  compositions: require('./rest/compositionService'),
12
12
  files: require('./rest/fileService'),
13
+ images: require('./rest/imageService'),
14
+ documents: require('./rest/documentService'),
15
+ links: require('./rest/linkService'),
13
16
  advocacy: require('./rest/advocacyService'),
14
17
  utilities: require('./rest/utilityService'),
15
18
  });
@@ -0,0 +1,35 @@
1
+ const BaseRestService = require('./base');
2
+
3
+ class DocumentService extends BaseRestService {
4
+ constructor(client, config, logger) {
5
+ super(client, config, 'documents', 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
+ delete(id, apiKey) {
16
+ return this._request({ apiKey, path: `${id}/delete` });
17
+ }
18
+
19
+ search(params = {}, apiKey) {
20
+ return this._request({
21
+ apiKey,
22
+ path: 'search' + this._utils.queryString(params)
23
+ });
24
+ }
25
+
26
+ upload(payload, apiKey) {
27
+ return this._request({
28
+ apiKey,
29
+ body: payload,
30
+ path: 'upload',
31
+ });
32
+ }
33
+ }
34
+
35
+ module.exports = DocumentService;
@@ -9,8 +9,22 @@ class FileService extends BaseRestService {
9
9
  super(client, config, 'files', logger);
10
10
  }
11
11
 
12
- get(id, apiKey) {
13
- return this._request({ apiKey, path: `${id}` });
12
+ get(id, apiKey, opts = {}) {
13
+ return this._request({
14
+ apiKey,
15
+ path: `${id}`+ this._utils.queryString(opts)
16
+ });
17
+ }
18
+
19
+ delete(id, apiKey) {
20
+ return this._request({ apiKey, path: `${id}/delete` });
21
+ }
22
+
23
+ search(params = {}, apiKey) {
24
+ return this._request({
25
+ apiKey,
26
+ path: 'search' + this._utils.queryString(params)
27
+ });
14
28
  }
15
29
 
16
30
  upload(file, key, apiKey, { extract, extname } = {}) {
@@ -0,0 +1,36 @@
1
+ const BaseRestService = require('./base');
2
+
3
+ class ImageService extends BaseRestService {
4
+ constructor(client, config, logger) {
5
+ super(client, config, 'images', 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
+ delete(id, apiKey) {
16
+ return this._request({ apiKey, path: `${id}/delete` });
17
+ }
18
+
19
+ search(params = {}, apiKey) {
20
+ return this._request({
21
+ apiKey,
22
+ path: 'search' + this._utils.queryString(params)
23
+ });
24
+ }
25
+
26
+ upload(payload, apiKey) {
27
+ return this._request({
28
+ apiKey,
29
+ body: payload,
30
+ path: 'upload',
31
+ });
32
+ }
33
+ }
34
+
35
+ module.exports = ImageService;
36
+
@@ -0,0 +1,35 @@
1
+ const BaseRestService = require('./base');
2
+
3
+ class LinkService extends BaseRestService {
4
+ constructor(client, config, logger) {
5
+ super(client, config, 'links', 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
+ delete(id, apiKey) {
16
+ return this._request({ apiKey, path: `${id}/delete` });
17
+ }
18
+
19
+ search(params = {}, apiKey) {
20
+ return this._request({
21
+ apiKey,
22
+ path: 'search' + this._utils.queryString(params)
23
+ });
24
+ }
25
+
26
+ import(payload, apiKey) {
27
+ return this._request({
28
+ apiKey,
29
+ body: payload,
30
+ path: 'import',
31
+ });
32
+ }
33
+ }
34
+
35
+ module.exports = LinkService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vouchfor/sdk",
3
- "version": "1.1.30",
3
+ "version": "1.1.32",
4
4
  "description": "Vouch API SDK",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -8,7 +8,8 @@ const vouchClient = new Vouch({
8
8
  const apiKey = 'kTYGShoaeg-QvraTZk9LmHNsxP4dWcye82uJB6Rf0XtIsgq7UaEcYpVhMDl3z';
9
9
 
10
10
  (async () => {
11
- const data = await vouchClient.compositions.get('fMMsKxK9Ic', apiKey).catch(() => undefined);
12
- console.log(data);
11
+ const data = await vouchClient.compositions.get('fMMsKxK9Ic', apiKey)
12
+ .then((data) => console.log('data', data))
13
+ .catch((err) => console.log('error', err));
13
14
  })();
14
15
 
package/test-images.js ADDED
@@ -0,0 +1,41 @@
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
+
10
+ (async () => {
11
+ {
12
+ const params = {
13
+ query: 'why',
14
+ limit: 2
15
+ };
16
+ const data = await vouchClient.images.search(params, apiKey).catch(() => undefined);
17
+ console.log(data);
18
+ }
19
+ {
20
+ const params = {
21
+ account: {
22
+ email: 'david@vouchfor.com'
23
+ },
24
+ image: {
25
+ name: 'Image from Url',
26
+ externalid: '777888999000',
27
+ url: 'https://googlechrome.github.io/samples/picture-element/images/butterfly.webp',
28
+ sourceUrl: 'https://googlechrome.github.io/samples/picture-element/images/butterfly.webp',
29
+ source: 'TEST'
30
+ }
31
+ };
32
+ const data = await vouchClient.images.upload(params, apiKey).catch(() => undefined);
33
+ console.log(data);
34
+ }
35
+ {
36
+ const id = '777888999000';
37
+ const data = await vouchClient.images.get(id, apiKey).catch(() => undefined);
38
+ console.log(data);
39
+ }
40
+ })();
41
+