diff --git a/src/services/django-api.js b/src/services/django-api.js index b44c5e3..f4171c9 100644 --- a/src/services/django-api.js +++ b/src/services/django-api.js @@ -1,93 +1,99 @@ -import AuthService from '@/services/auth'; -import http from '@/services/http'; +import AuthService from "@/services/auth"; +import http from "@/services/http"; class DjangoApi { - constructor() { - this.base = import.meta.env.VITE_DJANGO_BASE_URL; - } + constructor() { + this.base = import.meta.env.VITE_DJANGO_BASE_URL; + } - getRequest(url) { - return http.get(url).then(r => r.data); - } + getRequest(url) { + return http.get(url).then((r) => r.data); + } - postRequest(url, payload) { - return http.post(url, payload).then(r => r.data); - } + postRequest(url, payload) { + return http.post(url, payload).then((r) => r.data); + } - getCustomers() { - const url = this.base + '/don_confiao/api/customers/'; - return this.getRequest(url); - } + getCustomers() { + const url = this.base + "/don_confiao/api/customers/"; + return this.getRequest(url); + } - getProducts() { - const url = this.base + '/don_confiao/api/products/'; - return this.getRequest(url); - } + getProducts() { + const url = this.base + "/don_confiao/api/products/"; + return this.getRequest(url); + } - getPaymentMethods() { - const url = this.base + '/don_confiao/payment_methods/all/select_format'; - return this.getRequest(url); - } + getPaymentMethods() { + const url = + this.base + "/don_confiao/payment_methods/all/select_format"; + return this.getRequest(url); + } - getSummaryPurchase(purchaseId) { - const url = this.base + `/don_confiao/resumen_compra_json/${purchaseId}`; - return this.getRequest(url); - } + getSummaryPurchase(purchaseId) { + const url = + this.base + `/don_confiao/resumen_compra_json/${purchaseId}`; + return this.getRequest(url); + } - getPurchasesForReconciliation() { - const url = this.base + '/don_confiao/purchases/for_reconciliation'; - return this.getRequest(url); - } + getPurchasesForReconciliation() { + const url = this.base + "/don_confiao/purchases/for_reconciliation"; + return this.getRequest(url); + } - getListReconcliations(page, itemsPerPage) { - const url = this.base + `/don_confiao/api/reconciliate_jar/?page=${page}&page_size=${itemsPerPage}`; - return this.getRequest(url); - } + getListReconcliations(page, itemsPerPage) { + const url = + this.base + + `/don_confiao/api/reconciliate_jar/?page=${page}&page_size=${itemsPerPage}`; + return this.getRequest(url); + } - getReconciliation(reconciliationId) { - const url = this.base + `/don_confiao/api/reconciliate_jar/${reconciliationId}/`; - return this.getRequest(url); - } + getReconciliation(reconciliationId) { + const url = + this.base + + `/don_confiao/api/reconciliate_jar/${reconciliationId}/`; + return this.getRequest(url); + } - createPurchase(purchase) { - const url = this.base + '/don_confiao/api/sales/'; - return this.postRequest(url, purchase); - } + createPurchase(purchase) { + const url = this.base + "/don_confiao/api/sales/"; + return this.postRequest(url, purchase); + } - createReconciliationJar(reconciliation) { - const url = this.base + '/don_confiao/reconciliate_jar'; - return this.postRequest(url, reconciliation); - } + createReconciliationJar(reconciliation) { + const url = this.base + "/don_confiao/reconciliate_jar"; + return this.postRequest(url, reconciliation); + } - createCustomer(customer) { - const url = this.base + '/don_confiao/api/customers/'; - return this.postRequest(url, customer); - } + createCustomer(customer) { + const url = this.base + "/don_confiao/api/customers/"; + return this.postRequest(url, customer); + } - getCSVForTryton() { - const url = this.base + '/don_confiao/api/sales/for_tryton'; - return this.getRequest(url); - } + getCSVForTryton() { + const url = this.base + "/don_confiao/api/sales/for_tryton"; + return this.getRequest(url); + } - getProductsFromTryton(){ - const url = this.base + '/don_confiao/api/importar_productos_de_tryton'; - return this.postRequest(url, {}); - } + getProductsFromTryton() { + const url = this.base + "/don_confiao/api/importar_productos_de_tryton"; + return this.postRequest(url, {}); + } - getCustomersFromTryton(){ - const url = this.base + '/don_confiao/api/importar_clientes_de_tryton'; - return this.postRequest(url, {}); - } + getCustomersFromTryton() { + const url = this.base + "/don_confiao/api/importar_clientes_de_tryton"; + return this.postRequest(url, {}); + } - sendSalesToTryton(){ - const url = this.base + '/don_confiao/api/enviar_ventas_a_tryton'; - return this.postRequest(url, {}); - } + sendSalesToTryton() { + const url = this.base + "/don_confiao/api/enviar_ventas_a_tryton"; + return this.postRequest(url, {}); + } - getCurrentUser() { - const url = this.base + '/api/users/me/'; - return this.getRequest(url); - } + getCurrentUser() { + const url = this.base + "/api/users/me/"; + return this.getRequest(url); + } } export default DjangoApi;