Skip to content

Commit 995c259

Browse files
committed
add create invitation with payments to lightspark sdk
1 parent 8053c92 commit 995c259

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

lightspark/lightspark_client.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
PrivateFormat,
1616
PublicFormat,
1717
)
18+
1819
from lightspark.exceptions import LightsparkException
1920
from lightspark.objects.Account import Account
2021
from lightspark.objects.Account import from_json as Account_from_json
@@ -79,6 +80,7 @@
7980
from lightspark.scripts.create_uma_invitation import (
8081
CREATE_UMA_INVITATION_MUTATION,
8182
CREATE_UMA_INVITATION_WITH_INCENTIVES_MUTATION,
83+
CREATE_UMA_INVITATION_WITH_PAYMENT_MUTATION,
8284
)
8385
from lightspark.scripts.create_uma_invoice import CREATE_UMA_INVOICE_MUTATION
8486
from lightspark.scripts.current_account import CURRENT_ACCOUNT_QUERY
@@ -1015,5 +1017,37 @@ def fail_htlcs(self, invoice_id: str, cancel_invoice: bool = True) -> str:
10151017

10161018
return json["fail_htlcs"]["invoice"]["id"]
10171019

1020+
def create_uma_invitation_with_payment(
1021+
self,
1022+
inviter_uma: str,
1023+
payment_amount: float,
1024+
payment_currency: Any,
1025+
expires_at: str,
1026+
) -> UmaInvitation:
1027+
"""
1028+
Creates a new UMA invitation with payment.
1029+
1030+
Args:
1031+
inviter_uma: The UMA of the inviter.
1032+
payment_amount: The amount to be paid.
1033+
payment_currency: The currency object (should have code, symbol, name, decimals attributes).
1034+
expires_at: The expiration datetime as an ISO8601 string.
1035+
"""
1036+
json = self._requester.execute_graphql(
1037+
CREATE_UMA_INVITATION_WITH_PAYMENT_MUTATION,
1038+
{
1039+
"inviter_uma": inviter_uma,
1040+
"payment_amount": payment_amount,
1041+
"payment_currency_code": payment_currency.code,
1042+
"payment_currency_symbol": payment_currency.symbol,
1043+
"payment_currency_name": payment_currency.name,
1044+
"payment_currency_decimals": payment_currency.decimals,
1045+
"expires_at": expires_at,
1046+
},
1047+
)
1048+
return UmaInvitation_from_json(
1049+
self._requester, json["create_uma_invitation_with_payment"]["invitation"]
1050+
)
1051+
10181052

10191053
E614_REGEX = re.compile(r"^\+?[1-9]\d{1,14}$")

lightspark/scripts/create_uma_invitation.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,33 @@
3737
3838
{INVITATION_FRAGMENT}
3939
"""
40+
41+
CREATE_UMA_INVITATION_WITH_PAYMENT_MUTATION = f"""
42+
mutation CreateUmaInvitationWithPayment(
43+
$inviter_uma: String!
44+
$payment_amount: Float!
45+
$payment_currency_code: String!
46+
$payment_currency_symbol: String!
47+
$payment_currency_name: String!
48+
$payment_currency_decimals: Int!
49+
$expires_at: DateTime!
50+
) {{
51+
create_uma_invitation_with_payment(input: {{
52+
inviter_uma: $inviter_uma
53+
payment_amount: $payment_amount
54+
payment_currency: {{
55+
code: $payment_currency_code
56+
symbol: $payment_currency_symbol
57+
name: $payment_currency_name
58+
decimals: $payment_currency_decimals
59+
}}
60+
expires_at: $expires_at
61+
}}) {{
62+
invitation {{
63+
...UmaInvitationFragment
64+
}}
65+
}}
66+
}}
67+
68+
{INVITATION_FRAGMENT}
69+
"""

0 commit comments

Comments
 (0)