@veritree/services 1.0.0-12 → 1.0.0-15

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": "1.0.0-12",
3
+ "version": "1.0.0-15",
4
4
  "description": "A collection of javascript functions/services to talk to veritree API",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,5 +1,15 @@
1
1
  import Api from "../helpers/api";
2
+ import Sequestrations from '../helpers/sequestrations';
2
3
 
3
- const resource = "forest-types";
4
+ class ForestTypesApi extends Api {
5
+ constructor(resource) {
6
+ super(resource);
7
+ this.resource = "forest-types";
8
+ }
4
9
 
5
- export const ForestTypes = new Api(resource);
10
+ sequestrations(id, args) {
11
+ return Sequestrations(this, id, args);
12
+ }
13
+ }
14
+
15
+ export const ForestTypes = new ForestTypesApi();
@@ -8,7 +8,7 @@ class NotesApi extends Api {
8
8
  }
9
9
 
10
10
  relation(prefix, id, args) {
11
- return new Relations(this, prefix, id, args);
11
+ return Relations(this, prefix, id, args);
12
12
  }
13
13
  }
14
14
 
@@ -8,7 +8,7 @@ class TagsApi extends Api {
8
8
  }
9
9
 
10
10
  relation(prefix, id, args) {
11
- return new Relations(this, prefix, id, args);
11
+ return Relations(this, prefix, id, args);
12
12
  }
13
13
  }
14
14
 
@@ -3,12 +3,12 @@ const Relations = (api, prefix, id, args) => {
3
3
 
4
4
  const all = async () => {
5
5
  url = `${url}${api.getUrlParams(args)}`;
6
- return await api.unWrap(url);
6
+ return await api.get(url);
7
7
  }
8
8
 
9
9
  const single = async(tagId) => {
10
10
  url = `${url}/${tagId}${api.getUrlParams(args)}`;
11
- return await api.unWrap(url);
11
+ return await api.get(url);
12
12
  }
13
13
 
14
14
  const attach = async(tagId, data) => {
@@ -0,0 +1,20 @@
1
+ const Sequestrations = (api, forestTypeId, args) => {
2
+ let url = `${api.baseUrl}/${api.resource}/${forestTypeId}/sequestrations`;
3
+
4
+ const all = async () => {
5
+ url = `${url}${api.getUrlParams(args)}`;
6
+ return await api.get(url);
7
+ }
8
+
9
+ const create = async(data) => {
10
+ url = `${url}${api.getUrlParams(args)}`;
11
+ return await api.post(url, data);
12
+ }
13
+
14
+ return {
15
+ all,
16
+ create
17
+ }
18
+ }
19
+
20
+ export default Sequestrations;