MakeInvoiceResponse.deserialize constructor
MakeInvoiceResponse.deserialize(
- Map<String, dynamic> input
)
Implementation
factory MakeInvoiceResponse.deserialize(Map<String, dynamic> input) {
if (!input.containsKey('result')) {
throw Exception('Invalid input');
}
Map<String, dynamic> result = input['result'] as Map<String, dynamic>;
return MakeInvoiceResponse(
type: result['type'] as String,
invoice: result['invoice'] as String,
description: result['description'] as String,
descriptionHash: result.containsKey('description_hash')
? result['description_hash'] as String
: '',
preimage:
result.containsKey('preimage') ? result['preimage'] as String : '',
paymentHash: result.containsKey('payment_hash')
? result['payment_hash'] as String
: '',
amountMsat: result['amount'] as int,
feesPaid:
result.containsKey('feeds_paid') ? result['fees_paid'] as int : 0,
createdAt: result['created_at'] as int,
expiresAt: result['expires_at'] as int?,
settledAt: result['settled_at'] as int?, // optional
resultType: input['result_type'] as String,
);
}