@veritree/services 2.11.0 → 2.12.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/services",
3
- "version": "2.11.0",
3
+ "version": "2.12.0",
4
4
  "description": "A collection of javascript functions/services to talk to veritree API",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -12,8 +12,8 @@ class ImagesApi extends Api {
12
12
  return this.update(url, data, 'patch');
13
13
  }
14
14
 
15
- relation(prefix, id) {
16
- return Relations(this, prefix, id);
15
+ relation(relationPrefix, relationId) {
16
+ return Relations(this, relationPrefix, relationId);
17
17
  }
18
18
  }
19
19
 
@@ -1,9 +1,14 @@
1
1
  import Api from '../helpers/api';
2
2
 
3
3
  class StandardsApi extends Api {
4
+ constructor(resource) {
5
+ super(resource);
6
+ this.resource = 'standards';
7
+ }
8
+
4
9
  themes() {
5
10
  const all = async () => {
6
- const url = `${this.getUrl()}standards/themes`;
11
+ const url = `${this.getUrl()}/themes`;
7
12
  return await this.get(url);
8
13
  };
9
14
 
@@ -14,7 +19,7 @@ class StandardsApi extends Api {
14
19
 
15
20
  goals() {
16
21
  const single = async (goalId) => {
17
- const url = `${this.getUrl()}standards/goals/${goalId}`;
22
+ const url = `${this.getUrl()}/goals/${goalId}`;
18
23
  return await this.get(url);
19
24
  };
20
25
 
@@ -28,7 +28,7 @@ class SubsitesApi extends Api {
28
28
  return await this.post(url, formData);
29
29
  };
30
30
 
31
- const deleteFromSubsite = async (subsite, indicator) => {
31
+ const remove = async (subsite, indicator) => {
32
32
  const url = `${this.getUrl()}/${subsite}/indicators/${indicator}`;
33
33
  return await this.post(url, null, 'delete');
34
34
  };
@@ -36,9 +36,9 @@ class SubsitesApi extends Api {
36
36
  return {
37
37
  all,
38
38
  create,
39
- deleteFromSubsite,
39
+ delete: remove,
40
40
  };
41
41
  }
42
42
  }
43
43
 
44
- export const Subsites = new SubsitesApi();
44
+ export const Subsites = new SubsitesApi();
@@ -1,23 +1,23 @@
1
- const Relations = (api, prefix, id) => {
2
- let url = `${api.baseUrl}/${prefix}/${id}/${api.resource}`;
1
+ const Relations = (api, relationPrefix, relationId) => {
2
+ let url = `${api.baseUrl}/${relationPrefix}/${relationId}/${api.resource}`;
3
3
 
4
4
  const all = async (args) => {
5
5
  url = `${url}${api.getUrlParams(args)}`;
6
6
  return await api.get(url);
7
7
  };
8
8
 
9
- const single = async (tagId, args) => {
10
- url = `${url}/${tagId}${api.getUrlParams(args)}`;
9
+ const single = async (id, args) => {
10
+ url = `${url}/${id}${api.getUrlParams(args)}`;
11
11
  return await api.get(url);
12
12
  };
13
13
 
14
- const attach = async (tagId, data, args) => {
15
- url = `${url}/${tagId}/attach${api.getUrlParams(args)}`;
14
+ const attach = async (id, data, args) => {
15
+ url = `${url}/${id}/attach${api.getUrlParams(args)}`;
16
16
  return await api.post(url, data);
17
17
  };
18
18
 
19
- const detach = async (tagId, args) => {
20
- url = `${url}/${tagId}/detach${api.getUrlParams(args)}`;
19
+ const detach = async (id, args) => {
20
+ url = `${url}/${id}/detach${api.getUrlParams(args)}`;
21
21
  return await api.post(url, null, "delete");
22
22
  };
23
23