@amanat-qa/utils-backend 1.1.5 → 1.2.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/API/baseAPI.js +26 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amanat-qa/utils-backend",
3
- "version": "1.1.5",
3
+ "version": "1.2.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -67,6 +67,32 @@ class BaseAPI {
67
67
  return error.response;
68
68
  }
69
69
  }
70
+
71
+ async put(endpoint, params) {
72
+ Logger.log(`[req] ▶ put ${JSON.stringify(params || {})} to ${endpoint}:`);
73
+ try {
74
+ const response = await this.#axiosInstance.put(`/${endpoint}`, params);
75
+ Logger.log(`[res] status code: ${response.status}`);
76
+ return response;
77
+ } catch (error) {
78
+ Logger.log(`[res] status code: ${error.response.status}`);
79
+ Logger.log(`[res] body: ${JSON.stringify(error.response.data)}`);
80
+ return error.response;
81
+ }
82
+ }
83
+
84
+ async delete(endpoint, params) {
85
+ Logger.log(`[req] ▶ delete ${JSON.stringify(params || {})} to ${endpoint}:`);
86
+ try {
87
+ const response = await this.#axiosInstance.delete(`/${endpoint}`, params);
88
+ Logger.log(`[res] status code: ${response.status}`);
89
+ return response;
90
+ } catch (error) {
91
+ Logger.log(`[res] status code: ${error.response.status}`);
92
+ Logger.log(`[res] body: ${JSON.stringify(error.response.data)}`);
93
+ return error.response;
94
+ }
95
+ }
70
96
  }
71
97
 
72
98
  module.exports = BaseAPI; // test commentary... don't mind me