Skip to content

Models

models

Modules (dataclases) used by aiorocket2

Classes

Base

Base class for all models

Methods:
as_dict(keep_enums=False, keep_datetime=False)
Note:
  • To export data use method .as_dict().
  • To just convert data to a dict use built-in function dict()
from_api(j) classmethod

Build model from api data

Info dataclass

Bases: Base

Represents a info entity returned by the xRocket Pay API.

Attributes
name instance-attribute

Name of current app

fee_percents instance-attribute

Fee for incoming transactions

Methods:
from_api(j) classmethod

Build Info from API JSON object.

Balance dataclass

Bases: Base

Represents a balance entity returned by the xRocket Pay API.

Methods:
from_api(j) classmethod

Build Info from API JSON object.

Transfer dataclass

Bases: Base

Represents a transfer entity returned by the xRocket Pay API.

Attributes
id instance-attribute

Transfer ID

tg_user_id instance-attribute
currency instance-attribute

Currency code

amount instance-attribute

Transfer amount. 9 decimal places, others cut off

description instance-attribute

Transfer description

Methods:
from_api(j) classmethod

Build Transfer from API JSON object.

Withdrawal dataclass

Bases: Base

Represents a Withdrawal entity returned by the xRocket Pay API.

Attributes
network instance-attribute

Network code.

address instance-attribute

Withdrawal address

currency instance-attribute

Currency code

amount instance-attribute

Withdrawal amount. 9 decimal places, others cut off

withdrawal_id instance-attribute

Unique withdrawal ID in your system to prevent double spends

status instance-attribute

Withdrawal status

comment instance-attribute

Withdrawal comment

tx_hash instance-attribute

Withdrawal TX hash. Provided only after withdrawal.

Withdrawal TX link. Provided only after withdrawal

Methods:
from_api(j) classmethod

Build Withdrawal from API JSON object.

WithdrawalCoin dataclass

Bases: Base

Represents a WithdrawalCoin entity returned by the xRocket Pay API.

Attributes
code instance-attribute

Crypto code

min_withdrawal instance-attribute

Minimal amount for withdrawals

Methods:
from_api(j) classmethod

Build WithdrawalCoin from API JSON object.

WithdrawalCoinFees dataclass

Bases: Base

Represents a WithdrawalCoinFees entity returned by the xRocket Pay API.

Attributes
network_code instance-attribute

Network code for withdraw

fee instance-attribute

Fee amount

currency instance-attribute

Withdraw fee currency

Methods:
from_api(j) classmethod

Build WithdrawalCoinFees from API JSON object.

Cheque dataclass

Bases: Base

Represents a multi-cheque entity returned by the xRocket Pay API.

Attributes
id instance-attribute

Cheque ID

total instance-attribute

Total amount of cheque (this amount is charged from balance)

per_user instance-attribute

Amount of cheque per user

users instance-attribute

Number of users that can activate your cheque

password instance-attribute

Cheque password

description instance-attribute

Cheque description

send_notifications instance-attribute

send notifications about cheque activation to application cheque webhook or not

ref_program_percents instance-attribute

percentage of cheque that rewarded for referral program

ref_reward_per_user instance-attribute

amount of referral user reward

captcha_enabled instance-attribute

enable / disable cheque captcha

disabled_languages instance-attribute

Disable languages

enabled_countries instance-attribute

Enabled countries

for_premium instance-attribute

Only users with Telegram Premium can activate this cheque

for_new_users_only instance-attribute

Only new users can activate this cheque

linked_wallet instance-attribute

Only users with connected wallets can activate this cheque

activations instance-attribute

How many times cheque is activate

ref_rewards instance-attribute

How many times referral reward is payed

Methods:
from_api(j) classmethod

Build Cheque from API JSON object.

TgResource dataclass

Bases: Base

Represents a TgResourse entity returned by the xRocket Pay API.

Methods:
from_api(j) classmethod

Build Cheque from API JSON object.

PaginatedCheque dataclass

Bases: Base

Represents a PaginatedCheque entity returned by the xRocket Pay API.

Attributes
total instance-attribute

Total times

Methods:
from_api(j) classmethod

Build PaginatedCheque from API JSON object.

DateTimeStr dataclass

Bases: str, Base

Time object, to comfortable get time from the api

Invoice dataclass

Bases: Base

Represents a Invoice entity returned by the xRocket Pay API.

Attributes
id instance-attribute

Invoice ID

amount instance-attribute

Amount of invoice

min_payment instance-attribute

Min payment of invoice

total_activations instance-attribute

Total activations of invoice

activations_left instance-attribute

Activations left of invoice

description instance-attribute

Invoice description

hidden_message instance-attribute

Message that will be displayed after invoice payment

payload instance-attribute

Any data that is attached to invoice

callback_url instance-attribute

url that will be set for Return button after invoice is paid

comments_enabled instance-attribute

Allow comments for invoice

created instance-attribute

(date-time) When invoice was created

paid instance-attribute

(date-time) When invoice was paid

expired_in instance-attribute

Invoice expire time in seconds, max 1 day, 0 - none expired

Methods:
from_api(j) classmethod

Build Invoice from API JSON object.

PaginatedInvoice dataclass

Bases: Base

Represents a PaginatedInvoice entity returned by the xRocket Pay API.

Attributes
total instance-attribute

Total times

Methods:
from_api(j) classmethod

Build PaginatedInvoice from API JSON object.

WithdrawalFee dataclass

Bases: Base

Represents a WithdrawalFee entity returned by the xRocket Pay API.

Attributes
currency instance-attribute

ID of main currency for token

Methods:
from_api(j) classmethod

Build WithdrawalFee from API JSON object.

Currency dataclass

Bases: Base

Represents a Currency entity returned by the xRocket Pay API.

Attributes
currency instance-attribute

ID of currency, use in Rocket Pay Api

name instance-attribute

Name of currency

min_transfer instance-attribute

Minimal amount for transfer

min_cheque instance-attribute

Minimal amount for cheque

min_invoice instance-attribute

Minimal amount for invoice

min_withdraw instance-attribute

Minimal amount for withdrawals

Methods:
from_api(j) classmethod

Build Currency from API JSON object.

Functions:

to_dict(obj, keep_enums=False, keep_datetime=False)

Recursively converts an object to a dictionary suitable for JSON serialization.

Supports: - dataclass: recursively converts all fields. - Enum: returns the enum value if keep_enums=False, otherwise returns the Enum object. - list: recursively converts all elements. - dict: recursively converts all values. - datetime: returns ISO-formatted string if keep_datetime=False, otherwise returns the datetime object.

Parameters:

Name Type Description Default
obj Any

Any object to convert.

required
keep_enums bool

If True, keeps Enum objects, otherwise returns their values.

False
keep_datetime bool

If True, keeps datetime objects, otherwise returns ISO string.

False

Returns:

Name Type Description
dict dict

recursively converted object.