# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from io import BytesIO
from pyrogram.raw.core.primitives import Int, Long, Int128, Int256, Bool, Bytes, String, Double, Vector
from pyrogram.raw.core import TLObject
from pyrogram import raw
from typing import List, Optional, Any
# # # # # # # # # # # # # # # # # # # # # # # #
# !!! WARNING !!! #
# This is a generated file! #
# All changes made in this file will be lost! #
# # # # # # # # # # # # # # # # # # # # # # # #
[docs]
class CreateOnrampSession(TLObject): # type: ignore
"""
Details:
- Layer: ``230``
- ID: ``A2197CF6``
Parameters:
provider (``str``):
N/A
crypto_currency (``str``):
N/A
address (``str``):
N/A
payment_method (``str``, *optional*):
N/A
base_currency (``str``, *optional*):
N/A
base_amount (``str``, *optional*):
N/A
memo (``str``, *optional*):
N/A
theme (``str``, *optional*):
N/A
success_return_url (``str``, *optional*):
N/A
fail_return_url (``str``, *optional*):
N/A
crypto_amount (``str``, *optional*):
N/A
Returns:
:obj:`OnrampSession <pyrogram.raw.base.OnrampSession>`
"""
__slots__: List[str] = ["provider", "crypto_currency", "address", "payment_method", "base_currency", "base_amount", "memo", "theme", "success_return_url", "fail_return_url", "crypto_amount"]
ID = 0xa2197cf6
QUALNAME = "functions.payments.CreateOnrampSession"
def __init__(self, *, provider: str, crypto_currency: str, address: str, payment_method: Optional[str] = None, base_currency: Optional[str] = None, base_amount: Optional[str] = None, memo: Optional[str] = None, theme: Optional[str] = None, success_return_url: Optional[str] = None, fail_return_url: Optional[str] = None, crypto_amount: Optional[str] = None) -> None:
self.provider = provider # string
self.crypto_currency = crypto_currency # string
self.address = address # string
self.payment_method = payment_method # flags.0?string
self.base_currency = base_currency # flags.1?string
self.base_amount = base_amount # flags.2?string
self.memo = memo # flags.3?string
self.theme = theme # flags.4?string
self.success_return_url = success_return_url # flags.5?string
self.fail_return_url = fail_return_url # flags.6?string
self.crypto_amount = crypto_amount # flags.7?string
@staticmethod
def read(b: BytesIO, *args: Any) -> "CreateOnrampSession":
flags = Int.read(b)
provider = String.read(b)
crypto_currency = String.read(b)
address = String.read(b)
payment_method = String.read(b) if flags & (1 << 0) else None
base_currency = String.read(b) if flags & (1 << 1) else None
base_amount = String.read(b) if flags & (1 << 2) else None
memo = String.read(b) if flags & (1 << 3) else None
theme = String.read(b) if flags & (1 << 4) else None
success_return_url = String.read(b) if flags & (1 << 5) else None
fail_return_url = String.read(b) if flags & (1 << 6) else None
crypto_amount = String.read(b) if flags & (1 << 7) else None
return CreateOnrampSession(provider=provider, crypto_currency=crypto_currency, address=address, payment_method=payment_method, base_currency=base_currency, base_amount=base_amount, memo=memo, theme=theme, success_return_url=success_return_url, fail_return_url=fail_return_url, crypto_amount=crypto_amount)
def write(self, *args) -> bytes:
b = BytesIO()
b.write(Int(self.ID, False))
flags = 0
flags |= (1 << 0) if self.payment_method is not None else 0
flags |= (1 << 1) if self.base_currency is not None else 0
flags |= (1 << 2) if self.base_amount is not None else 0
flags |= (1 << 3) if self.memo is not None else 0
flags |= (1 << 4) if self.theme is not None else 0
flags |= (1 << 5) if self.success_return_url is not None else 0
flags |= (1 << 6) if self.fail_return_url is not None else 0
flags |= (1 << 7) if self.crypto_amount is not None else 0
b.write(Int(flags))
b.write(String(self.provider))
b.write(String(self.crypto_currency))
b.write(String(self.address))
if self.payment_method is not None:
b.write(String(self.payment_method))
if self.base_currency is not None:
b.write(String(self.base_currency))
if self.base_amount is not None:
b.write(String(self.base_amount))
if self.memo is not None:
b.write(String(self.memo))
if self.theme is not None:
b.write(String(self.theme))
if self.success_return_url is not None:
b.write(String(self.success_return_url))
if self.fail_return_url is not None:
b.write(String(self.fail_return_url))
if self.crypto_amount is not None:
b.write(String(self.crypto_amount))
return b.getvalue()