@veritree/services 0.14.1 → 0.16.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/services",
3
- "version": "0.14.1",
3
+ "version": "0.16.0",
4
4
  "description": "A collection of javascript functions/services to talk to veritree API",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -47,6 +47,7 @@ const Api = {
47
47
  */
48
48
  getConfig(method, data) {
49
49
  const isGet = method === "get";
50
+ const isPut = method === "put";
50
51
  const isFormData = this._isFormData(data);
51
52
  const accessToken = `Bearer ${getCookie('access_token')}`;
52
53
 
@@ -62,7 +63,12 @@ const Api = {
62
63
  }
63
64
 
64
65
  if (!isGet) {
65
- isFormData ? (config.body = data) : (config.body = JSON.stringify(data));
66
+ if(isFormData) {
67
+ if(isPut) data.set('_method', 'PUT');
68
+ config.body = data;
69
+ } else {
70
+ config.body = JSON.stringify(data);
71
+ }
66
72
  }
67
73
 
68
74
  return config;
@@ -35,6 +35,5 @@ export const createFieldUpdateVerificationsApiService = () => {
35
35
 
36
36
  return {
37
37
  post,
38
- update,
39
38
  };
40
39
  };
@@ -32,6 +32,12 @@ export const createSubsitesApiService = () => {
32
32
 
33
33
  return await Api.get(url);
34
34
  },
35
+
36
+ async stats(id) {
37
+ const url = `${_getUrl()}/${id}/stats`;
38
+
39
+ return await Api.get(url);
40
+ }
35
41
  };
36
42
 
37
43
  const post = (data) => {
@@ -40,6 +46,12 @@ export const createSubsitesApiService = () => {
40
46
  return Api.post(url, data);
41
47
  }
42
48
 
49
+ const update = (id, data) => {
50
+ const url = `${_getUrl()}/${id}?${_getUrlParams()}`;
51
+
52
+ return Api.update(url, data);
53
+ }
54
+
43
55
  const _getUrl = () => {
44
56
  return `${Api.baseUrl}/${resource}`;
45
57
  };
@@ -52,6 +64,7 @@ export const createSubsitesApiService = () => {
52
64
 
53
65
  return {
54
66
  get,
55
- post
67
+ post,
68
+ update
56
69
  };
57
70
  };