@veritree/services 0.9.1 → 0.10.2

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": "0.9.1",
3
+ "version": "0.10.2",
4
4
  "description": "A collection of javascript functions/services to talk to veritree API",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -5,6 +5,10 @@ export const createFieldUpdatesApiService = () => {
5
5
  const resource = `field-updates`;
6
6
  const { orgId, orgType } = getSession();
7
7
 
8
+ if (!orgId && !orgType) {
9
+ throw new Error('Organization id and type are required');
10
+ }
11
+
8
12
  const get = {
9
13
  async all(countryId, regionId, subsiteId, page = 1, orderBy = 'date_planted-desc', pageSize = 10) {
10
14
  const params = `${_getParams(
@@ -19,6 +23,12 @@ export const createFieldUpdatesApiService = () => {
19
23
 
20
24
  return await Api.get(url);
21
25
  },
26
+
27
+ async specific(id) {
28
+ const url = `${_getUrl()}/${id}?${_getParams()}`;
29
+
30
+ return await Api.get(url);
31
+ }
22
32
  };
23
33
 
24
34
  /**
@@ -33,6 +43,17 @@ export const createFieldUpdatesApiService = () => {
33
43
  return Api.post(url, data);
34
44
  };
35
45
 
46
+ /**
47
+ *
48
+ */
49
+ const remove = {
50
+ async img(fieldUpdateId, data) {
51
+ const url = `${_getUrl()}/${fieldUpdateId}/images/detach?${_getParams()}`;
52
+
53
+ return await Api.post(url, data);
54
+ }
55
+ }
56
+
36
57
  const _getUrl = () => {
37
58
  return `${Api.baseUrl}/${resource}`;
38
59
  };
@@ -52,5 +73,6 @@ export const createFieldUpdatesApiService = () => {
52
73
  return {
53
74
  get,
54
75
  update,
76
+ remove
55
77
  };
56
78
  };
@@ -1,8 +1,13 @@
1
1
  import Api from '../helpers/api';
2
+ import { getSession } from "../helpers/session";
2
3
 
3
- export const createForestTypesApiService = (orgId, orgType) => {
4
- if (!orgId || !orgType) throw new Error('orgId and orgType are required');
4
+ export const createForestTypesApiService = () => {
5
5
  const resource = 'forest-types';
6
+ const { orgId, orgType } = getSession();
7
+
8
+ if (!orgId && !orgType) {
9
+ throw new Error('Organization id and type are required');
10
+ }
6
11
 
7
12
  const get = {
8
13
  /**
@@ -1,8 +1,13 @@
1
1
  import Api from '../helpers/api';
2
+ import { getSession } from "../helpers/session";
2
3
 
3
- export const createRegionsApiService = (orgId, orgType) => {
4
- if (!orgId && !orgType) throw new Error('orgId and orgType are required');
4
+ export const createRegionsApiService = () => {
5
5
  const resource = 'regions';
6
+ const { orgId, orgType } = getSession();
7
+
8
+ if (!orgId && !orgType) {
9
+ throw new Error('Organization id and type are required');
10
+ }
6
11
 
7
12
  const get = {
8
13
  async all(page = 1, pageSize = 10) {
@@ -1,8 +1,13 @@
1
1
  import Api from '../helpers/api';
2
+ import { getSession } from "../helpers/session";
2
3
 
3
- export const createSubsitesApiService = (orgId, orgType) => {
4
- if (!orgId && !orgType) throw new Error('orgId is required');
4
+ export const createSubsitesApiService = () => {
5
5
  const resource = 'subsites';
6
+ const { orgId, orgType } = getSession();
7
+
8
+ if (!orgId && !orgType) {
9
+ throw new Error('Organization id and type are required');
10
+ }
6
11
 
7
12
  const get = {
8
13
  /**