@veritree/services 2.42.0 → 2.44.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
@@ -7,6 +7,7 @@ import { ForestTypeSpecies } from './src/endpoints/forest-type-species';
7
7
  import { ForestTypes } from './src/endpoints/forest-types';
8
8
  import { ForestTypeProfiles } from './src/endpoints/forest-types-profiles';
9
9
  import { Images } from './src/endpoints/images';
10
+ import { Initiatives } from './src/endpoints/initiatives';
10
11
  import { Methodologies } from './src/endpoints/methodologies';
11
12
  import { Notes } from './src/endpoints/notes';
12
13
  import { Orgs } from './src/endpoints/orgs';
@@ -48,8 +49,9 @@ export {
48
49
  ForestTypes,
49
50
  ForestTypeProfiles,
50
51
  FormSubmissions,
51
- Methodologies,
52
52
  Images,
53
+ Initiatives,
54
+ Methodologies,
53
55
  Notes,
54
56
  Orgs,
55
57
  Regions,
@@ -79,5 +81,5 @@ export {
79
81
  Organizations,
80
82
  Tasks,
81
83
  Geometries,
82
- Password
84
+ Password,
83
85
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/services",
3
- "version": "2.42.0",
3
+ "version": "2.44.0",
4
4
  "description": "A collection of javascript functions/services to talk to veritree API",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,17 +1,19 @@
1
- import Api from "../helpers/api";
1
+ import Api from '../helpers/api';
2
2
 
3
3
  class FieldReportsApi extends Api {
4
4
  constructor(resource) {
5
5
  super(resource);
6
- this.resource = "field-reports";
6
+ this.resource = 'field-reports';
7
7
  }
8
8
 
9
9
  evidence(fieldReportId, params) {
10
- const url = `${this.getUrl()}/${fieldReportId}/evidence${this.getUrlParams(params)}`;
10
+ const url = `${this.getUrl()}/${fieldReportId}/evidence${this.getUrlParams(
11
+ params
12
+ )}`;
11
13
 
12
14
  const all = async () => {
13
15
  return await this.get(url);
14
- }
16
+ };
15
17
 
16
18
  const attach = async (formData) => {
17
19
  return await this.post(url, formData);
@@ -19,20 +21,54 @@ class FieldReportsApi extends Api {
19
21
 
20
22
  const detach = async (evidenceId, fileType = 'images') => {
21
23
  const url = `${this.getUrl()}/${fieldReportId}/evidence/${fileType}/${evidenceId}${this.getUrlParams()}`;
22
- return await this.post(url, null, "delete");
24
+ return await this.post(url, null, 'delete');
23
25
  };
24
26
 
25
27
  return {
26
28
  all,
27
29
  attach,
28
- detach
29
- }
30
+ detach,
31
+ };
30
32
  }
31
33
 
32
34
  blockchain(fieldReportId, params) {
33
35
  const url = `${this.getUrl()}/${fieldReportId}${this.getUrlParams(params)}`;
34
- return this.get(url)
36
+ return this.get(url);
37
+ }
38
+
39
+ initiatives(fieldReportId, params) {
40
+ const all = async () => {
41
+ const url = `${this.getUrl()}/${fieldReportId}/initiatives${this.getUrlParams(
42
+ params
43
+ )}`;
44
+ return await this.get(url);
45
+ };
46
+
47
+ return { all };
48
+ }
49
+
50
+ attachInitiatives(fieldReportId, formData, params) {
51
+ const url = `${this.getUrl()}/${fieldReportId}/attach-initiatives${this.getUrlParams(
52
+ params
53
+ )}`;
54
+ return this.post(url, formData, null, params);
55
+ }
56
+
57
+ detachInitiatives(fieldReportId, formData, params) {
58
+ const url = `${this.getUrl()}/${fieldReportId}/detach-initiatives${this.getUrlParams(
59
+ params
60
+ )}`;
61
+ return this.post(url, formData, null, params);
62
+ }
63
+
64
+ phases() {
65
+ const all = async () => {
66
+ const url = `${this.getUrl()}/phases`;
67
+ return await this.get(url);
68
+ };
69
+
70
+ return { all };
35
71
  }
36
72
  }
37
73
 
38
- export const FieldReports = new FieldReportsApi();
74
+ export const FieldReports = new FieldReportsApi();
@@ -0,0 +1,10 @@
1
+ import Api from '../helpers/api';
2
+
3
+ class InitiativesApi extends Api {
4
+ constructor(resource) {
5
+ super(resource);
6
+ this.resource = 'initiatives';
7
+ }
8
+ }
9
+
10
+ export const Initiatives = new InitiativesApi();
@@ -1,16 +1,16 @@
1
- import Api from "../helpers/api";
1
+ import Api from '../helpers/api';
2
2
 
3
3
  class SponsorsApi extends Api {
4
4
  constructor(resource) {
5
5
  super(resource);
6
- this.resource = "sponsors";
6
+ this.resource = 'sponsors';
7
7
  }
8
8
 
9
9
  async map() {
10
10
  this.setOrg();
11
11
 
12
12
  if (!this.orgId) {
13
- throw new Error("No org id provided");
13
+ throw new Error('No org id provided');
14
14
  }
15
15
 
16
16
  const url = `${this.getUrl()}/${this.orgId}/map-data`;
@@ -21,7 +21,7 @@ class SponsorsApi extends Api {
21
21
  this.setOrg();
22
22
 
23
23
  if (!this.orgId) {
24
- throw new Error("No org id provided");
24
+ throw new Error('No org id provided');
25
25
  }
26
26
 
27
27
  const url = `${this.getUrl()}/${this.orgId}/profile`;
@@ -105,21 +105,34 @@ class SponsorsApi extends Api {
105
105
 
106
106
  const stats = () => {
107
107
  const all = async () => {
108
- const url = `${this.getUrl()}/${this.orgId}/regions/${regionId}/stats${this.getUrlParams(
109
- args
110
- )}`;
111
-
108
+ const url = `${this.getUrl()}/${
109
+ this.orgId
110
+ }/regions/${regionId}/stats${this.getUrlParams(args)}`;
111
+
112
112
  return await this.get(url);
113
- }
113
+ };
114
114
 
115
115
  return {
116
- all
117
- }
118
- }
116
+ all,
117
+ };
118
+ };
119
119
 
120
120
  return {
121
- stats
122
- }
121
+ stats,
122
+ };
123
+ }
124
+
125
+ metrics(sponsorId) {
126
+ const all = async (args) => {
127
+ const url = `${this.getUrl()}/${sponsorId}/metrics${this.getUrlParams(
128
+ args
129
+ )}`;
130
+ return await this.get(url);
131
+ };
132
+
133
+ return {
134
+ all,
135
+ };
123
136
  }
124
137
  }
125
138