card remaning done

This commit is contained in:
2025-07-08 19:08:49 +05:00
parent 10ac440401
commit 89a1c0d9f2
7 changed files with 804 additions and 0 deletions

View File

@@ -411,6 +411,74 @@ class AuthService {
// POST request authenticated (token header will be included if available)
return this.makeRequest('/card-balance-quick-check', payload, true, 'POST');
}
// ================================
// Card Balance Orders (Kart galyndylary)
// ================================
// LIST
async getCardBalanceOrders() {
return this.makeRequest('/card-balances', null, true, 'GET');
}
// CREATE
async createCardBalanceOrder(cardNumber, cardMonth, cardYear, passportSerie = null, passportId = null) {
let serie = passportSerie;
let pid = passportId;
if (!serie || !pid) {
const user = await this.getStoredUser();
serie = serie || user?.passport_serie;
pid = pid || user?.passport_id;
}
if (!serie || !pid) {
throw new Error('Passport details are missing');
}
const payload = {
passport_serie: serie,
passport_id: pid,
card_number: cardNumber,
card_month: cardMonth,
card_year: cardYear,
};
return this.makeRequest('/card-balances', payload, true, 'POST');
}
// SHOW
async getCardBalanceOrder(orderId) {
return this.makeRequest(`/card-balances/${orderId}`, null, true, 'GET');
}
// UPDATE
async updateCardBalanceOrder(orderId, cardNumber, cardMonth, cardYear, passportSerie = null, passportId = null) {
let serie = passportSerie;
let pid = passportId;
if (!serie || !pid) {
const user = await this.getStoredUser();
serie = serie || user?.passport_serie;
pid = pid || user?.passport_id;
}
if (!serie || !pid) {
throw new Error('Passport details are missing');
}
const payload = {
passport_serie: serie,
passport_id: pid,
card_number: cardNumber,
card_month: cardMonth,
card_year: cardYear,
};
return this.makeRequest(`/card-balances/${orderId}`, payload, true, 'POST');
}
// DELETE
async deleteCardBalanceOrder(orderId) {
return this.makeRequest(`/card-balances/${orderId}`, null, true, 'DELETE');
}
// DOWNLOAD (returns object with card details)
async downloadCardBalances(orderId) {
return this.makeRequest(`/card-balances-download/${orderId}`, null, true, 'GET');
}
}
export default new AuthService();