-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathCreateTestModeInvoiceInput.py
More file actions
45 lines (33 loc) · 1.56 KB
/
CreateTestModeInvoiceInput.py
File metadata and controls
45 lines (33 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved
from dataclasses import dataclass
from typing import Any, Mapping, Optional
from lightspark.utils.enums import parse_enum_optional
from .InvoiceType import InvoiceType
@dataclass
class CreateTestModeInvoiceInput:
local_node_id: str
"""The local node from which to create the invoice."""
amount_msats: int
"""The amount for which the invoice should be created, in millisatoshis. Setting the amount to 0 will allow the payer to specify an amount."""
memo: Optional[str]
"""An optional memo to include in the invoice."""
invoice_type: Optional[InvoiceType]
"""The type of invoice to create."""
def to_json(self) -> Mapping[str, Any]:
return {
"create_test_mode_invoice_input_local_node_id": self.local_node_id,
"create_test_mode_invoice_input_amount_msats": self.amount_msats,
"create_test_mode_invoice_input_memo": self.memo,
"create_test_mode_invoice_input_invoice_type": (
self.invoice_type.value if self.invoice_type else None
),
}
def from_json(obj: Mapping[str, Any]) -> CreateTestModeInvoiceInput:
return CreateTestModeInvoiceInput(
local_node_id=obj["create_test_mode_invoice_input_local_node_id"],
amount_msats=obj["create_test_mode_invoice_input_amount_msats"],
memo=obj["create_test_mode_invoice_input_memo"],
invoice_type=parse_enum_optional(
InvoiceType, obj["create_test_mode_invoice_input_invoice_type"]
),
)