@veritree/services 2.13.0 → 2.13.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/index.js +3 -1
- package/package.json +1 -1
- package/src/endpoints/crumbs.js +21 -0
- package/src/helpers/api.js +2 -2
- package/src/utils/args.js +7 -5
package/index.js
CHANGED
|
@@ -24,6 +24,7 @@ import { Users } from './src/endpoints/users';
|
|
|
24
24
|
import { Roles } from './src/endpoints/roles';
|
|
25
25
|
import { FieldReports } from './src/endpoints/field-reports';
|
|
26
26
|
import { ExternalReports } from './src/endpoints/external-reports';
|
|
27
|
+
import { Crumbs } from './src/endpoints/crumbs';
|
|
27
28
|
|
|
28
29
|
export {
|
|
29
30
|
BulkUploads,
|
|
@@ -51,5 +52,6 @@ export {
|
|
|
51
52
|
Users,
|
|
52
53
|
Roles,
|
|
53
54
|
FieldReports,
|
|
54
|
-
ExternalReports
|
|
55
|
+
ExternalReports,
|
|
56
|
+
Crumbs
|
|
55
57
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
import Api from '../helpers/api';
|
|
3
|
+
|
|
4
|
+
class CrumbsApi extends Api {
|
|
5
|
+
constructor(resource) {
|
|
6
|
+
super(resource);
|
|
7
|
+
this.resource = 'crumbs';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
mapData(crumbId) {
|
|
11
|
+
const all = async() => {
|
|
12
|
+
const url = `${this.getUrl()}/${crumbId}/map-data`;
|
|
13
|
+
return await this.get(url);
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
all,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const Crumbs = new CrumbsApi();
|
package/src/helpers/api.js
CHANGED
|
@@ -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 =
|
|
163
|
-
let orgTypeParam =
|
|
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 !==
|
|
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
|
|
14
|
-
|
|
13
|
+
arr = value
|
|
14
|
+
.map((item, index) => {
|
|
15
|
+
const param = `${key}[]=${encodeURIComponent(item)}`;
|
|
15
16
|
return index === 0 ? `${param}` : `&${param}`;
|
|
16
|
-
})
|
|
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
|
});
|