@veritree/services 2.34.0 → 2.35.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 +83 -83
- package/package.json +16 -16
- package/src/endpoints/bulk-uploads.js +4 -4
- package/src/endpoints/countries.js +5 -5
- package/src/endpoints/crumbs.js +20 -20
- package/src/endpoints/evidence.js +47 -47
- package/src/endpoints/external-reports.js +9 -9
- package/src/endpoints/field-reports.js +37 -37
- package/src/endpoints/field-udpate-verifications.js +5 -5
- package/src/endpoints/field-updates.js +16 -16
- package/src/endpoints/forest-type-species.js +4 -4
- package/src/endpoints/forest-types-profiles.js +4 -4
- package/src/endpoints/forest-types.js +14 -14
- package/src/endpoints/form-submissions.js +4 -4
- package/src/endpoints/geometries.js +4 -4
- package/src/endpoints/images-aggregated.js +4 -4
- package/src/endpoints/images.js +21 -21
- package/src/endpoints/methodologies.js +36 -36
- package/src/endpoints/notes.js +14 -14
- package/src/endpoints/organizations.js +59 -59
- package/src/endpoints/orgs.js +65 -65
- package/src/endpoints/password.js +58 -58
- package/src/endpoints/planting-sites.js +121 -110
- package/src/endpoints/regions.js +41 -41
- package/src/endpoints/resellers.js +37 -37
- package/src/endpoints/roles.js +4 -4
- package/src/endpoints/sdgs.js +4 -4
- package/src/endpoints/sponsors.js +86 -86
- package/src/endpoints/sso-token.js +5 -5
- package/src/endpoints/standards.js +140 -140
- package/src/endpoints/stats.js +17 -17
- package/src/endpoints/subdomains.js +4 -4
- package/src/endpoints/subsite-types.js +5 -5
- package/src/endpoints/subsites.js +88 -88
- package/src/endpoints/tags.js +14 -14
- package/src/endpoints/tasks.js +47 -47
- package/src/endpoints/tree-order-statuses.js +4 -4
- package/src/endpoints/trees-orders.js +23 -23
- package/src/endpoints/user.js +27 -27
- package/src/endpoints/users.js +14 -14
- package/src/endpoints/utilities.js +35 -35
- package/src/endpoints/verifications.js +21 -21
- package/src/helpers/api.js +293 -293
- package/src/helpers/cookies.js +36 -36
- package/src/helpers/relations.js +32 -32
- package/src/helpers/sequestrations.js +19 -19
- package/src/helpers/session.js +3 -3
- package/src/helpers/team.js +45 -45
- package/src/utils/args.js +46 -46
package/src/helpers/relations.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
const Relations = (api, relationPrefix, relationId) => {
|
|
2
|
-
let url = `${api.baseUrl}/${relationPrefix}/${relationId}/${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 (id, args) => {
|
|
10
|
-
url = `${url}/${id}${api.getUrlParams(args)}`;
|
|
11
|
-
return await api.get(url);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const attach = async (id, data, args) => {
|
|
15
|
-
url = `${url}/${id}/attach${api.getUrlParams(args)}`;
|
|
16
|
-
return await api.post(url, data);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const detach = async (id, args) => {
|
|
20
|
-
url = `${url}/${id}/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;
|
|
1
|
+
const Relations = (api, relationPrefix, relationId) => {
|
|
2
|
+
let url = `${api.baseUrl}/${relationPrefix}/${relationId}/${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 (id, args) => {
|
|
10
|
+
url = `${url}/${id}${api.getUrlParams(args)}`;
|
|
11
|
+
return await api.get(url);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const attach = async (id, data, args) => {
|
|
15
|
+
url = `${url}/${id}/attach${api.getUrlParams(args)}`;
|
|
16
|
+
return await api.post(url, data);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const detach = async (id, args) => {
|
|
20
|
+
url = `${url}/${id}/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;
|
|
@@ -1,20 +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
|
-
|
|
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
20
|
export default Sequestrations;
|
package/src/helpers/session.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const getSession = () => {
|
|
2
|
-
return JSON.parse(localStorage.getItem('session'));
|
|
3
|
-
};
|
|
1
|
+
export const getSession = () => {
|
|
2
|
+
return JSON.parse(localStorage.getItem('session'));
|
|
3
|
+
};
|
package/src/helpers/team.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates an abstract team object that can be used
|
|
3
|
-
* for CRUD operations related to an org users.
|
|
4
|
-
*
|
|
5
|
-
* @param {object} api
|
|
6
|
-
* @param {number} id
|
|
7
|
-
* @returns {object}
|
|
8
|
-
*/
|
|
9
|
-
const Team = (api, id) => {
|
|
10
|
-
let url = `${api.baseUrl}/${api.resource}/${id}/users`;
|
|
11
|
-
|
|
12
|
-
const all = async (params) => {
|
|
13
|
-
url = `${url}${api.getUrlParams(params)}`;
|
|
14
|
-
return await api.get(url);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const single = async (userId, params) => {
|
|
18
|
-
url = `${url}/${userId}${api.getUrlParams(params)}`;
|
|
19
|
-
return await api.get(url);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const create = async (data, params) => {
|
|
23
|
-
url = `${url}${api.getUrlParams(params)}`;
|
|
24
|
-
return await api.post(url, data);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const update = async (userId, data, params) => {
|
|
28
|
-
url = `${url}/${userId}${api.getUrlParams(params)}`;
|
|
29
|
-
return await api.post(url, data, 'patch');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const remove = async (userId, params) => {
|
|
33
|
-
url = `${url}/${userId}${api.getUrlParams(params)}`;
|
|
34
|
-
return await api.post(url, null, "delete");
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
all,
|
|
39
|
-
single,
|
|
40
|
-
create,
|
|
41
|
-
update,
|
|
42
|
-
delete: remove
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Creates an abstract team object that can be used
|
|
3
|
+
* for CRUD operations related to an org users.
|
|
4
|
+
*
|
|
5
|
+
* @param {object} api
|
|
6
|
+
* @param {number} id
|
|
7
|
+
* @returns {object}
|
|
8
|
+
*/
|
|
9
|
+
const Team = (api, id) => {
|
|
10
|
+
let url = `${api.baseUrl}/${api.resource}/${id}/users`;
|
|
11
|
+
|
|
12
|
+
const all = async (params) => {
|
|
13
|
+
url = `${url}${api.getUrlParams(params)}`;
|
|
14
|
+
return await api.get(url);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const single = async (userId, params) => {
|
|
18
|
+
url = `${url}/${userId}${api.getUrlParams(params)}`;
|
|
19
|
+
return await api.get(url);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const create = async (data, params) => {
|
|
23
|
+
url = `${url}${api.getUrlParams(params)}`;
|
|
24
|
+
return await api.post(url, data);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const update = async (userId, data, params) => {
|
|
28
|
+
url = `${url}/${userId}${api.getUrlParams(params)}`;
|
|
29
|
+
return await api.post(url, data, 'patch');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const remove = async (userId, params) => {
|
|
33
|
+
url = `${url}/${userId}${api.getUrlParams(params)}`;
|
|
34
|
+
return await api.post(url, null, "delete");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
all,
|
|
39
|
+
single,
|
|
40
|
+
create,
|
|
41
|
+
update,
|
|
42
|
+
delete: remove
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
46
|
export default Team;
|
package/src/utils/args.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
export const createParamsStringFromArgs = (args) => {
|
|
2
|
-
if (!args && typeof args !== "object" && !Array.isArray(args)) {
|
|
3
|
-
return "";
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
const paramsString = [];
|
|
7
|
-
let arr = [];
|
|
8
|
-
|
|
9
|
-
Object.entries(args).forEach(([key, value]) => {
|
|
10
|
-
if (value === null) return;
|
|
11
|
-
|
|
12
|
-
if (Array.isArray(value)) {
|
|
13
|
-
arr = value
|
|
14
|
-
.map((item, index) => {
|
|
15
|
-
const param = `${key}[]=${encodeURIComponent(item)}`;
|
|
16
|
-
return index === 0 ? `${param}` : `&${param}`;
|
|
17
|
-
})
|
|
18
|
-
.join("");
|
|
19
|
-
|
|
20
|
-
paramsString.push(arr);
|
|
21
|
-
} else {
|
|
22
|
-
if (value !== undefined) {
|
|
23
|
-
/**
|
|
24
|
-
* as args is an object, we can't pass same keys
|
|
25
|
-
* and sometimes the api might need the keys
|
|
26
|
-
* to be equal (e.g box=1&box=2...). As a
|
|
27
|
-
* solution, we have this -x- to allow
|
|
28
|
-
* same keys to be passed. The args
|
|
29
|
-
* would look like:
|
|
30
|
-
*
|
|
31
|
-
* {
|
|
32
|
-
* 'box-x-1': 1
|
|
33
|
-
* 'box-x-2': 2
|
|
34
|
-
* }
|
|
35
|
-
*
|
|
36
|
-
* and would be translated as expected:
|
|
37
|
-
*
|
|
38
|
-
* box=1&box=2
|
|
39
|
-
*/
|
|
40
|
-
paramsString.push(`${key.split('-x-')[0]}=${encodeURIComponent(value)}`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return paramsString.length ? `&${paramsString.join("&")}` : "";
|
|
46
|
-
};
|
|
1
|
+
export const createParamsStringFromArgs = (args) => {
|
|
2
|
+
if (!args && typeof args !== "object" && !Array.isArray(args)) {
|
|
3
|
+
return "";
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const paramsString = [];
|
|
7
|
+
let arr = [];
|
|
8
|
+
|
|
9
|
+
Object.entries(args).forEach(([key, value]) => {
|
|
10
|
+
if (value === null) return;
|
|
11
|
+
|
|
12
|
+
if (Array.isArray(value)) {
|
|
13
|
+
arr = value
|
|
14
|
+
.map((item, index) => {
|
|
15
|
+
const param = `${key}[]=${encodeURIComponent(item)}`;
|
|
16
|
+
return index === 0 ? `${param}` : `&${param}`;
|
|
17
|
+
})
|
|
18
|
+
.join("");
|
|
19
|
+
|
|
20
|
+
paramsString.push(arr);
|
|
21
|
+
} else {
|
|
22
|
+
if (value !== undefined) {
|
|
23
|
+
/**
|
|
24
|
+
* as args is an object, we can't pass same keys
|
|
25
|
+
* and sometimes the api might need the keys
|
|
26
|
+
* to be equal (e.g box=1&box=2...). As a
|
|
27
|
+
* solution, we have this -x- to allow
|
|
28
|
+
* same keys to be passed. The args
|
|
29
|
+
* would look like:
|
|
30
|
+
*
|
|
31
|
+
* {
|
|
32
|
+
* 'box-x-1': 1
|
|
33
|
+
* 'box-x-2': 2
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* and would be translated as expected:
|
|
37
|
+
*
|
|
38
|
+
* box=1&box=2
|
|
39
|
+
*/
|
|
40
|
+
paramsString.push(`${key.split('-x-')[0]}=${encodeURIComponent(value)}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return paramsString.length ? `&${paramsString.join("&")}` : "";
|
|
46
|
+
};
|