@veritree/services 2.12.0 → 2.13.1

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.12.0",
3
+ "version": "2.13.1",
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,23 @@ class FieldReportsApi extends Api {
5
5
  super(resource);
6
6
  this.resource = "field-reports";
7
7
  }
8
+
9
+ evidence(fieldReportId) {
10
+ const url = `${this.getUrl()}/${fieldReportId}/evidence${this.getUrlParams()}`;
11
+
12
+ const all = async () => {
13
+ return await this.get(url);
14
+ }
15
+
16
+ const attach = async (formData) => {
17
+ return await this.post(url, formData);
18
+ };
19
+
20
+ return {
21
+ all,
22
+ attach
23
+ }
24
+ }
8
25
  }
9
26
 
10
27
  export const FieldReports = new FieldReportsApi();
@@ -159,8 +159,8 @@ export default class Api {
159
159
  this.setOrg();
160
160
  let isOrgLess = false;
161
161
  let isOrgAs = false;
162
- let orgIdParam = null;
163
- let orgTypeParam = null;
162
+ let orgIdParam = '';
163
+ let orgTypeParam = '';
164
164
 
165
165
  // while most of endpoints require an org id and type, some endpoints do not
166
166
  if (args) {
package/src/utils/args.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export const createParamsStringFromArgs = (args) => {
2
- if (!args && typeof args !== 'object' && !Array.isArray(args)) {
2
+ if (!args && typeof args !== "object" && !Array.isArray(args)) {
3
3
  return "";
4
4
  }
5
5
 
@@ -10,15 +10,17 @@ export const createParamsStringFromArgs = (args) => {
10
10
  if (value === null) return;
11
11
 
12
12
  if (Array.isArray(value)) {
13
- arr = value.map((item, index) => {
14
- const param = `${key}[]=${item}`;
13
+ arr = value
14
+ .map((item, index) => {
15
+ const param = `${key}[]=${encodeURIComponent(item)}`;
15
16
  return index === 0 ? `${param}` : `&${param}`;
16
- }).join("");
17
+ })
18
+ .join("");
17
19
 
18
20
  paramsString.push(arr);
19
21
  } else {
20
22
  if (value !== undefined) {
21
- paramsString.push(`${key}=${value}`);
23
+ paramsString.push(`${key}=${encodeURIComponent(value)}`);
22
24
  }
23
25
  }
24
26
  });