@veritree/services 2.35.0 → 2.36.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.35.0",
3
+ "version": "2.36.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,5 +12,8 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "np": "^7.6.2"
15
+ },
16
+ "engines": {
17
+ "node": ">16.0.0 <=18.16.0"
15
18
  }
16
19
  }
@@ -54,6 +54,17 @@ class OrganizationsApi extends Api {
54
54
 
55
55
  return { all };
56
56
  }
57
+
58
+ plantingReport(orgId) {
59
+ const all = async (params) => {
60
+ const url = `${this.getUrl()}/${orgId}/planting-report${this.getUrlParams(
61
+ params
62
+ )}`;
63
+
64
+ return await this.get(url);
65
+ };
66
+ return {all}
67
+ }
57
68
  }
58
69
 
59
70
  export const Organizations = new OrganizationsApi();
@@ -277,6 +277,22 @@ export default class Api {
277
277
  return;
278
278
  }
279
279
 
280
+ const contentType = response.headers.get('content-type');
281
+
282
+ if (contentType.includes('json')) {
283
+ response.json().then((json) => {
284
+ response.ok ? resolve(json) : reject(json);
285
+ });
286
+ return;
287
+ }
288
+
289
+ if (contentType.includes('csv')) {
290
+ response.text().then((res) => {
291
+ response.ok ? resolve(res) : reject(res);
292
+ });
293
+ return;
294
+ }
295
+
280
296
  response.json().then((json) => {
281
297
  response.ok ? resolve(json) : reject(json);
282
298
  });