MakeInvoiceResponse.deserialize constructor

MakeInvoiceResponse.deserialize(
  1. 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['description_hash'] as String,
    preimage: result['preimage'] as String,
    paymentHash: result['payment_hash'] as String,
    amountMsat: 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,
  );
}