clean up api utils
This commit is contained in:
parent
b087ea673e
commit
ce708f5209
4 changed files with 74 additions and 57 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import DataUtils from "./utils";
|
||||
import ApiUtils from "./apiUtils";
|
||||
|
||||
const ZIPPOPOTAMUS_BASE_URL = "https://api.zippopotam.us/us";
|
||||
const FRAPPE_PROXY_METHOD = "custom_ui.api.proxy.request";
|
||||
|
|
@ -12,12 +12,12 @@ const FRAPPE_GET_CLIENT_METHOD = "custom_ui.api.db.clients.get_client";
|
|||
|
||||
class Api {
|
||||
static async request(frappeMethod, args = {}) {
|
||||
args = DataUtils.toSnakeCaseObject(args);
|
||||
args = ApiUtils.toSnakeCaseObject(args);
|
||||
const request = { method: frappeMethod, args };
|
||||
console.log("DEBUG: API - Request Args: ", request);
|
||||
try {
|
||||
let response = await frappe.call(request);
|
||||
response = DataUtils.toCamelCaseObject(response);
|
||||
response = ApiUtils.toCamelCaseObject(response);
|
||||
console.log("DEBUG: API - Request Response: ", response);
|
||||
return response.message;
|
||||
} catch (error) {
|
||||
|
|
@ -32,7 +32,7 @@ class Api {
|
|||
}
|
||||
|
||||
static async getClientDetails(clientName) {
|
||||
return await this.request(FRAPPE_GET_CLIENT_DETAILS_METHOD, { clientName });
|
||||
return await this.request(FRAPPE_GET_CLIENT_METHOD, { clientName });
|
||||
}
|
||||
|
||||
static async getJobDetails() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue