💥 Updated API routes

This commit is contained in:
2025-10-22 22:51:51 +08:00
parent 2a7d12de48
commit 1ae81794b1
49 changed files with 197 additions and 182 deletions

View File

@@ -26,7 +26,7 @@ part 'wallet.g.dart';
Future<SnWallet?> walletCurrent(Ref ref) async {
try {
final apiClient = ref.watch(apiClientProvider);
final resp = await apiClient.get('/id/wallets');
final resp = await apiClient.get('/pass/wallets');
return SnWallet.fromJson(resp.data);
} catch (err) {
if (err is DioException && err.response?.statusCode == 404) {
@@ -491,7 +491,7 @@ class TransactionListNotifier extends _$TransactionListNotifier
final queryParams = {'offset': offset, 'take': _pageSize};
final response = await client.get(
'/id/wallets/transactions',
'/pass/wallets/transactions',
queryParameters: queryParams,
);
final total = int.parse(response.headers.value('X-Total') ?? '0');
@@ -518,7 +518,7 @@ Future<List<SnWalletFund>> walletFunds(
int take = 20,
}) async {
final client = ref.watch(apiClientProvider);
final resp = await client.get('/id/wallets/funds?offset=$offset&take=$take');
final resp = await client.get('/pass/wallets/funds?offset=$offset&take=$take');
return (resp.data as List).map((e) => SnWalletFund.fromJson(e)).toList();
}
@@ -530,7 +530,7 @@ Future<List<SnWalletFundRecipient>> walletFundRecipients(
}) async {
final client = ref.watch(apiClientProvider);
final resp = await client.get(
'/id/wallets/funds/recipients?offset=$offset&take=$take',
'/pass/wallets/funds/recipients?offset=$offset&take=$take',
);
return (resp.data as List)
.map((e) => SnWalletFundRecipient.fromJson(e))
@@ -540,14 +540,14 @@ Future<List<SnWalletFundRecipient>> walletFundRecipients(
@riverpod
Future<SnWalletFund> walletFund(Ref ref, String fundId) async {
final client = ref.watch(apiClientProvider);
final resp = await client.get('/id/wallets/funds/$fundId');
final resp = await client.get('/pass/wallets/funds/$fundId');
return SnWalletFund.fromJson(resp.data);
}
@riverpod
Future<Map<String, dynamic>> walletFundStats(Ref ref) async {
final client = ref.watch(apiClientProvider);
final resp = await client.get('/id/wallets/funds/stats');
final resp = await client.get('/pass/wallets/funds/stats');
return resp.data as Map<String, dynamic>;
}
@@ -563,7 +563,7 @@ class WalletScreen extends HookConsumerWidget {
Future<void> createWallet() async {
final client = ref.read(apiClientProvider);
try {
await client.post('/id/wallets');
await client.post('/pass/wallets');
ref.invalidate(walletCurrentProvider);
} catch (err) {
showErrorAlert(err);
@@ -941,14 +941,14 @@ class WalletScreen extends HookConsumerWidget {
try {
showLoadingModal(context);
final resp = await client.post(
'/id/wallets/funds',
'/pass/wallets/funds',
data: fundData,
options: Options(headers: {'X-Noop': true}),
);
final fund = SnWalletFund.fromJson(resp.data);
if (fund.status == 0) return; // Already created
final orderResp = await client.post('/id/wallets/funds/${fund.id}/order');
final orderResp = await client.post('/pass/wallets/funds/${fund.id}/order');
final order = SnWalletOrder.fromJson(orderResp.data);
if (context.mounted) hideLoadingModal(context);