Copy // file name
// _requests.ts.ziref
import axios, {AxiosResponse} from 'axios'
import {ID, Response} from '../../../../../_metronic/helpers'
import {[[[zg-entity...zg-name]]], zg-pluralize(((zg-entity...zg-name)))QueryResponse} from './_models'
const API_URL = process.env.REACT_APP_API_URL
const GET_zg-upper(((zg-entity...zg-name)))_URL = `${API_URL}/zg-lower(((zg-entity...zg-name)))/getzg-lower(((zg-entity...zg-name)))`
const CREATE_zg-upper(((zg-entity...zg-name)))_URL = `${API_URL}/zg-lower(((zg-entity...zg-name)))/addzg-lower(((zg-entity...zg-name)))`
const UPDATE_zg-upper(((zg-entity...zg-name)))_URL = `${API_URL}/zg-lower(((zg-entity...zg-name)))/updatezg-lower(((zg-entity...zg-name)))`
const DELETE_zg-upper(((zg-entity...zg-name)))_URL = `${API_URL}/zg-lower(((zg-entity...zg-name)))/deletezg-lower(((zg-entity...zg-name)))`
const GET_zg-upper(((zg-pluralize(((zg-entity...zg-name))))))_URL = `${API_URL}/zg-lower(((zg-entity...zg-name)))/getzg-lower(((zg-pluralize(((zg-entity...zg-name))))))`
const getzg-pluralize(((zg-entity...zg-name))) = (query: string): Promise<zg-pluralize(((zg-entity...zg-name)))QueryResponse> => {
return axios
.get(`${GET_zg-upper(((zg-pluralize(((zg-entity...zg-name))))))_URL}?${query}`)
.then((d: AxiosResponse<zg-pluralize(((zg-entity...zg-name)))QueryResponse>) => d.data)
}
const get[[[zg-entity...zg-name]]]ById = (id: ID): Promise<[[[zg-entity...zg-name]]] | undefined> => {
return axios
.get(`${GET_zg-upper(((zg-entity...zg-name)))_URL}/${id}`)
.then((response: AxiosResponse<Response<[[[zg-entity...zg-name]]]>>) => response.data)
.then((response: Response<[[[zg-entity...zg-name]]]>) => response.data)
}
const create[[[zg-entity...zg-name]]] = (zg-lower(((zg-entity...zg-name))): [[[zg-entity...zg-name]]]): Promise<[[[zg-entity...zg-name]]] | undefined> => {
return axios
.post(CREATE_zg-upper(((zg-entity...zg-name)))_URL, zg-lower(((zg-entity...zg-name))))
.then((response: AxiosResponse<Response<[[[zg-entity...zg-name]]]>>) => response.data)
.then((response: Response<[[[zg-entity...zg-name]]]>) => response.data)
}
const update[[[zg-entity...zg-name]]] = (zg-lower(((zg-entity...zg-name))): [[[zg-entity...zg-name]]]): Promise<[[[zg-entity...zg-name]]] | undefined> => {
return axios
.put(`${UPDATE_zg-upper(((zg-entity...zg-name)))_URL}/${zg-lower(((zg-entity...zg-name))).id}`, zg-lower(((zg-entity...zg-name))))
.then((response: AxiosResponse<Response<[[[zg-entity...zg-name]]]>>) => response.data)
.then((response: Response<[[[zg-entity...zg-name]]]>) => response.data)
}
const delete[[[zg-entity...zg-name]]] = (zg-lower(((zg-entity...zg-name)))Id: ID): Promise<void> => {
return axios.delete(`${DELETE_zg-upper(((zg-entity...zg-name)))_URL}/${zg-lower(((zg-entity...zg-name)))Id}`).then(() => {})
}
const deleteSelectedzg-pluralize(((zg-entity...zg-name))) = (zg-lower(((zg-entity...zg-name)))Ids: Array<ID>): Promise<void> => {
const requests = zg-lower(((zg-entity...zg-name)))Ids.map((id) => axios.delete(`${DELETE_zg-upper(((zg-entity...zg-name)))_URL}/${id}`))
return axios.all(requests).then(() => {})
}
export {getzg-pluralize(((zg-entity...zg-name))), delete[[[zg-entity...zg-name]]], deleteSelectedzg-pluralize(((zg-entity...zg-name))), get[[[zg-entity...zg-name]]]ById, create[[[zg-entity...zg-name]]], update[[[zg-entity...zg-name]]]}