dev
dart 44 lines 1.32 KB
Raw
1 import 'package:cw_zano/api/model/destination.dart';
2
3 class TransferParams {
4 final List<Destination> destinations;
5 final BigInt fee;
6 final int mixin;
7 final String paymentId;
8 final String comment;
9 final bool pushPayer;
10 final bool hideReceiver;
11
12 TransferParams({
13 required this.destinations,
14 required this.fee,
15 required this.mixin,
16 required this.paymentId,
17 required this.comment,
18 required this.pushPayer,
19 required this.hideReceiver,
20 });
21
22 Map<String, dynamic> toJson() => {
23 'destinations': destinations,
24 'fee': fee.toInt(),
25 'mixin': mixin,
26 'payment_id': paymentId,
27 'comment': comment,
28 'push_payer': pushPayer,
29 'hide_receiver': hideReceiver,
30 };
31
32 factory TransferParams.fromJson(Map<String, dynamic> json) => TransferParams(
33 destinations: (json['destinations'] as List<dynamic>?)
34 ?.map((e) => Destination.fromJson(e as Map<String, dynamic>))
35 .toList() ??
36 [],
37 fee: BigInt.from(json['fee'] as int? ?? 0),
38 mixin: json['mixin'] as int? ?? 0,
39 paymentId: json['payment_id'] as String? ?? '',
40 comment: json['comment'] as String? ?? '',
41 pushPayer: json['push_payer'] as bool? ?? false,
42 hideReceiver: json['hide_receiver'] as bool? ?? false,
43 );
44 }