@veritree/services 1.0.0-9 → 1.2.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/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { BulkUploads } from './src/endpoints/bulk-uploads';
1
2
  import { Countries } from './src/endpoints/countries';
2
3
  import { FieldUpdates } from './src/endpoints/field-updates';
3
4
  import { FieldUpdateVerifications } from './src/endpoints/field-udpate-verifications';
@@ -15,10 +16,12 @@ import { Stats } from './src/endpoints/stats';
15
16
  import { Subdomains } from './src/endpoints/subdomains';
16
17
  import { Subsites } from './src/endpoints/subsites';
17
18
  import { SubsiteTypes } from './src/endpoints/subsite-types';
19
+ import { Tags } from './src/endpoints/tags';
18
20
  import { TreeOrders } from './src/endpoints/trees-orders';
19
21
  import { User } from './src/endpoints/user';
20
22
 
21
23
  export {
24
+ BulkUploads,
22
25
  Countries,
23
26
  FieldUpdates,
24
27
  FieldUpdateVerifications,
@@ -36,6 +39,7 @@ export {
36
39
  Subdomains,
37
40
  Subsites,
38
41
  SubsiteTypes,
42
+ Tags,
39
43
  TreeOrders,
40
44
  User
41
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/services",
3
- "version": "1.0.0-9",
3
+ "version": "1.2.0",
4
4
  "description": "A collection of javascript functions/services to talk to veritree API",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -0,0 +1,5 @@
1
+ import Api from "../helpers/api";
2
+
3
+ const resource = "bulk-uploads";
4
+
5
+ export const BulkUploads = new Api(resource);
@@ -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();
@@ -1,4 +1,5 @@
1
1
  import Api from "../helpers/api";
2
+ import Relations from "../helpers/relations";
2
3
 
3
4
  class NotesApi extends Api {
4
5
  constructor(resource) {
@@ -6,9 +7,8 @@ class NotesApi extends Api {
6
7
  this.resource = "notes";
7
8
  }
8
9
 
9
- async relation(prefix, id, args) {
10
- const url = `${this.baseUrl}/${prefix}/${id}/${this.resource}${this.getUrlParams(args)}`;
11
- return await this.unWrap(url);
10
+ relation(prefix, id, args) {
11
+ return Relations(this, prefix, id, args);
12
12
  }
13
13
  }
14
14
 
@@ -23,6 +23,17 @@ class SponsorsApi extends Api {
23
23
  const url = `${this.getUrl()}/${this.orgId}/profile`;
24
24
  return await this.get(url);
25
25
  }
26
+
27
+ async plantingStats(args) {
28
+ const url = `${this.getUrl()}/planting-stats${this.getUrlParams(args)}`;
29
+ return await this.get(url);
30
+ }
31
+
32
+ async totalPlantingStats(args) {
33
+ const url = `${this.getUrl()}/total-planting-stats${this.getUrlParams(args)}`;
34
+ return await this.get(url);
35
+ }
36
+
26
37
  }
27
38
 
28
39
  export const Sponsors = new SponsorsApi();
@@ -0,0 +1,15 @@
1
+ import Api from "../helpers/api";
2
+ import Relations from "../helpers/relations";
3
+
4
+ class TagsApi extends Api {
5
+ constructor(resource) {
6
+ super(resource);
7
+ this.resource = "tags";
8
+ }
9
+
10
+ relation(prefix, id) {
11
+ return Relations(this, prefix, id);
12
+ }
13
+ }
14
+
15
+ export const Tags = new TagsApi();
@@ -0,0 +1,32 @@
1
+ const Relations = (api, prefix, id) => {
2
+ let url = `${api.baseUrl}/${prefix}/${id}/${api.resource}`;
3
+
4
+ const all = async (args) => {
5
+ url = `${url}${api.getUrlParams(args)}`;
6
+ return await api.get(url);
7
+ };
8
+
9
+ const single = async (tagId, args) => {
10
+ url = `${url}/${tagId}${api.getUrlParams(args)}`;
11
+ return await api.get(url);
12
+ };
13
+
14
+ const attach = async (tagId, data, args) => {
15
+ url = `${url}/${tagId}/attach${api.getUrlParams(args)}`;
16
+ return await api.post(url, data);
17
+ };
18
+
19
+ const detach = async (tagId, args) => {
20
+ url = `${url}/${tagId}/detach${api.getUrlParams(args)}`;
21
+ return await api.post(url, null, "delete");
22
+ };
23
+
24
+ return {
25
+ all,
26
+ single,
27
+ attach,
28
+ detach,
29
+ };
30
+ };
31
+
32
+ export default Relations;
@@ -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;