LookupInvoiceResponse.deserialize constructor

LookupInvoiceResponse.deserialize(
  1. Map<String, dynamic> input
)

Implementation

factory LookupInvoiceResponse.deserialize(Map<String, dynamic> input) {
  if (!input.containsKey('result')) {
    throw Exception('Invalid input');
  }

  Map<String, dynamic> result = input['result'] as Map<String, dynamic>;

  return LookupInvoiceResponse(
    type: result['type'] as String,
    invoice: result['invoice'] as String,
    description: result['description'] as String,
    descriptionHash: result['description_hash'] as String,
    preimage: result['preimage'] as String,
    paymentHash: result['payment_hash'] as String,
    amount: result['amount'] as int,
    feesPaid: result['fees_paid'] as int,
    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,
  );
}