@veritree/services 1.5.0-1 → 1.5.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 CHANGED
@@ -19,6 +19,7 @@ import { SubsiteTypes } from './src/endpoints/subsite-types';
19
19
  import { Tags } from './src/endpoints/tags';
20
20
  import { TreeOrders } from './src/endpoints/trees-orders';
21
21
  import { User } from './src/endpoints/user';
22
+ import { Users } from './src/endpoints/users';
22
23
 
23
24
  export {
24
25
  BulkUploads,
@@ -41,5 +42,6 @@ export {
41
42
  SubsiteTypes,
42
43
  Tags,
43
44
  TreeOrders,
44
- User
45
+ User,
46
+ Users
45
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/services",
3
- "version": "1.5.0-1",
3
+ "version": "1.5.0",
4
4
  "description": "A collection of javascript functions/services to talk to veritree API",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,16 +1,5 @@
1
1
  import Api from "../helpers/api";
2
2
 
3
- class FieldUpdatesApi extends Api {
4
- constructor(resource) {
5
- super(resource);
6
- this.resource = "field-updates";
7
- }
3
+ const resource = "field-updates";
8
4
 
9
- async images(fieldUpdateId, args) {
10
- const url = `${this.getUrl()}/${fieldUpdateId}/images${this.getUrlParams(args)}`;
11
-
12
- return await this.get(url);
13
- }
14
- }
15
-
16
- export const FieldUpdates = new FieldUpdatesApi();
5
+ export const FieldUpdates = new Api(resource);
@@ -0,0 +1,5 @@
1
+ import Api from '../helpers/api';
2
+
3
+ const resource = 'users';
4
+
5
+ export const Users = new Api(resource);
@@ -8,13 +8,13 @@ import { getSession } from "./session";
8
8
  * @param {string} url
9
9
  * @returns {string} url
10
10
  */
11
- function addVersionArg(url) {
11
+ function addEnvelopeParam(url) {
12
12
  if (!url || url.includes("_result=1")) return url;
13
13
 
14
14
  const urlHasArgs = url.includes("?");
15
- const urlVersionArg = urlHasArgs ? "&_v=5.0.0" : "?_v=5.0.0";
15
+ const urlEvenlopeArg = urlHasArgs ? "&_result=1" : "?_result=1";
16
16
 
17
- return `${url}${urlVersionArg}`;
17
+ return `${url}${urlEvenlopeArg}`;
18
18
  }
19
19
 
20
20
  /**
@@ -183,7 +183,7 @@ export default class Api {
183
183
  * @returns {object} envelope
184
184
  */
185
185
  async unWrap(url, method = "get", data, as) {
186
- url = addVersionArg(url);
186
+ url = addEnvelopeParam(url);
187
187
  const config = getConfig(method, data, as);
188
188
  const response = await fetch(url, config);
189
189