All checks were successful
ci/woodpecker/push/billing_fees Pipeline was successful
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/bff Pipeline was successful
ci/woodpecker/push/discovery Pipeline was successful
ci/woodpecker/push/fx_ingestor Pipeline was successful
ci/woodpecker/push/fx_oracle Pipeline was successful
ci/woodpecker/push/frontend Pipeline was successful
ci/woodpecker/push/gateway_mntx Pipeline was successful
ci/woodpecker/push/gateway_chain Pipeline was successful
ci/woodpecker/push/gateway_tgsettle Pipeline was successful
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/ledger Pipeline was successful
ci/woodpecker/push/notification Pipeline was successful
ci/woodpecker/push/payments_orchestrator Pipeline was successful
52 lines
1.7 KiB
Dart
52 lines
1.7 KiB
Dart
import 'package:pshared/api/requests/wallet/create.dart';
|
|
import 'package:pshared/api/responses/wallet_balance.dart';
|
|
import 'package:pshared/api/responses/wallets.dart';
|
|
import 'package:pshared/data/mapper/describable.dart';
|
|
import 'package:pshared/data/mapper/wallet/chain_asset.dart';
|
|
import 'package:pshared/data/mapper/wallet/response.dart';
|
|
import 'package:pshared/models/describable.dart';
|
|
import 'package:pshared/models/wallet/balance.dart';
|
|
import 'package:pshared/models/wallet/chain_asset.dart';
|
|
import 'package:pshared/models/wallet/wallet.dart';
|
|
import 'package:pshared/service/authorization/service.dart';
|
|
import 'package:pshared/service/services.dart';
|
|
|
|
|
|
class WalletService {
|
|
static const String _objectType = Services.chainWallets;
|
|
|
|
static Future<List<WalletModel>> list(String organizationRef) async {
|
|
final json = await AuthorizationService.getGETResponse(
|
|
_objectType,
|
|
'/$organizationRef',
|
|
);
|
|
return WalletsResponse.fromJson(json).toDomain();
|
|
}
|
|
|
|
static Future<WalletBalance> getBalance({
|
|
required String organizationRef,
|
|
required String walletRef,
|
|
}) async {
|
|
final json = await AuthorizationService.getGETResponse(
|
|
_objectType,
|
|
'/$organizationRef/$walletRef/balance',
|
|
);
|
|
return WalletBalanceResponse.fromJson(json).toDomain();
|
|
}
|
|
|
|
static Future<void> create({
|
|
required String organizationRef,
|
|
required Describable describable,
|
|
required ChainAsset asset,
|
|
required String? ownerRef,
|
|
}) async => AuthorizationService.getPOSTResponse(
|
|
_objectType,
|
|
'/$organizationRef',
|
|
CreateWalletRequest(
|
|
asset: asset.toDTO(),
|
|
describable: describable.toDTO(),
|
|
ownerRef: ownerRef,
|
|
).toJson(),
|
|
);
|
|
}
|