sync profile api
This commit is contained in:
82
src/services/apiService.js
Normal file
82
src/services/apiService.js
Normal file
@@ -0,0 +1,82 @@
|
||||
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();
|
||||
Reference in New Issue
Block a user