Files
tbbank-react-native-mobile/src/services/apiService.js
2025-07-03 22:36:28 +05:00

82 lines
1.8 KiB
JavaScript

import authService from './authService';
class ApiService {
// Profile methods
async getProfile() {
return authService.getProfile();
}
async updateProfile(data) {
return authService.updateProfile(data);
}
async changePassword(currentPassword, newPassword) {
return authService.changePassword(currentPassword, newPassword);
}
async deleteAccount() {
return authService.deleteAccount();
}
// Balance and transactions
async getBalance() {
return authService.getBalance();
}
async getTransactions(page = 1, limit = 20) {
return authService.getTransactions(page, limit);
}
// Transfer and payments
async transferMoney(data) {
return authService.transferMoney(data);
}
async payBill(data) {
return authService.payBill(data);
}
// Cards management
async getCards() {
return authService.getCards();
}
async addCard(data) {
return authService.addCard(data);
}
async blockCard(cardId) {
return authService.blockCard(cardId);
}
async unblockCard(cardId) {
return authService.unblockCard(cardId);
}
// Utility methods for common operations
async getUserDashboardData() {
try {
const [balance, transactions, cards] = await Promise.all([
this.getBalance().catch(() => ({ balance: 0 })),
this.getTransactions(1, 5).catch(() => ({ transactions: [] })),
this.getCards().catch(() => ({ cards: [] }))
]);
return {
success: true,
data: {
balance: balance.balance || 0,
recentTransactions: transactions.transactions || [],
cards: cards.cards || []
}
};
} catch (error) {
return {
success: false,
error: error.message
};
}
}
}
export default new ApiService();