Skip to content

Commit 6ccee4c

Browse files
authored
Merge pull request #37 from lightsparkdev/05-14-regenerate_the_python_sdk_objects
Regenerate the python SDK objects
2 parents 6c0b35b + 647bde1 commit 6ccee4c

17 files changed

Lines changed: 207 additions & 3 deletions

lightspark/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,24 @@
137137
from lightspark.objects.OutgoingPaymentAttemptToHopsConnection import (
138138
OutgoingPaymentAttemptToHopsConnection,
139139
)
140+
from lightspark.objects.OutgoingPaymentForIdempotencyKeyInput import (
141+
OutgoingPaymentForIdempotencyKeyInput,
142+
)
143+
from lightspark.objects.OutgoingPaymentForIdempotencyKeyOutput import (
144+
OutgoingPaymentForIdempotencyKeyOutput,
145+
)
140146
from lightspark.objects.OutgoingPaymentsForInvoiceQueryInput import (
141147
OutgoingPaymentsForInvoiceQueryInput,
142148
)
143149
from lightspark.objects.OutgoingPaymentsForInvoiceQueryOutput import (
144150
OutgoingPaymentsForInvoiceQueryOutput,
145151
)
152+
from lightspark.objects.OutgoingPaymentsForPaymentHashQueryInput import (
153+
OutgoingPaymentsForPaymentHashQueryInput,
154+
)
155+
from lightspark.objects.OutgoingPaymentsForPaymentHashQueryOutput import (
156+
OutgoingPaymentsForPaymentHashQueryOutput,
157+
)
146158
from lightspark.objects.OutgoingPaymentToAttemptsConnection import (
147159
OutgoingPaymentToAttemptsConnection,
148160
)

lightspark/objects/Account.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,6 +1264,7 @@ def get_transactions(
12641264
}
12651265
outgoing_payment_payment_preimage: payment_preimage
12661266
outgoing_payment_is_internal_payment: is_internal_payment
1267+
outgoing_payment_idempotency_key: idempotency_key
12671268
}
12681269
... on RoutingTransaction {
12691270
__typename
@@ -1713,15 +1714,16 @@ def get_withdrawal_requests(
17131714
bitcoin_networks: Optional[List[BitcoinNetwork]] = None,
17141715
statuses: Optional[List[WithdrawalRequestStatus]] = None,
17151716
node_ids: Optional[List[str]] = None,
1717+
idempotency_keys: Optional[List[str]] = None,
17161718
after_date: Optional[datetime] = None,
17171719
before_date: Optional[datetime] = None,
17181720
) -> AccountToWithdrawalRequestsConnection:
17191721
json = self.requester.execute_graphql(
17201722
"""
1721-
query FetchAccountToWithdrawalRequestsConnection($entity_id: ID!, $first: Int, $after: String, $bitcoin_networks: [BitcoinNetwork!], $statuses: [WithdrawalRequestStatus!], $node_ids: [ID!], $after_date: DateTime, $before_date: DateTime) {
1723+
query FetchAccountToWithdrawalRequestsConnection($entity_id: ID!, $first: Int, $after: String, $bitcoin_networks: [BitcoinNetwork!], $statuses: [WithdrawalRequestStatus!], $node_ids: [ID!], $idempotency_keys: [String!], $after_date: DateTime, $before_date: DateTime) {
17221724
entity(id: $entity_id) {
17231725
... on Account {
1724-
withdrawal_requests(, first: $first, after: $after, bitcoin_networks: $bitcoin_networks, statuses: $statuses, node_ids: $node_ids, after_date: $after_date, before_date: $before_date) {
1726+
withdrawal_requests(, first: $first, after: $after, bitcoin_networks: $bitcoin_networks, statuses: $statuses, node_ids: $node_ids, idempotency_keys: $idempotency_keys, after_date: $after_date, before_date: $before_date) {
17251727
__typename
17261728
account_to_withdrawal_requests_connection_count: count
17271729
account_to_withdrawal_requests_connection_page_info: page_info {
@@ -1783,6 +1785,7 @@ def get_withdrawal_requests(
17831785
withdrawal_request_withdrawal: withdrawal {
17841786
id
17851787
}
1788+
withdrawal_request_idempotency_key: idempotency_key
17861789
}
17871790
}
17881791
}
@@ -1796,6 +1799,7 @@ def get_withdrawal_requests(
17961799
"bitcoin_networks": bitcoin_networks,
17971800
"statuses": statuses,
17981801
"node_ids": node_ids,
1802+
"idempotency_keys": idempotency_keys,
17991803
"after_date": after_date,
18001804
"before_date": before_date,
18011805
},

lightspark/objects/Entity.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,7 @@ class Entity:
12891289
}
12901290
outgoing_payment_payment_preimage: payment_preimage
12911291
outgoing_payment_is_internal_payment: is_internal_payment
1292+
outgoing_payment_idempotency_key: idempotency_key
12921293
}
12931294
... on OutgoingPaymentAttempt {
12941295
__typename
@@ -1514,6 +1515,7 @@ class Entity:
15141515
withdrawal_request_withdrawal: withdrawal {
15151516
id
15161517
}
1518+
withdrawal_request_idempotency_key: idempotency_key
15171519
}
15181520
}
15191521
"""

lightspark/objects/LightningTransaction.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ def to_json(self) -> Mapping[str, Any]:
447447
}
448448
outgoing_payment_payment_preimage: payment_preimage
449449
outgoing_payment_is_internal_payment: is_internal_payment
450+
outgoing_payment_idempotency_key: idempotency_key
450451
}
451452
... on RoutingTransaction {
452453
__typename
@@ -569,6 +570,7 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> LightningTransact
569570
else None,
570571
payment_preimage=obj["outgoing_payment_payment_preimage"],
571572
is_internal_payment=obj["outgoing_payment_is_internal_payment"],
573+
idempotency_key=obj["outgoing_payment_idempotency_key"],
572574
)
573575
if obj["__typename"] == "RoutingTransaction":
574576
# pylint: disable=import-outside-toplevel

lightspark/objects/OutgoingPayment.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ class OutgoingPayment(LightningTransaction, Transaction, Entity):
8282

8383
is_internal_payment: bool
8484
"""Whether the payment is made to the same node."""
85+
86+
idempotency_key: Optional[str]
87+
"""The idempotency key of the payment."""
8588
typename: str
8689

8790
def get_attempts(
@@ -179,6 +182,7 @@ def to_json(self) -> Mapping[str, Any]:
179182
else None,
180183
"outgoing_payment_payment_preimage": self.payment_preimage,
181184
"outgoing_payment_is_internal_payment": self.is_internal_payment,
185+
"outgoing_payment_idempotency_key": self.idempotency_key,
182186
}
183187

184188

@@ -527,6 +531,7 @@ def to_json(self) -> Mapping[str, Any]:
527531
}
528532
outgoing_payment_payment_preimage: payment_preimage
529533
outgoing_payment_is_internal_payment: is_internal_payment
534+
outgoing_payment_idempotency_key: idempotency_key
530535
}
531536
"""
532537

@@ -576,4 +581,5 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> OutgoingPayment:
576581
else None,
577582
payment_preimage=obj["outgoing_payment_payment_preimage"],
578583
is_internal_payment=obj["outgoing_payment_is_internal_payment"],
584+
idempotency_key=obj["outgoing_payment_idempotency_key"],
579585
)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved
2+
3+
from dataclasses import dataclass
4+
from typing import Any, Mapping
5+
6+
7+
@dataclass
8+
class OutgoingPaymentForIdempotencyKeyInput:
9+
idempotency_key: str
10+
11+
def to_json(self) -> Mapping[str, Any]:
12+
return {
13+
"outgoing_payment_for_idempotency_key_input_idempotency_key": self.idempotency_key,
14+
}
15+
16+
17+
def from_json(obj: Mapping[str, Any]) -> OutgoingPaymentForIdempotencyKeyInput:
18+
return OutgoingPaymentForIdempotencyKeyInput(
19+
idempotency_key=obj[
20+
"outgoing_payment_for_idempotency_key_input_idempotency_key"
21+
],
22+
)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved
2+
3+
from dataclasses import dataclass
4+
from typing import Any, Mapping, Optional
5+
6+
from lightspark.requests.requester import Requester
7+
8+
9+
@dataclass
10+
class OutgoingPaymentForIdempotencyKeyOutput:
11+
requester: Requester
12+
13+
payment_id: Optional[str]
14+
15+
def to_json(self) -> Mapping[str, Any]:
16+
return {
17+
"outgoing_payment_for_idempotency_key_output_payment": {
18+
"id": self.payment_id
19+
}
20+
if self.payment_id
21+
else None,
22+
}
23+
24+
25+
FRAGMENT = """
26+
fragment OutgoingPaymentForIdempotencyKeyOutputFragment on OutgoingPaymentForIdempotencyKeyOutput {
27+
__typename
28+
outgoing_payment_for_idempotency_key_output_payment: payment {
29+
id
30+
}
31+
}
32+
"""
33+
34+
35+
def from_json(
36+
requester: Requester, obj: Mapping[str, Any]
37+
) -> OutgoingPaymentForIdempotencyKeyOutput:
38+
return OutgoingPaymentForIdempotencyKeyOutput(
39+
requester=requester,
40+
payment_id=obj["outgoing_payment_for_idempotency_key_output_payment"]["id"]
41+
if obj["outgoing_payment_for_idempotency_key_output_payment"]
42+
else None,
43+
)

lightspark/objects/OutgoingPaymentsForInvoiceQueryOutput.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ def to_json(self) -> Mapping[str, Any]:
370370
}
371371
outgoing_payment_payment_preimage: payment_preimage
372372
outgoing_payment_is_internal_payment: is_internal_payment
373+
outgoing_payment_idempotency_key: idempotency_key
373374
}
374375
}
375376
"""
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved
2+
3+
from dataclasses import dataclass
4+
from typing import Any, List, Mapping, Optional
5+
6+
from lightspark.utils.enums import parse_optional_list_of_enums
7+
8+
from .TransactionStatus import TransactionStatus
9+
10+
11+
@dataclass
12+
class OutgoingPaymentsForPaymentHashQueryInput:
13+
payment_hash: str
14+
"""The 32-byte hash of the payment preimage for which to fetch payments"""
15+
16+
statuses: Optional[List[TransactionStatus]]
17+
"""An optional filter to only query outgoing payments of given statuses."""
18+
19+
def to_json(self) -> Mapping[str, Any]:
20+
return {
21+
"outgoing_payments_for_payment_hash_query_input_payment_hash": self.payment_hash,
22+
"outgoing_payments_for_payment_hash_query_input_statuses": [
23+
e.value for e in self.statuses
24+
]
25+
if self.statuses
26+
else None,
27+
}
28+
29+
30+
def from_json(obj: Mapping[str, Any]) -> OutgoingPaymentsForPaymentHashQueryInput:
31+
return OutgoingPaymentsForPaymentHashQueryInput(
32+
payment_hash=obj["outgoing_payments_for_payment_hash_query_input_payment_hash"],
33+
statuses=parse_optional_list_of_enums(
34+
TransactionStatus,
35+
obj["outgoing_payments_for_payment_hash_query_input_statuses"],
36+
),
37+
)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved
2+
3+
from dataclasses import dataclass
4+
from typing import Any, List, Mapping
5+
6+
from lightspark.requests.requester import Requester
7+
8+
from .OutgoingPayment import OutgoingPayment
9+
from .OutgoingPayment import from_json as OutgoingPayment_from_json
10+
11+
12+
@dataclass
13+
class OutgoingPaymentsForPaymentHashQueryOutput:
14+
requester: Requester
15+
16+
payments: List[OutgoingPayment]
17+
18+
def to_json(self) -> Mapping[str, Any]:
19+
return {
20+
"outgoing_payments_for_payment_hash_query_output_payments": [
21+
e.to_json() for e in self.payments
22+
],
23+
}
24+
25+
26+
FRAGMENT = """
27+
fragment OutgoingPaymentsForPaymentHashQueryOutputFragment on OutgoingPaymentsForPaymentHashQueryOutput {
28+
__typename
29+
outgoing_payments_for_payment_hash_query_output_payments: payments {
30+
id
31+
}
32+
}
33+
"""
34+
35+
36+
def from_json(
37+
requester: Requester, obj: Mapping[str, Any]
38+
) -> OutgoingPaymentsForPaymentHashQueryOutput:
39+
return OutgoingPaymentsForPaymentHashQueryOutput(
40+
requester=requester,
41+
payments=list(
42+
map(
43+
# pylint: disable=unnecessary-lambda
44+
lambda e: OutgoingPayment_from_json(requester, e),
45+
obj["outgoing_payments_for_payment_hash_query_output_payments"],
46+
)
47+
),
48+
)

0 commit comments

Comments
 (0)