diff --git a/.gitignore b/.gitignore index 035761f9..1a999df3 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ htmlcov .benchmarks -glQiwiApi/t.py +glQiwiApi/playground.py.py *.pem # Distribution / packaging .Python diff --git a/benchmarks/p2p/test_performance.py b/benchmarks/p2p/test_performance.py index 61970c92..21c2cdea 100644 --- a/benchmarks/p2p/test_performance.py +++ b/benchmarks/p2p/test_performance.py @@ -1,5 +1,6 @@ # pip install pytest-benchmark pyqiwip2p import os +from typing import Any, Callable, Dict, Tuple import pytest from pyqiwip2p.AioQiwip2p import AioQiwiP2P @@ -26,7 +27,9 @@ async def create_bill_with_pyQiwiP2P(): @pytest.fixture() -def aio_benchmark(benchmark: BenchmarkFixture) -> BenchmarkFixture: +def aio_benchmark( + benchmark: BenchmarkFixture, +) -> Callable[[Any, Tuple[Any, ...], Dict[str, Any]], None]: import asyncio import threading diff --git a/glQiwiApi/__init__.py b/glQiwiApi/__init__.py index ca4618cb..8aeab5e5 100644 --- a/glQiwiApi/__init__.py +++ b/glQiwiApi/__init__.py @@ -19,7 +19,7 @@ def default_cache_storage() -> CacheStorage: return InMemoryCacheStorage(invalidate_strategy=APIResponsesCacheInvalidationStrategy()) -__version__ = '2.11' +__version__ = '2.12' __all__ = ( # clients diff --git a/glQiwiApi/core/event_fetching/class_based/bill.py b/glQiwiApi/core/event_fetching/class_based/bill.py index e9fa31e8..4c1ae355 100644 --- a/glQiwiApi/core/event_fetching/class_based/bill.py +++ b/glQiwiApi/core/event_fetching/class_based/bill.py @@ -5,7 +5,7 @@ from glQiwiApi.core.event_fetching.class_based.base import Handler from glQiwiApi.qiwi.clients.p2p.types import Bill -from glQiwiApi.types.amount import PlainAmount +from glQiwiApi.types.amount import Amount if TYPE_CHECKING: from glQiwiApi.qiwi.clients.p2p.client import QiwiP2PClient @@ -21,8 +21,8 @@ def bill_id(self) -> str: return self.event.id @property - def bill_sum(self) -> PlainAmount: - return self.event.amount + def bill_sum(self) -> Amount: + return self.event.value @property def pay_url(self) -> str: diff --git a/glQiwiApi/core/event_fetching/class_based/transaction.py b/glQiwiApi/core/event_fetching/class_based/transaction.py index d2295bfa..18ef74d8 100644 --- a/glQiwiApi/core/event_fetching/class_based/transaction.py +++ b/glQiwiApi/core/event_fetching/class_based/transaction.py @@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, cast from glQiwiApi.qiwi.clients.wallet.types.transaction import Transaction -from glQiwiApi.types.amount import AmountWithCurrency +from glQiwiApi.types.amount import Amount from .base import Handler @@ -22,5 +22,5 @@ def transaction_id(self) -> int: return self.event.id @property - def transaction_sum(self) -> AmountWithCurrency: + def transaction_sum(self) -> Amount: return self.event.sum diff --git a/glQiwiApi/core/event_fetching/executor.py b/glQiwiApi/core/event_fetching/executor.py index 10777591..09fa5063 100644 --- a/glQiwiApi/core/event_fetching/executor.py +++ b/glQiwiApi/core/event_fetching/executor.py @@ -174,7 +174,7 @@ async def start_non_blocking_qiwi_api_polling( on_shutdown: Optional[_EventHandlerType] = None, loop: Optional[asyncio.AbstractEventLoop] = None, context: Union[Dict[str, Any], Context, None] = None, -) -> asyncio.Task: +) -> asyncio.Task[None]: if context is None: context = {} executor = PollingExecutor( @@ -312,7 +312,7 @@ def start_polling(self) -> None: # allow graceful shutdown pass - async def start_non_blocking_polling(self) -> asyncio.Task: + async def start_non_blocking_polling(self) -> asyncio.Task[None]: return asyncio.create_task(self._run_infinite_polling()) async def _run_infinite_polling(self) -> None: diff --git a/glQiwiApi/core/event_fetching/webhooks/__init__.py b/glQiwiApi/core/event_fetching/webhooks/__init__.py index 9f602c15..8be0904c 100644 --- a/glQiwiApi/core/event_fetching/webhooks/__init__.py +++ b/glQiwiApi/core/event_fetching/webhooks/__init__.py @@ -3,4 +3,4 @@ from . import app # noqa from .views import QiwiBillWebhookView, QiwiTransactionWebhookView -__all__ = ('QiwiBillWebhookView', 'QiwiTransactionWebhookView', 'BaseWebhookView', 'app.py') +__all__ = ('QiwiBillWebhookView', 'QiwiTransactionWebhookView', 'BaseWebhookView', 'app') diff --git a/glQiwiApi/core/session/holder.py b/glQiwiApi/core/session/holder.py index 4456ed84..16a71694 100644 --- a/glQiwiApi/core/session/holder.py +++ b/glQiwiApi/core/session/holder.py @@ -3,7 +3,7 @@ import abc from dataclasses import dataclass from types import TracebackType -from typing import Any, Dict, Generic, Mapping, Optional, Set, Type, TypeVar, cast +from typing import Any, Dict, Generic, Mapping, Optional, Type, TypeVar, cast import aiohttp from aiohttp import ClientResponse diff --git a/glQiwiApi/qiwi/clients/p2p/client.py b/glQiwiApi/qiwi/clients/p2p/client.py index 3076aef9..d64c1f7d 100644 --- a/glQiwiApi/qiwi/clients/p2p/client.py +++ b/glQiwiApi/qiwi/clients/p2p/client.py @@ -11,7 +11,7 @@ from glQiwiApi.qiwi.clients.p2p.methods.refund_bill import RefundBill from glQiwiApi.qiwi.clients.p2p.methods.reject_p2p_bill import RejectP2PBill from glQiwiApi.qiwi.clients.p2p.types import Bill, Customer, PairOfP2PKeys, RefundedBill -from glQiwiApi.types.amount import PlainAmount +from glQiwiApi.types.amount import Amount from glQiwiApi.utils.compat import remove_suffix from glQiwiApi.utils.deprecated import warn_deprecated from glQiwiApi.utils.validators import String @@ -105,7 +105,7 @@ async def get_bill_status(self, bill_id: str) -> str: :param bill_id: :return: status of bill """ - return (await self.get_bill_by_id(bill_id)).status.value + return (await self.get_bill_by_id(bill_id)).status.amount async def create_p2p_bill( self, @@ -175,7 +175,7 @@ async def refund_bill( self, bill_id: Union[str, int], refund_id: Union[str, int], - json_bill_data: Union[PlainAmount, Dict[str, Union[str, int]]], + json_bill_data: Union[Amount, Dict[str, Union[str, int]]], ) -> RefundedBill: """ The method allows you to make a refund on a paid invoice. diff --git a/glQiwiApi/qiwi/clients/p2p/methods/create_p2p_bill.py b/glQiwiApi/qiwi/clients/p2p/methods/create_p2p_bill.py index 6d2c6514..11dbba47 100644 --- a/glQiwiApi/qiwi/clients/p2p/methods/create_p2p_bill.py +++ b/glQiwiApi/qiwi/clients/p2p/methods/create_p2p_bill.py @@ -1,6 +1,6 @@ import uuid from datetime import datetime, timedelta -from typing import Any, ClassVar, Dict, List, Optional, Union +from typing import Any, ClassVar, Dict, List, Optional from pydantic import Field, validator diff --git a/glQiwiApi/qiwi/clients/p2p/methods/refund_bill.py b/glQiwiApi/qiwi/clients/p2p/methods/refund_bill.py index b7067834..9851d632 100644 --- a/glQiwiApi/qiwi/clients/p2p/methods/refund_bill.py +++ b/glQiwiApi/qiwi/clients/p2p/methods/refund_bill.py @@ -5,7 +5,7 @@ from glQiwiApi.core.abc.api_method import Request from glQiwiApi.qiwi.base import QiwiAPIMethod from glQiwiApi.qiwi.clients.p2p.types import RefundedBill -from glQiwiApi.types.amount import PlainAmount +from glQiwiApi.types.amount import Amount class RefundBill(QiwiAPIMethod[RefundedBill]): @@ -15,11 +15,11 @@ class RefundBill(QiwiAPIMethod[RefundedBill]): bill_id: str = Field(..., path_runtime_value=True) refund_id: str = Field(..., path_runtime_value=True) - json_bill_data: Union[PlainAmount, Dict[str, Union[str, int]]] + json_bill_data: Union[Amount, Dict[str, Union[str, int]]] def build_request(self, **url_format_kw: Any) -> 'Request': json_payload = self.json_bill_data - if isinstance(self.json_bill_data, PlainAmount): + if isinstance(self.json_bill_data, Amount): json_payload = self.json_bill_data.json(encoder=self.Config.json_dumps) # type: ignore return Request( diff --git a/glQiwiApi/qiwi/clients/p2p/types.py b/glQiwiApi/qiwi/clients/p2p/types.py index a84dcc79..496e5862 100644 --- a/glQiwiApi/qiwi/clients/p2p/types.py +++ b/glQiwiApi/qiwi/clients/p2p/types.py @@ -8,7 +8,7 @@ from pydantic import BaseConfig, Extra, Field -from glQiwiApi.types.amount import HashablePlainAmount, PlainAmount +from glQiwiApi.types.amount import Amount, HashableAmount from glQiwiApi.types.base import HashableBase from glQiwiApi.types.exceptions import WebhookSignatureUnverifiedError @@ -39,7 +39,7 @@ class BillError(HashableBase): class Bill(HashableBase): - amount: HashablePlainAmount + amount: HashableAmount status: BillStatus site_id: str = Field(..., alias='siteId') id: str = Field(..., alias='billId') @@ -61,13 +61,13 @@ def invoice_uid(self) -> str: class RefundedBill(HashableBase): """object: RefundedBill""" - amount: PlainAmount + value: Amount datetime: datetime refund_id: str = Field(..., alias='refundId') status: str def __str__(self) -> str: - return f'№{self.refund_id} {self.status} {self.amount} {self.datetime}' + return f'№{self.refund_id} {self.status} {self.value} {self.datetime}' class BillWebhookPayload(Bill): @@ -79,13 +79,13 @@ class BillWebhook(HashableBase): bill: BillWebhookPayload = Field(..., alias='bill') def __repr__(self) -> str: - return f'#{self.bill.id} {self.bill.amount} {self.bill.status} ' + return f'#{self.bill.id} {self.bill.value} {self.bill.status} ' def verify_signature(self, sha256_signature: str, secret_p2p_key: str) -> None: webhook_key = base64.b64decode(bytes(secret_p2p_key, 'utf-8')) bill = self.bill - invoice_params = f'{bill.amount.currency}|{bill.amount.value}|{bill.id}|{bill.site_id}|{bill.status.value}' + invoice_params = f'{bill.value.currency}|{bill.value.value}|{bill.id}|{bill.site_id}|{bill.status.value}' generated_signature = hmac.new( webhook_key, invoice_params.encode('utf-8'), hashlib.sha256 ).hexdigest() diff --git a/glQiwiApi/qiwi/clients/wallet/client.py b/glQiwiApi/qiwi/clients/wallet/client.py index 3acbb581..4aae2f6d 100644 --- a/glQiwiApi/qiwi/clients/wallet/client.py +++ b/glQiwiApi/qiwi/clients/wallet/client.py @@ -49,7 +49,7 @@ from glQiwiApi.qiwi.clients.wallet.methods.webhook.send_test_notification import ( SendTestWebhookNotification, ) -from glQiwiApi.types.amount import AmountWithCurrency +from glQiwiApi.types.amount import Amount from glQiwiApi.types.arbitrary import File from glQiwiApi.utils.validators import PhoneNumber, String @@ -381,7 +381,7 @@ async def get_list_of_balances(self) -> List[Balance]: GetBalances(), phone_number=self.phone_number_without_plus_sign ) - async def get_balance(self, *, account_number: int = 1) -> AmountWithCurrency: + async def get_balance(self, *, account_number: int = 1) -> Amount: resp: List[Balance] = await self._request_service.execute_api_method( GetBalances(), phone_number=self._phone_number, @@ -506,7 +506,7 @@ async def get_cross_rates(self) -> List[CrossRate]: async def payment_by_payment_details( self, - payment_sum: AmountWithCurrency, + payment_sum: Amount, payment_method: PaymentMethod, fields: PaymentDetails, payment_id: Optional[str] = None, diff --git a/glQiwiApi/qiwi/clients/wallet/methods/authenticate_wallet.py b/glQiwiApi/qiwi/clients/wallet/methods/authenticate_wallet.py index 21a4dbd7..594019f5 100644 --- a/glQiwiApi/qiwi/clients/wallet/methods/authenticate_wallet.py +++ b/glQiwiApi/qiwi/clients/wallet/methods/authenticate_wallet.py @@ -1,4 +1,4 @@ -from typing import Any, ClassVar, Dict, Optional +from typing import Any, ClassVar, Dict from pydantic import Field diff --git a/glQiwiApi/qiwi/clients/wallet/methods/get_available_balances.py b/glQiwiApi/qiwi/clients/wallet/methods/get_available_balances.py index d25e82f8..f6353ce7 100644 --- a/glQiwiApi/qiwi/clients/wallet/methods/get_available_balances.py +++ b/glQiwiApi/qiwi/clients/wallet/methods/get_available_balances.py @@ -1,7 +1,6 @@ from typing import ClassVar, List from glQiwiApi.qiwi.base import QiwiAPIMethod -from glQiwiApi.qiwi.clients.wallet.types import Balance from glQiwiApi.qiwi.clients.wallet.types.balance import AvailableBalance diff --git a/glQiwiApi/qiwi/clients/wallet/methods/get_balances.py b/glQiwiApi/qiwi/clients/wallet/methods/get_balances.py index 3f2f086e..fec18e9f 100644 --- a/glQiwiApi/qiwi/clients/wallet/methods/get_balances.py +++ b/glQiwiApi/qiwi/clients/wallet/methods/get_balances.py @@ -2,7 +2,6 @@ from pydantic import parse_obj_as -from glQiwiApi.core.abc.api_method import ReturningType from glQiwiApi.core.session.holder import HTTPResponse from glQiwiApi.qiwi.base import QiwiAPIMethod from glQiwiApi.qiwi.clients.wallet.types import Balance diff --git a/glQiwiApi/qiwi/clients/wallet/methods/get_cross_rates.py b/glQiwiApi/qiwi/clients/wallet/methods/get_cross_rates.py index 78ba164e..33c40a1e 100644 --- a/glQiwiApi/qiwi/clients/wallet/methods/get_cross_rates.py +++ b/glQiwiApi/qiwi/clients/wallet/methods/get_cross_rates.py @@ -2,7 +2,6 @@ from pydantic import parse_obj_as -from glQiwiApi.core.abc.api_method import ReturningType from glQiwiApi.core.session.holder import HTTPResponse from glQiwiApi.qiwi.base import QiwiAPIMethod from glQiwiApi.qiwi.clients.wallet.types import CrossRate diff --git a/glQiwiApi/qiwi/clients/wallet/methods/get_limits.py b/glQiwiApi/qiwi/clients/wallet/methods/get_limits.py index 7e9da164..fc966f03 100644 --- a/glQiwiApi/qiwi/clients/wallet/methods/get_limits.py +++ b/glQiwiApi/qiwi/clients/wallet/methods/get_limits.py @@ -1,6 +1,6 @@ -from typing import Any, ClassVar, Dict, List, Sequence +from typing import Any, ClassVar, Dict, Sequence -from glQiwiApi.core.abc.api_method import Request, ReturningType +from glQiwiApi.core.abc.api_method import Request from glQiwiApi.core.session.holder import HTTPResponse from glQiwiApi.qiwi.base import QiwiAPIMethod from glQiwiApi.qiwi.clients.wallet.types import Limit diff --git a/glQiwiApi/qiwi/clients/wallet/methods/payment_by_details.py b/glQiwiApi/qiwi/clients/wallet/methods/payment_by_details.py index e70558f0..520d0983 100644 --- a/glQiwiApi/qiwi/clients/wallet/methods/payment_by_details.py +++ b/glQiwiApi/qiwi/clients/wallet/methods/payment_by_details.py @@ -6,7 +6,7 @@ from glQiwiApi.core.abc.api_method import RuntimeValue from glQiwiApi.qiwi.base import QiwiAPIMethod from glQiwiApi.qiwi.clients.wallet.types import PaymentDetails, PaymentInfo, PaymentMethod -from glQiwiApi.types.amount import AmountWithCurrency +from glQiwiApi.types.amount import Amount class MakePaymentByDetails(QiwiAPIMethod[PaymentInfo]): @@ -20,7 +20,7 @@ class MakePaymentByDetails(QiwiAPIMethod[PaymentInfo]): 'fields': RuntimeValue(), } - payment_sum: AmountWithCurrency = Field(..., scheme_path='sum') + payment_sum: Amount = Field(..., scheme_path='sum') payment_method: PaymentMethod = Field(..., scheme_path='paymentMethod') details: PaymentDetails = Field(..., scheme_path='fields') payment_id: Optional[str] = Field(None, scheme_path='id') diff --git a/glQiwiApi/qiwi/clients/wallet/methods/predict_comission.py b/glQiwiApi/qiwi/clients/wallet/methods/predict_comission.py index d11a75c3..005e65ed 100644 --- a/glQiwiApi/qiwi/clients/wallet/methods/predict_comission.py +++ b/glQiwiApi/qiwi/clients/wallet/methods/predict_comission.py @@ -1,4 +1,4 @@ -from typing import Any, ClassVar, Dict, Optional, Union +from typing import Any, ClassVar, Dict, Union from pydantic import Field diff --git a/glQiwiApi/qiwi/clients/wallet/methods/qiwi_master/block_card.py b/glQiwiApi/qiwi/clients/wallet/methods/qiwi_master/block_card.py index b5295146..b5f8b738 100644 --- a/glQiwiApi/qiwi/clients/wallet/methods/qiwi_master/block_card.py +++ b/glQiwiApi/qiwi/clients/wallet/methods/qiwi_master/block_card.py @@ -3,7 +3,6 @@ from pydantic import Field -from glQiwiApi.core.abc.api_method import ReturningType from glQiwiApi.core.session.holder import HTTPResponse from glQiwiApi.qiwi.base import QiwiAPIMethod diff --git a/glQiwiApi/qiwi/clients/wallet/methods/reveal_card_id.py b/glQiwiApi/qiwi/clients/wallet/methods/reveal_card_id.py index bdbb8baf..55489628 100644 --- a/glQiwiApi/qiwi/clients/wallet/methods/reveal_card_id.py +++ b/glQiwiApi/qiwi/clients/wallet/methods/reveal_card_id.py @@ -1,12 +1,10 @@ -from json import JSONDecodeError from typing import Any, ClassVar from pydantic import Field -from glQiwiApi.core.abc.api_method import Request, ReturningType +from glQiwiApi.core.abc.api_method import Request from glQiwiApi.core.session.holder import HTTPResponse from glQiwiApi.qiwi.base import QiwiAPIMethod -from glQiwiApi.qiwi.exceptions import QiwiAPIError try: from orjson import JSONDecodeError as OrjsonDecodeError diff --git a/glQiwiApi/qiwi/clients/wallet/methods/transfer_money_to_card.py b/glQiwiApi/qiwi/clients/wallet/methods/transfer_money_to_card.py index 5ebca939..7325ef71 100644 --- a/glQiwiApi/qiwi/clients/wallet/methods/transfer_money_to_card.py +++ b/glQiwiApi/qiwi/clients/wallet/methods/transfer_money_to_card.py @@ -1,5 +1,5 @@ import time -from typing import Any, ClassVar, Dict, Union +from typing import Any, ClassVar, Dict from pydantic import Field diff --git a/glQiwiApi/qiwi/clients/wallet/methods/webhook/get_webhook_secret.py b/glQiwiApi/qiwi/clients/wallet/methods/webhook/get_webhook_secret.py index d1eae3c9..bff176a8 100644 --- a/glQiwiApi/qiwi/clients/wallet/methods/webhook/get_webhook_secret.py +++ b/glQiwiApi/qiwi/clients/wallet/methods/webhook/get_webhook_secret.py @@ -2,7 +2,6 @@ from pydantic import Field -from glQiwiApi.core.abc.api_method import ReturningType from glQiwiApi.core.session.holder import HTTPResponse from glQiwiApi.qiwi.base import QiwiAPIMethod diff --git a/glQiwiApi/qiwi/clients/wallet/types/account_info.py b/glQiwiApi/qiwi/clients/wallet/types/account_info.py index 5278ec2c..34c64f5a 100644 --- a/glQiwiApi/qiwi/clients/wallet/types/account_info.py +++ b/glQiwiApi/qiwi/clients/wallet/types/account_info.py @@ -2,11 +2,10 @@ from datetime import datetime from typing import Any, Dict, List, Optional, Union -from pydantic import Field, validator +from pydantic import Field -from glQiwiApi.types.amount import AmountWithCurrency, CurrencyModel +from glQiwiApi.types.amount import Amount, Currency from glQiwiApi.types.base import Base -from glQiwiApi.utils.currency_util import Currency class PassInfo(Base): @@ -48,7 +47,7 @@ class AuthInfo(Base): class SmsNotification(Base): """object: SmsNotification""" - price: AmountWithCurrency + price: Amount enabled: bool active: bool end_date: Optional[datetime] = Field(None, alias='endDate') @@ -95,7 +94,7 @@ class ContractInfo(Base): class UserInfo(Base): """object: UserInfo""" - default_pay_currency: CurrencyModel = Field(..., alias='defaultPayCurrency') + default_pay_currency: Currency = Field(..., alias='defaultPayCurrency') default_pay_source: Optional[int] = Field(None, alias='defaultPaySource') default_pay_account_alias: Optional[str] = Field(None, alias='defaultPayAccountAlias') email: Optional[str] = None @@ -105,12 +104,6 @@ class UserInfo(Base): phone_hash: str = Field(alias='phoneHash') promo_enabled: Optional[bool] = Field(None, alias='promoEnabled') - @validator('default_pay_currency', pre=True) - def humanize_pay_currency(cls, v): # type: ignore - if not isinstance(v, int): - return v - return Currency.get(str(v)) - class UserProfile(Base): auth_info: Optional[AuthInfo] = Field(None, alias='authInfo') diff --git a/glQiwiApi/qiwi/clients/wallet/types/balance.py b/glQiwiApi/qiwi/clients/wallet/types/balance.py index f4280681..6666dc5f 100644 --- a/glQiwiApi/qiwi/clients/wallet/types/balance.py +++ b/glQiwiApi/qiwi/clients/wallet/types/balance.py @@ -1,15 +1,14 @@ -from typing import Any, Dict, Optional, Union +from typing import Any, Dict, Optional -from pydantic import Field, validator +from pydantic import Field -from glQiwiApi.types.amount import AmountWithCurrency, CurrencyModel +from glQiwiApi.types.amount import Amount, Currency from glQiwiApi.types.base import HashableBase -from glQiwiApi.utils.currency_util import Currency class AvailableBalance(HashableBase): alias: str - currency: Union[str, CurrencyModel] + currency: Currency class Balance(HashableBase): @@ -20,13 +19,7 @@ class Balance(HashableBase): fs_alias: str = Field(alias='fsAlias') bank_alias: str = Field(alias='bankAlias') has_balance: bool = Field(alias='hasBalance') - balance: Optional[AmountWithCurrency] = None - currency: CurrencyModel + balance: Optional[Amount] = None + currency: Currency account_type: Optional[Dict[str, Any]] = Field(None, alias='type') is_default_account: bool = Field(alias='defaultAccount') - - @validator('currency', pre=True) - def humanize_pay_currency(cls, v): # type: ignore - if not isinstance(v, int): - return v - return Currency.get(str(v)) diff --git a/glQiwiApi/qiwi/clients/wallet/types/commission.py b/glQiwiApi/qiwi/clients/wallet/types/commission.py index 18228928..1d6aab28 100644 --- a/glQiwiApi/qiwi/clients/wallet/types/commission.py +++ b/glQiwiApi/qiwi/clients/wallet/types/commission.py @@ -1,12 +1,12 @@ from pydantic import Field -from glQiwiApi.types.amount import AmountWithCurrency +from glQiwiApi.types.amount import Amount from glQiwiApi.types.base import Base class Commission(Base): provider_id: int = Field(alias='providerId') - withdraw_sum: AmountWithCurrency = Field(alias='withdrawSum') - enrollment_sum: AmountWithCurrency = Field(alias='enrollmentSum') - qiwi_commission: AmountWithCurrency = Field(alias='qwCommission') + withdraw_sum: Amount = Field(alias='withdrawSum') + enrollment_sum: Amount = Field(alias='enrollmentSum') + qiwi_commission: Amount = Field(alias='qwCommission') withdraw_to_enrollment_rate: int = Field(alias='withdrawToEnrollmentRate') diff --git a/glQiwiApi/qiwi/clients/wallet/types/limit.py b/glQiwiApi/qiwi/clients/wallet/types/limit.py index 356faff2..a0505836 100644 --- a/glQiwiApi/qiwi/clients/wallet/types/limit.py +++ b/glQiwiApi/qiwi/clients/wallet/types/limit.py @@ -1,11 +1,10 @@ from datetime import datetime from typing import Union -from pydantic import Field, validator +from pydantic import Field -from glQiwiApi.types.amount import CurrencyModel +from glQiwiApi.types.amount import Currency from glQiwiApi.types.base import Base -from glQiwiApi.utils.currency_util import Currency class Interval(Base): @@ -18,18 +17,12 @@ class Interval(Base): class Limit(Base): """object: Limit""" - currency: CurrencyModel + currency: Currency rest: Union[float, int] max_limit: Union[float, int] = Field(alias='max') spent: Union[float, int] interval: Interval limit_type: str = Field(alias='type') - @validator('currency', pre=True) - def currency_validate(cls, v): # type: ignore - if not isinstance(v, str): - raise ValueError() - return Currency.get(v) - __all__ = ['Limit'] diff --git a/glQiwiApi/qiwi/clients/wallet/types/other.py b/glQiwiApi/qiwi/clients/wallet/types/other.py index 5226360c..55e35a9f 100644 --- a/glQiwiApi/qiwi/clients/wallet/types/other.py +++ b/glQiwiApi/qiwi/clients/wallet/types/other.py @@ -1,28 +1,16 @@ -from typing import Union +from pydantic import Field -from pydantic import Field, validator - -from glQiwiApi.types.amount import CurrencyModel +from glQiwiApi.types.amount import Currency from glQiwiApi.types.base import Base, HashableBase -from glQiwiApi.utils.currency_util import Currency class CrossRate(HashableBase): """Курс валюты""" - rate_from: Union[str, CurrencyModel] = Field(..., alias='from') - rate_to: Union[str, CurrencyModel] = Field(..., alias='to') + rate_from: Currency = Field(..., alias='from') + rate_to: Currency = Field(..., alias='to') rate: float - @validator('rate_from', 'rate_to', pre=True) - def humanize_rates(cls, v): # type: ignore - if not isinstance(v, str): - return v - cur = Currency.get(v) - if not cur: - return v - return cur - class PaymentMethod(Base): payment_type: str diff --git a/glQiwiApi/qiwi/clients/wallet/types/payment_info.py b/glQiwiApi/qiwi/clients/wallet/types/payment_info.py index 279443fd..9b849699 100644 --- a/glQiwiApi/qiwi/clients/wallet/types/payment_info.py +++ b/glQiwiApi/qiwi/clients/wallet/types/payment_info.py @@ -2,7 +2,7 @@ from pydantic import Field -from glQiwiApi.types.amount import AmountWithCurrency +from glQiwiApi.types.amount import Amount from glQiwiApi.types.base import Base @@ -29,7 +29,7 @@ class PaymentInfo(Base): """object: PaymentInfo""" id: int - amount: AmountWithCurrency = Field(..., alias='sum') + value: Amount = Field(..., alias='sum') terms: str fields: Fields source: str @@ -44,7 +44,7 @@ class PaymentMethod(Base): class QiwiPayment(Base): id: int - sum: AmountWithCurrency + sum: Amount method: PaymentMethod = Field(..., alias='paymentMethod') fields: Dict[Any, Any] comment: Optional[str] = None diff --git a/glQiwiApi/qiwi/clients/wallet/types/qiwi_master.py b/glQiwiApi/qiwi/clients/wallet/types/qiwi_master.py index 6204ac9c..ae256450 100644 --- a/glQiwiApi/qiwi/clients/wallet/types/qiwi_master.py +++ b/glQiwiApi/qiwi/clients/wallet/types/qiwi_master.py @@ -5,7 +5,7 @@ from pydantic import Field -from glQiwiApi.types.amount import AmountWithCurrency +from glQiwiApi.types.amount import Amount from glQiwiApi.types.base import Base, HashableBase @@ -19,7 +19,7 @@ class OrderDetails(Base): order_id: str = Field(..., alias='id') card_alias: str = Field(..., alias='cardAlias') status: str - price: Optional[AmountWithCurrency] = None + price: Optional[Amount] = None card_id: Optional[str] = Field(alias='cardId', default=None) @@ -41,7 +41,7 @@ class CardCredentials(Base): class Requisite(Base): - name: str + value: str value: str @@ -58,7 +58,7 @@ class CardInfo(Base): id_: int = Field(..., alias='id') name: str alias: str - price: AmountWithCurrency + price: Amount period: str type_: str = Field(..., alias='type') details: Details @@ -66,5 +66,5 @@ class CardInfo(Base): class Card(HashableBase): details: CardCredentials = Field(..., alias='qvx') - balance: Optional[AmountWithCurrency] = None + balance: Optional[Amount] = None info: CardInfo diff --git a/glQiwiApi/qiwi/clients/wallet/types/stats.py b/glQiwiApi/qiwi/clients/wallet/types/stats.py index aa29834a..b4c1fe39 100644 --- a/glQiwiApi/qiwi/clients/wallet/types/stats.py +++ b/glQiwiApi/qiwi/clients/wallet/types/stats.py @@ -2,15 +2,15 @@ from pydantic import Field -from glQiwiApi.types.amount import AmountWithCurrency +from glQiwiApi.types.amount import Amount from glQiwiApi.types.base import Base class Statistic(Base): """object: Statistic""" - incoming: List[AmountWithCurrency] = Field(alias='incomingTotal') - out: List[AmountWithCurrency] = Field(alias='outgoingTotal') + incoming: List[Amount] = Field(alias='incomingTotal') + out: List[Amount] = Field(alias='outgoingTotal') __all__ = ['Statistic'] diff --git a/glQiwiApi/qiwi/clients/wallet/types/transaction.py b/glQiwiApi/qiwi/clients/wallet/types/transaction.py index b450efd8..2fc1f006 100644 --- a/glQiwiApi/qiwi/clients/wallet/types/transaction.py +++ b/glQiwiApi/qiwi/clients/wallet/types/transaction.py @@ -6,7 +6,7 @@ from pydantic import Field -from glQiwiApi.types.amount import AmountWithCurrency +from glQiwiApi.types.amount import Amount from glQiwiApi.types.base import Base @@ -100,13 +100,13 @@ class Transaction(Base): Для пополнений - номер отправителя, терминала или название агента пополнения кошелька """ - sum: AmountWithCurrency + sum: Amount """Данные о сумме платежа или пополнения.""" - commission: AmountWithCurrency + commission: Amount """Данные о комиссии""" - total: AmountWithCurrency + total: Amount """Общие данные о платеже в формате объекта Sum""" provider: Provider diff --git a/glQiwiApi/qiwi/clients/wallet/types/webhooks.py b/glQiwiApi/qiwi/clients/wallet/types/webhooks.py index 3dd7f887..9def24b4 100644 --- a/glQiwiApi/qiwi/clients/wallet/types/webhooks.py +++ b/glQiwiApi/qiwi/clients/wallet/types/webhooks.py @@ -7,7 +7,7 @@ from pydantic import Field, root_validator -from glQiwiApi.types.amount import HashableSum +from glQiwiApi.types.amount import HashableAmount from glQiwiApi.types.base import Base, HashableBase from glQiwiApi.types.exceptions import WebhookSignatureUnverifiedError @@ -25,9 +25,9 @@ class WebhookPayment(HashableBase): status: str = Field(..., alias='status') txn_id: str = Field(..., alias='txnId') type: str = Field(..., alias='type') - commission: Optional[HashableSum] = Field(default=None, alias='calc_commission') - sum: HashableSum = Field(..., alias='sum') - total: HashableSum = Field(..., alias='total') + commission: Optional[HashableAmount] = Field(default=None, alias='calc_commission') + sum: HashableAmount = Field(..., alias='sum') + total: HashableAmount = Field(..., alias='total') class TransactionWebhook(HashableBase): diff --git a/glQiwiApi/qiwi/clients/wrapper.py b/glQiwiApi/qiwi/clients/wrapper.py index b78036f0..0e41a43c 100644 --- a/glQiwiApi/qiwi/clients/wrapper.py +++ b/glQiwiApi/qiwi/clients/wrapper.py @@ -35,7 +35,7 @@ from glQiwiApi.qiwi.clients.wallet.types.balance import AvailableBalance from glQiwiApi.qiwi.clients.wallet.types.mobile_operator import MobileOperator from glQiwiApi.qiwi.clients.wallet.types.nickname import NickName -from glQiwiApi.types.amount import AmountWithCurrency, PlainAmount +from glQiwiApi.types.amount import Amount from glQiwiApi.types.arbitrary import File from glQiwiApi.utils.deprecated import deprecated @@ -58,7 +58,7 @@ def __init__( self._qiwi_wallet = QiwiWallet(api_access_token or '', phone_number) self._p2p_client = QiwiP2PClient(secret_p2p or '', shim_server_url=shim_server_url) - async def get_balance(self, *, account_number: int = 1) -> AmountWithCurrency: + async def get_balance(self, *, account_number: int = 1) -> Amount: return await self._qiwi_wallet.get_balance(account_number=account_number) async def get_nickname(self) -> NickName: @@ -164,7 +164,7 @@ async def check_transaction( """ def obsolete_check_transaction(txn: Transaction) -> bool: - if txn.sum.amount < amount or txn.type != transaction_type.value: + if txn.sum.value < amount or txn.type != transaction_type.value: return False if txn.comment == comment and txn.to_account == sender: return True @@ -394,7 +394,7 @@ async def get_cross_rates(self) -> List[CrossRate]: async def payment_by_payment_details( self, - payment_sum: AmountWithCurrency, + payment_sum: Amount, payment_method: PaymentMethod, fields: PaymentDetails, payment_id: Optional[str] = None, @@ -605,7 +605,7 @@ async def refund_bill( self, bill_id: Union[str, int], refund_id: Union[str, int], - json_bill_data: Union[PlainAmount, Dict[str, Union[str, int]]], + json_bill_data: Union[Amount, Dict[str, Union[str, int]]], ) -> RefundedBill: """ The method allows you to make a refund on a paid invoice. diff --git a/glQiwiApi/types/_currencies.py b/glQiwiApi/types/_currencies.py deleted file mode 100644 index 5e45d7e9..00000000 --- a/glQiwiApi/types/_currencies.py +++ /dev/null @@ -1,1354 +0,0 @@ -from glQiwiApi.types.amount import CurrencyModel - -codes_number = { - '008': 'ALL', - '012': 'DZD', - '032': 'ARS', - '036': 'AUD', - '044': 'BSD', - '048': 'BHD', - '050': 'BDT', - '051': 'AMD', - '052': 'BBD', - '060': 'BMD', - '064': 'BTN', - '068': 'BOB', - '072': 'BWP', - '084': 'BZD', - '090': 'SBD', - '096': 'BND', - '104': 'MMK', - '108': 'BIF', - '116': 'KHR', - '124': 'CAD', - '132': 'CVE', - '136': 'KYD', - '144': 'LKR', - '152': 'CLP', - '156': 'CNY', - '170': 'COP', - '174': 'KMF', - '188': 'CRC', - '191': 'HRK', - '192': 'CUP', - '203': 'CZK', - '208': 'DKK', - '214': 'DOP', - '222': 'SVC', - '230': 'ETB', - '232': 'ERN', - '238': 'FKP', - '242': 'FJD', - '262': 'DJF', - '270': 'GMD', - '292': 'GIP', - '320': 'GTQ', - '324': 'GNF', - '328': 'GYD', - '332': 'HTG', - '340': 'HNL', - '344': 'HKD', - '348': 'HUF', - '352': 'ISK', - '356': 'INR', - '360': 'IDR', - '364': 'IRR', - '368': 'IQD', - '376': 'ILS', - '388': 'JMD', - '392': 'JPY', - '398': 'KZT', - '400': 'JOD', - '404': 'KES', - '408': 'KPW', - '410': 'KRW', - '414': 'KWD', - '417': 'KGS', - '418': 'LAK', - '422': 'LBP', - '426': 'LSL', - '430': 'LRD', - '434': 'LYD', - '446': 'MOP', - '454': 'MWK', - '458': 'MYR', - '462': 'MVR', - '480': 'MUR', - '484': 'MXN', - '496': 'MNT', - '498': 'MDL', - '504': 'MAD', - '512': 'OMR', - '516': 'NAD', - '524': 'NPR', - '532': 'ANG', - '533': 'AWG', - '548': 'VUV', - '554': 'NZD', - '558': 'NIO', - '566': 'NGN', - '578': 'NOK', - '586': 'PKR', - '590': 'PAB', - '598': 'PGK', - '600': 'PYG', - '604': 'PEN', - '608': 'PHP', - '634': 'QAR', - '643': 'RUB', - '646': 'RWF', - '654': 'SHP', - '682': 'SAR', - '690': 'SCR', - '694': 'SLL', - '702': 'SGD', - '704': 'VND', - '706': 'SOS', - '710': 'ZAR', - '728': 'SSP', - '748': 'SZL', - '752': 'SEK', - '756': 'CHF', - '760': 'SYP', - '764': 'THB', - '776': 'TOP', - '780': 'TTD', - '784': 'AED', - '788': 'TND', - '800': 'UGX', - '807': 'MKD', - '818': 'EGP', - '826': 'GBP', - '834': 'TZS', - '840': 'USD', - '858': 'UYU', - '860': 'UZS', - '882': 'WST', - '886': 'YER', - '901': 'TWD', - '929': 'MRU', - '930': 'STN', - '931': 'CUC', - '932': 'ZWL', - '934': 'TMT', - '936': 'GHS', - '937': 'VEF', - '938': 'SDG', - '940': 'UYI', - '941': 'RSD', - '943': 'MZN', - '944': 'AZN', - '946': 'RON', - '947': 'CHE', - '948': 'CHW', - '949': 'TRY', - '950': 'XAF', - '951': 'XCD', - '952': 'XOF', - '953': 'XPF', - '960': 'XDR', - '965': 'XUA', - '967': 'ZMW', - '968': 'SRD', - '969': 'MGA', - '970': 'COU', - '971': 'AFN', - '972': 'TJS', - '973': 'AOA', - '974': 'BYR', - '975': 'BGN', - '976': 'CDF', - '977': 'BAM', - '978': 'EUR', - '979': 'MXV', - '980': 'UAH', - '981': 'GEL', - '984': 'BOV', - '985': 'PLN', - '986': 'BRL', - '990': 'CLF', - '994': 'XSU', - '997': 'USN', -} -described = { - 'AED': CurrencyModel( - code='AED', - decimal_digits=2, - name='United Arab Emirates Dirham', - name_plural='UAE dirhams', - rounding=0, - symbol='AED', - symbol_native='د.إ.\u200f', - isoformat='784', - ), - 'AFN': CurrencyModel( - code='AFN', - decimal_digits=0, - name='Afghan Afghani', - name_plural='Afghan Afghanis', - rounding=0, - symbol='Af', - symbol_native='؋', - isoformat='971', - ), - 'ALL': CurrencyModel( - code='ALL', - decimal_digits=0, - name='Albanian Lek', - name_plural='Albanian lekë', - rounding=0, - symbol='ALL', - symbol_native='Lek', - isoformat='008', - ), - 'AMD': CurrencyModel( - code='AMD', - decimal_digits=0, - name='Armenian Dram', - name_plural='Armenian drams', - rounding=0, - symbol='AMD', - symbol_native='դր.', - isoformat='051', - ), - 'ARS': CurrencyModel( - code='ARS', - decimal_digits=2, - name='Argentine Peso', - name_plural='Argentine pesos', - rounding=0, - symbol='AR$', - symbol_native='$', - isoformat='032', - ), - 'AUD': CurrencyModel( - code='AUD', - decimal_digits=2, - name='Australian Dollar', - name_plural='Australian dollars', - rounding=0, - symbol='AU$', - symbol_native='$', - isoformat='036', - ), - 'AZN': CurrencyModel( - code='AZN', - decimal_digits=2, - name='Azerbaijani Manat', - name_plural='Azerbaijani manats', - rounding=0, - symbol='man.', - symbol_native='ман.', - isoformat='944', - ), - 'BAM': CurrencyModel( - code='BAM', - decimal_digits=2, - name='Bosnia-Herzegovina Convertible Mark', - name_plural='Bosnia-Herzegovina convertible marks', - rounding=0, - symbol='KM', - symbol_native='KM', - isoformat='977', - ), - 'BDT': CurrencyModel( - code='BDT', - decimal_digits=2, - name='Bangladeshi Taka', - name_plural='Bangladeshi takas', - rounding=0, - symbol='Tk', - symbol_native='৳', - isoformat='050', - ), - 'BGN': CurrencyModel( - code='BGN', - decimal_digits=2, - name='Bulgarian Lev', - name_plural='Bulgarian leva', - rounding=0, - symbol='BGN', - symbol_native='лв.', - isoformat='975', - ), - 'BHD': CurrencyModel( - code='BHD', - decimal_digits=3, - name='Bahraini Dinar', - name_plural='Bahraini dinars', - rounding=0, - symbol='BD', - symbol_native='د.ب.\u200f', - isoformat='048', - ), - 'BIF': CurrencyModel( - code='BIF', - decimal_digits=0, - name='Burundian Franc', - name_plural='Burundian francs', - rounding=0, - symbol='FBu', - symbol_native='FBu', - isoformat='108', - ), - 'BND': CurrencyModel( - code='BND', - decimal_digits=2, - name='Brunei Dollar', - name_plural='Brunei dollars', - rounding=0, - symbol='BN$', - symbol_native='$', - isoformat='096', - ), - 'BOB': CurrencyModel( - code='BOB', - decimal_digits=2, - name='Bolivian Boliviano', - name_plural='Bolivian bolivianos', - rounding=0, - symbol='Bs', - symbol_native='Bs', - isoformat='068', - ), - 'BRL': CurrencyModel( - code='BRL', - decimal_digits=2, - name='Brazilian Real', - name_plural='Brazilian reals', - rounding=0, - symbol='R$', - symbol_native='R$', - isoformat='986', - ), - 'BWP': CurrencyModel( - code='BWP', - decimal_digits=2, - name='Botswanan Pula', - name_plural='Botswanan pulas', - rounding=0, - symbol='BWP', - symbol_native='P', - isoformat='072', - ), - 'BYR': CurrencyModel( - code='BYR', - decimal_digits=0, - name='Belarusian Ruble', - name_plural='Belarusian rubles', - rounding=0, - symbol='BYR', - symbol_native='BYR', - isoformat='974', - ), - 'BZD': CurrencyModel( - code='BZD', - decimal_digits=2, - name='Belize Dollar', - name_plural='Belize dollars', - rounding=0, - symbol='BZ$', - symbol_native='$', - isoformat='084', - ), - 'CAD': CurrencyModel( - code='CAD', - decimal_digits=2, - name='Canadian Dollar', - name_plural='Canadian dollars', - rounding=0, - symbol='CA$', - symbol_native='$', - isoformat='124', - ), - 'CDF': CurrencyModel( - code='CDF', - decimal_digits=2, - name='Congolese Franc', - name_plural='Congolese francs', - rounding=0, - symbol='CDF', - symbol_native='FrCD', - isoformat='976', - ), - 'CHF': CurrencyModel( - code='CHF', - decimal_digits=2, - name='Swiss Franc', - name_plural='Swiss francs', - rounding=0.05, - symbol='CHF', - symbol_native='CHF', - isoformat='756', - ), - 'CLP': CurrencyModel( - code='CLP', - decimal_digits=0, - name='Chilean Peso', - name_plural='Chilean pesos', - rounding=0, - symbol='CL$', - symbol_native='$', - isoformat='152', - ), - 'CNY': CurrencyModel( - code='CNY', - decimal_digits=2, - name='Chinese Yuan', - name_plural='Chinese yuan', - rounding=0, - symbol='CN¥', - symbol_native='CN¥', - isoformat='156', - ), - 'COP': CurrencyModel( - code='COP', - decimal_digits=0, - name='Colombian Peso', - name_plural='Colombian pesos', - rounding=0, - symbol='CO$', - symbol_native='$', - isoformat='170', - ), - 'CRC': CurrencyModel( - code='CRC', - decimal_digits=0, - name='Costa Rican Colón', - name_plural='Costa Rican colóns', - rounding=0, - symbol='₡', - symbol_native='₡', - isoformat='188', - ), - 'CVE': CurrencyModel( - code='CVE', - decimal_digits=2, - name='Cape Verdean Escudo', - name_plural='Cape Verdean escudos', - rounding=0, - symbol='CV$', - symbol_native='CV$', - isoformat='132', - ), - 'CZK': CurrencyModel( - code='CZK', - decimal_digits=2, - name='Czech Republic Koruna', - name_plural='Czech Republic korunas', - rounding=0, - symbol='Kč', - symbol_native='Kč', - isoformat='203', - ), - 'DJF': CurrencyModel( - code='DJF', - decimal_digits=0, - name='Djiboutian Franc', - name_plural='Djiboutian francs', - rounding=0, - symbol='Fdj', - symbol_native='Fdj', - isoformat='262', - ), - 'DKK': CurrencyModel( - code='DKK', - decimal_digits=2, - name='Danish Krone', - name_plural='Danish kroner', - rounding=0, - symbol='Dkr', - symbol_native='kr', - isoformat='208', - ), - 'DOP': CurrencyModel( - code='DOP', - decimal_digits=2, - name='Dominican Peso', - name_plural='Dominican pesos', - rounding=0, - symbol='RD$', - symbol_native='RD$', - isoformat='214', - ), - 'DZD': CurrencyModel( - code='DZD', - decimal_digits=2, - name='Algerian Dinar', - name_plural='Algerian dinars', - rounding=0, - symbol='DA', - symbol_native='د.ج.\u200f', - isoformat='012', - ), - 'EEK': CurrencyModel( - code='EEK', - decimal_digits=2, - name='Estonian Kroon', - name_plural='Estonian kroons', - rounding=0, - symbol='Ekr', - symbol_native='kr', - isoformat=None, - ), - 'EGP': CurrencyModel( - code='EGP', - decimal_digits=2, - name='Egyptian Pound', - name_plural='Egyptian pounds', - rounding=0, - symbol='EGP', - symbol_native='ج.م.\u200f', - isoformat='818', - ), - 'ERN': CurrencyModel( - code='ERN', - decimal_digits=2, - name='Eritrean Nakfa', - name_plural='Eritrean nakfas', - rounding=0, - symbol='Nfk', - symbol_native='Nfk', - isoformat='232', - ), - 'ETB': CurrencyModel( - code='ETB', - decimal_digits=2, - name='Ethiopian Birr', - name_plural='Ethiopian birrs', - rounding=0, - symbol='Br', - symbol_native='Br', - isoformat='230', - ), - 'EUR': CurrencyModel( - code='EUR', - decimal_digits=2, - name='Euro', - name_plural='euros', - rounding=0, - symbol='€', - symbol_native='€', - isoformat='978', - ), - 'GBP': CurrencyModel( - code='GBP', - decimal_digits=2, - name='British Pound Sterling', - name_plural='British pounds sterling', - rounding=0, - symbol='£', - symbol_native='£', - isoformat='826', - ), - 'GEL': CurrencyModel( - code='GEL', - decimal_digits=2, - name='Georgian Lari', - name_plural='Georgian laris', - rounding=0, - symbol='GEL', - symbol_native='GEL', - isoformat='981', - ), - 'GHS': CurrencyModel( - code='GHS', - decimal_digits=2, - name='Ghanaian Cedi', - name_plural='Ghanaian cedis', - rounding=0, - symbol='GH₵', - symbol_native='GH₵', - isoformat='936', - ), - 'GNF': CurrencyModel( - code='GNF', - decimal_digits=0, - name='Guinean Franc', - name_plural='Guinean francs', - rounding=0, - symbol='FG', - symbol_native='FG', - isoformat='324', - ), - 'GTQ': CurrencyModel( - code='GTQ', - decimal_digits=2, - name='Guatemalan Quetzal', - name_plural='Guatemalan quetzals', - rounding=0, - symbol='GTQ', - symbol_native='Q', - isoformat='320', - ), - 'HKD': CurrencyModel( - code='HKD', - decimal_digits=2, - name='Hong Kong Dollar', - name_plural='Hong Kong dollars', - rounding=0, - symbol='HK$', - symbol_native='$', - isoformat='344', - ), - 'HNL': CurrencyModel( - code='HNL', - decimal_digits=2, - name='Honduran Lempira', - name_plural='Honduran lempiras', - rounding=0, - symbol='HNL', - symbol_native='L', - isoformat='340', - ), - 'HRK': CurrencyModel( - code='HRK', - decimal_digits=2, - name='Croatian Kuna', - name_plural='Croatian kunas', - rounding=0, - symbol='kn', - symbol_native='kn', - isoformat='191', - ), - 'HUF': CurrencyModel( - code='HUF', - decimal_digits=0, - name='Hungarian Forint', - name_plural='Hungarian forints', - rounding=0, - symbol='Ft', - symbol_native='Ft', - isoformat='348', - ), - 'IDR': CurrencyModel( - code='IDR', - decimal_digits=0, - name='Indonesian Rupiah', - name_plural='Indonesian rupiahs', - rounding=0, - symbol='Rp', - symbol_native='Rp', - isoformat='360', - ), - 'ILS': CurrencyModel( - code='ILS', - decimal_digits=2, - name='Israeli New Sheqel', - name_plural='Israeli new sheqels', - rounding=0, - symbol='₪', - symbol_native='₪', - isoformat='376', - ), - 'INR': CurrencyModel( - code='INR', - decimal_digits=2, - name='Indian Rupee', - name_plural='Indian rupees', - rounding=0, - symbol='Rs', - symbol_native='টকা', - isoformat='356', - ), - 'IQD': CurrencyModel( - code='IQD', - decimal_digits=0, - name='Iraqi Dinar', - name_plural='Iraqi dinars', - rounding=0, - symbol='IQD', - symbol_native='د.ع.\u200f', - isoformat='368', - ), - 'IRR': CurrencyModel( - code='IRR', - decimal_digits=0, - name='Iranian Rial', - name_plural='Iranian rials', - rounding=0, - symbol='IRR', - symbol_native='﷼', - isoformat='364', - ), - 'ISK': CurrencyModel( - code='ISK', - decimal_digits=0, - name='Icelandic Króna', - name_plural='Icelandic krónur', - rounding=0, - symbol='Ikr', - symbol_native='kr', - isoformat='352', - ), - 'JMD': CurrencyModel( - code='JMD', - decimal_digits=2, - name='Jamaican Dollar', - name_plural='Jamaican dollars', - rounding=0, - symbol='J$', - symbol_native='$', - isoformat='388', - ), - 'JOD': CurrencyModel( - code='JOD', - decimal_digits=3, - name='Jordanian Dinar', - name_plural='Jordanian dinars', - rounding=0, - symbol='JD', - symbol_native='د.أ.\u200f', - isoformat='400', - ), - 'JPY': CurrencyModel( - code='JPY', - decimal_digits=0, - name='Japanese Yen', - name_plural='Japanese yen', - rounding=0, - symbol='¥', - symbol_native='¥', - isoformat='392', - ), - 'KES': CurrencyModel( - code='KES', - decimal_digits=2, - name='Kenyan Shilling', - name_plural='Kenyan shillings', - rounding=0, - symbol='Ksh', - symbol_native='Ksh', - isoformat='404', - ), - 'KHR': CurrencyModel( - code='KHR', - decimal_digits=2, - name='Cambodian Riel', - name_plural='Cambodian riels', - rounding=0, - symbol='KHR', - symbol_native='៛', - isoformat='116', - ), - 'KMF': CurrencyModel( - code='KMF', - decimal_digits=0, - name='Comorian Franc', - name_plural='Comorian francs', - rounding=0, - symbol='CF', - symbol_native='FC', - isoformat='174', - ), - 'KRW': CurrencyModel( - code='KRW', - decimal_digits=0, - name='South Korean Won', - name_plural='South Korean won', - rounding=0, - symbol='₩', - symbol_native='₩', - isoformat='410', - ), - 'KWD': CurrencyModel( - code='KWD', - decimal_digits=3, - name='Kuwaiti Dinar', - name_plural='Kuwaiti dinars', - rounding=0, - symbol='KD', - symbol_native='د.ك.\u200f', - isoformat='414', - ), - 'KZT': CurrencyModel( - code='KZT', - decimal_digits=2, - name='Kazakhstani Tenge', - name_plural='Kazakhstani tenges', - rounding=0, - symbol='KZT', - symbol_native='тңг.', - isoformat='398', - ), - 'LBP': CurrencyModel( - code='LBP', - decimal_digits=0, - name='Lebanese Pound', - name_plural='Lebanese pounds', - rounding=0, - symbol='LB£', - symbol_native='ل.ل.\u200f', - isoformat='422', - ), - 'LKR': CurrencyModel( - code='LKR', - decimal_digits=2, - name='Sri Lankan Rupee', - name_plural='Sri Lankan rupees', - rounding=0, - symbol='SLRs', - symbol_native='SL Re', - isoformat='144', - ), - 'LTL': CurrencyModel( - code='LTL', - decimal_digits=2, - name='Lithuanian Litas', - name_plural='Lithuanian litai', - rounding=0, - symbol='Lt', - symbol_native='Lt', - isoformat=None, - ), - 'LVL': CurrencyModel( - code='LVL', - decimal_digits=2, - name='Latvian Lats', - name_plural='Latvian lati', - rounding=0, - symbol='Ls', - symbol_native='Ls', - isoformat=None, - ), - 'LYD': CurrencyModel( - code='LYD', - decimal_digits=3, - name='Libyan Dinar', - name_plural='Libyan dinars', - rounding=0, - symbol='LD', - symbol_native='د.ل.\u200f', - isoformat='434', - ), - 'MAD': CurrencyModel( - code='MAD', - decimal_digits=2, - name='Moroccan Dirham', - name_plural='Moroccan dirhams', - rounding=0, - symbol='MAD', - symbol_native='د.م.\u200f', - isoformat='504', - ), - 'MDL': CurrencyModel( - code='MDL', - decimal_digits=2, - name='Moldovan Leu', - name_plural='Moldovan lei', - rounding=0, - symbol='MDL', - symbol_native='MDL', - isoformat='498', - ), - 'MGA': CurrencyModel( - code='MGA', - decimal_digits=0, - name='Malagasy Ariary', - name_plural='Malagasy Ariaries', - rounding=0, - symbol='MGA', - symbol_native='MGA', - isoformat='969', - ), - 'MKD': CurrencyModel( - code='MKD', - decimal_digits=2, - name='Macedonian Denar', - name_plural='Macedonian denari', - rounding=0, - symbol='MKD', - symbol_native='MKD', - isoformat='807', - ), - 'MMK': CurrencyModel( - code='MMK', - decimal_digits=0, - name='Myanma Kyat', - name_plural='Myanma kyats', - rounding=0, - symbol='MMK', - symbol_native='K', - isoformat='104', - ), - 'MOP': CurrencyModel( - code='MOP', - decimal_digits=2, - name='Macanese Pataca', - name_plural='Macanese patacas', - rounding=0, - symbol='MOP$', - symbol_native='MOP$', - isoformat='446', - ), - 'MUR': CurrencyModel( - code='MUR', - decimal_digits=0, - name='Mauritian Rupee', - name_plural='Mauritian rupees', - rounding=0, - symbol='MURs', - symbol_native='MURs', - isoformat='480', - ), - 'MXN': CurrencyModel( - code='MXN', - decimal_digits=2, - name='Mexican Peso', - name_plural='Mexican pesos', - rounding=0, - symbol='MX$', - symbol_native='$', - isoformat='484', - ), - 'MYR': CurrencyModel( - code='MYR', - decimal_digits=2, - name='Malaysian Ringgit', - name_plural='Malaysian ringgits', - rounding=0, - symbol='RM', - symbol_native='RM', - isoformat='458', - ), - 'MZN': CurrencyModel( - code='MZN', - decimal_digits=2, - name='Mozambican Metical', - name_plural='Mozambican meticals', - rounding=0, - symbol='MTn', - symbol_native='MTn', - isoformat='943', - ), - 'NAD': CurrencyModel( - code='NAD', - decimal_digits=2, - name='Namibian Dollar', - name_plural='Namibian dollars', - rounding=0, - symbol='N$', - symbol_native='N$', - isoformat='516', - ), - 'NGN': CurrencyModel( - code='NGN', - decimal_digits=2, - name='Nigerian Naira', - name_plural='Nigerian nairas', - rounding=0, - symbol='₦', - symbol_native='₦', - isoformat='566', - ), - 'NIO': CurrencyModel( - code='NIO', - decimal_digits=2, - name='Nicaraguan Córdoba', - name_plural='Nicaraguan córdobas', - rounding=0, - symbol='C$', - symbol_native='C$', - isoformat='558', - ), - 'NOK': CurrencyModel( - code='NOK', - decimal_digits=2, - name='Norwegian Krone', - name_plural='Norwegian kroner', - rounding=0, - symbol='Nkr', - symbol_native='kr', - isoformat='578', - ), - 'NPR': CurrencyModel( - code='NPR', - decimal_digits=2, - name='Nepalese Rupee', - name_plural='Nepalese rupees', - rounding=0, - symbol='NPRs', - symbol_native='नेरू', - isoformat='524', - ), - 'NZD': CurrencyModel( - code='NZD', - decimal_digits=2, - name='New Zealand Dollar', - name_plural='New Zealand dollars', - rounding=0, - symbol='NZ$', - symbol_native='$', - isoformat='554', - ), - 'OMR': CurrencyModel( - code='OMR', - decimal_digits=3, - name='Omani Rial', - name_plural='Omani rials', - rounding=0, - symbol='OMR', - symbol_native='ر.ع.\u200f', - isoformat='512', - ), - 'PAB': CurrencyModel( - code='PAB', - decimal_digits=2, - name='Panamanian Balboa', - name_plural='Panamanian balboas', - rounding=0, - symbol='B/.', - symbol_native='B/.', - isoformat='590', - ), - 'PEN': CurrencyModel( - code='PEN', - decimal_digits=2, - name='Peruvian Nuevo Sol', - name_plural='Peruvian nuevos soles', - rounding=0, - symbol='S/.', - symbol_native='S/.', - isoformat='604', - ), - 'PHP': CurrencyModel( - code='PHP', - decimal_digits=2, - name='Philippine Peso', - name_plural='Philippine pesos', - rounding=0, - symbol='₱', - symbol_native='₱', - isoformat='608', - ), - 'PKR': CurrencyModel( - code='PKR', - decimal_digits=0, - name='Pakistani Rupee', - name_plural='Pakistani rupees', - rounding=0, - symbol='PKRs', - symbol_native='₨', - isoformat='586', - ), - 'PLN': CurrencyModel( - code='PLN', - decimal_digits=2, - name='Polish Zloty', - name_plural='Polish zlotys', - rounding=0, - symbol='zł', - symbol_native='zł', - isoformat='985', - ), - 'PYG': CurrencyModel( - code='PYG', - decimal_digits=0, - name='Paraguayan Guarani', - name_plural='Paraguayan guaranis', - rounding=0, - symbol='₲', - symbol_native='₲', - isoformat='600', - ), - 'QAR': CurrencyModel( - code='QAR', - decimal_digits=2, - name='Qatari Rial', - name_plural='Qatari rials', - rounding=0, - symbol='QR', - symbol_native='ر.ق.\u200f', - isoformat='634', - ), - 'RON': CurrencyModel( - code='RON', - decimal_digits=2, - name='Romanian Leu', - name_plural='Romanian lei', - rounding=0, - symbol='RON', - symbol_native='RON', - isoformat='946', - ), - 'RSD': CurrencyModel( - code='RSD', - decimal_digits=0, - name='Serbian Dinar', - name_plural='Serbian dinars', - rounding=0, - symbol='din.', - symbol_native='дин.', - isoformat='941', - ), - 'RUB': CurrencyModel( - code='RUB', - decimal_digits=2, - name='Russian Ruble', - name_plural='Russian rubles', - rounding=0, - symbol='RUB', - symbol_native='руб.', - isoformat='643', - ), - 'RWF': CurrencyModel( - code='RWF', - decimal_digits=0, - name='Rwandan Franc', - name_plural='Rwandan francs', - rounding=0, - symbol='RWF', - symbol_native='FR', - isoformat='646', - ), - 'SAR': CurrencyModel( - code='SAR', - decimal_digits=2, - name='Saudi Riyal', - name_plural='Saudi riyals', - rounding=0, - symbol='SR', - symbol_native='ر.س.\u200f', - isoformat='682', - ), - 'SDG': CurrencyModel( - code='SDG', - decimal_digits=2, - name='Sudanese Pound', - name_plural='Sudanese pounds', - rounding=0, - symbol='SDG', - symbol_native='SDG', - isoformat='938', - ), - 'SEK': CurrencyModel( - code='SEK', - decimal_digits=2, - name='Swedish Krona', - name_plural='Swedish kronor', - rounding=0, - symbol='Skr', - symbol_native='kr', - isoformat='752', - ), - 'SGD': CurrencyModel( - code='SGD', - decimal_digits=2, - name='Singapore Dollar', - name_plural='Singapore dollars', - rounding=0, - symbol='S$', - symbol_native='$', - isoformat='702', - ), - 'SOS': CurrencyModel( - code='SOS', - decimal_digits=0, - name='Somali Shilling', - name_plural='Somali shillings', - rounding=0, - symbol='Ssh', - symbol_native='Ssh', - isoformat='706', - ), - 'SYP': CurrencyModel( - code='SYP', - decimal_digits=0, - name='Syrian Pound', - name_plural='Syrian pounds', - rounding=0, - symbol='SY£', - symbol_native='ل.س.\u200f', - isoformat='760', - ), - 'THB': CurrencyModel( - code='THB', - decimal_digits=2, - name='Thai Baht', - name_plural='Thai baht', - rounding=0, - symbol='฿', - symbol_native='฿', - isoformat='764', - ), - 'TND': CurrencyModel( - code='TND', - decimal_digits=3, - name='Tunisian Dinar', - name_plural='Tunisian dinars', - rounding=0, - symbol='DT', - symbol_native='د.ت.\u200f', - isoformat='788', - ), - 'TOP': CurrencyModel( - code='TOP', - decimal_digits=2, - name='Tongan Paʻanga', - name_plural='Tongan paʻanga', - rounding=0, - symbol='T$', - symbol_native='T$', - isoformat='776', - ), - 'TRY': CurrencyModel( - code='TRY', - decimal_digits=2, - name='Turkish Lira', - name_plural='Turkish Lira', - rounding=0, - symbol='TL', - symbol_native='TL', - isoformat='949', - ), - 'TTD': CurrencyModel( - code='TTD', - decimal_digits=2, - name='Trinidad and Tobago Dollar', - name_plural='Trinidad and Tobago dollars', - rounding=0, - symbol='TT$', - symbol_native='$', - isoformat='780', - ), - 'TWD': CurrencyModel( - code='TWD', - decimal_digits=2, - name='New Taiwan Dollar', - name_plural='New Taiwan dollars', - rounding=0, - symbol='NT$', - symbol_native='NT$', - isoformat='901', - ), - 'TZS': CurrencyModel( - code='TZS', - decimal_digits=0, - name='Tanzanian Shilling', - name_plural='Tanzanian shillings', - rounding=0, - symbol='TSh', - symbol_native='TSh', - isoformat='834', - ), - 'UAH': CurrencyModel( - code='UAH', - decimal_digits=2, - name='Ukrainian Hryvnia', - name_plural='Ukrainian hryvnias', - rounding=0, - symbol='₴', - symbol_native='₴', - isoformat='980', - ), - 'UGX': CurrencyModel( - code='UGX', - decimal_digits=0, - name='Ugandan Shilling', - name_plural='Ugandan shillings', - rounding=0, - symbol='USh', - symbol_native='USh', - isoformat='800', - ), - 'USD': CurrencyModel( - code='USD', - decimal_digits=2, - name='US Dollar', - name_plural='US dollars', - rounding=0, - symbol='$', - symbol_native='$', - isoformat='840', - ), - 'UYU': CurrencyModel( - code='UYU', - decimal_digits=2, - name='Uruguayan Peso', - name_plural='Uruguayan pesos', - rounding=0, - symbol='$U', - symbol_native='$', - isoformat='858', - ), - 'UZS': CurrencyModel( - code='UZS', - decimal_digits=0, - name='Uzbekistan Som', - name_plural='Uzbekistan som', - rounding=0, - symbol='UZS', - symbol_native='UZS', - isoformat='860', - ), - 'VEF': CurrencyModel( - code='VEF', - decimal_digits=2, - name='Venezuelan Bolívar', - name_plural='Venezuelan bolívars', - rounding=0, - symbol='Bs.raise_exception_matching_error_code.', - symbol_native='Bs.raise_exception_matching_error_code.', - isoformat='937', - ), - 'VND': CurrencyModel( - code='VND', - decimal_digits=0, - name='Vietnamese Dong', - name_plural='Vietnamese dong', - rounding=0, - symbol='₫', - symbol_native='₫', - isoformat='704', - ), - 'XAF': CurrencyModel( - code='XAF', - decimal_digits=0, - name='CFA Franc BEAC', - name_plural='CFA francs BEAC', - rounding=0, - symbol='FCFA', - symbol_native='FCFA', - isoformat='950', - ), - 'XOF': CurrencyModel( - code='XOF', - decimal_digits=0, - name='CFA Franc BCEAO', - name_plural='CFA francs BCEAO', - rounding=0, - symbol='CFA', - symbol_native='CFA', - isoformat='952', - ), - 'YER': CurrencyModel( - code='YER', - decimal_digits=0, - name='Yemeni Rial', - name_plural='Yemeni rials', - rounding=0, - symbol='YR', - symbol_native='ر.ي.\u200f', - isoformat='886', - ), - 'ZAR': CurrencyModel( - code='ZAR', - decimal_digits=2, - name='South African Rand', - name_plural='South African rand', - rounding=0, - symbol='R', - symbol_native='R', - isoformat='710', - ), - 'ZMK': CurrencyModel( - code='ZMK', - decimal_digits=0, - name='Zambian Kwacha', - name_plural='Zambian kwachas', - rounding=0, - symbol='ZK', - symbol_native='ZK', - isoformat=None, - ), -} diff --git a/glQiwiApi/types/amount.py b/glQiwiApi/types/amount.py index c73206e2..cb4e42e4 100644 --- a/glQiwiApi/types/amount.py +++ b/glQiwiApi/types/amount.py @@ -1,57 +1,30 @@ -from typing import Optional, Union +import inspect +from typing import Any, Dict, cast -from pydantic import BaseConfig, BaseModel, Field, validator +from iso4217 import Currency as _Currency +from iso4217 import find_currency +from pydantic import root_validator from glQiwiApi.types.base import Base, HashableBase -class CurrencyModel(HashableBase): - code: str - decimal_digits: int - name: str - name_plural: str - rounding: Union[int, float] - symbol: str - symbol_native: str - iso_format: Optional[str] = Field(..., alias='isoformat') +class Currency(HashableBase, _Currency): + __root__: int - def __str__(self) -> str: - return self.code + @root_validator(skip_on_failure=True) + def humanize(cls, values: Dict[str, Any]) -> Dict[str, Any]: + currency_numeric_code: int = cast(int, values.get('__root__')) + # inspect.getfullargspec(_Currency.__init__) will contain `self`, + # so we cut it off and get original currency cls's constructor input names + args = inspect.getfullargspec(_Currency.__init__).args[1:] + currency = find_currency(numeric_code=currency_numeric_code) + return {k: getattr(currency, k, None) for k in args} - class Config(BaseConfig): - frozen = True - allow_mutation = False - -class AmountWithCurrency(Base): - amount: float - currency: Union[CurrencyModel, str] # string if currency util couldn't parse it - - @validator('currency', pre=True) - def humanize_pay_currency(cls, v): # type: ignore - from glQiwiApi.utils.currency_util import Currency - - if not isinstance(v, int): - try: - v = int(v) - except ValueError: - return v - return Currency.get(str(v)) - - -class HashableSum(HashableBase, AmountWithCurrency): - ... - - -class PlainAmount(BaseModel): +class Amount(Base): value: float - currency: str - - -class HashablePlainAmount(HashableBase, PlainAmount): - ... + currency: Currency -class Type(BaseModel): - id: str - title: str +class HashableAmount(Amount, HashableBase): + pass diff --git a/glQiwiApi/types/base.py b/glQiwiApi/types/base.py index 83d6cca5..75db8db7 100644 --- a/glQiwiApi/types/base.py +++ b/glQiwiApi/types/base.py @@ -1,5 +1,3 @@ -from typing import Hashable - from pydantic import BaseConfig, BaseModel from glQiwiApi.utils.compat import json diff --git a/glQiwiApi/utils/certificates.py b/glQiwiApi/utils/certificates.py index 70ee4792..3dbd1d02 100644 --- a/glQiwiApi/utils/certificates.py +++ b/glQiwiApi/utils/certificates.py @@ -4,7 +4,6 @@ from dataclasses import dataclass from datetime import datetime, timedelta from io import BytesIO -from os import PathLike from typing import TYPE_CHECKING, Any, Iterable, List, Optional, Union, cast if TYPE_CHECKING: diff --git a/glQiwiApi/utils/currency_util.py b/glQiwiApi/utils/currency_util.py deleted file mode 100644 index 8728f905..00000000 --- a/glQiwiApi/utils/currency_util.py +++ /dev/null @@ -1,34 +0,0 @@ -from typing import Optional, Union - -from glQiwiApi.types import _currencies -from glQiwiApi.types.amount import CurrencyModel - - -class Currency: - """ - Class with many currencies - import glQiwiApi.types.basics >>> usd = Currency.get('840') - >>> usd - ... CurrencyModel(code='USD', decimal_digits=2, name='US Dollar', name_plural='US dollars', - ... rounding=0, symbol='$', symbol_native='$') - - >>> usd.symbol - ... '$' - """ - - @classmethod - def get(cls, currency_code: Union[str, int]) -> Optional[CurrencyModel]: - """ - Implements class-based getitem behaviour - - >>> Currency.get('840').symbol - ... '$' - >>> Currency.get('USD').symbol - ... '$' - :param currency_code: ISO 4217 string or CODE - :return: Currency object - """ - if isinstance(currency_code, int) or currency_code.isdigit(): - return _currencies.described.get(_currencies.codes_number[str(currency_code)]) - else: - return _currencies.described.get(currency_code.upper()) diff --git a/glQiwiApi/yoo_money/methods/get_access_token.py b/glQiwiApi/yoo_money/methods/get_access_token.py index c0be91eb..51cb0809 100644 --- a/glQiwiApi/yoo_money/methods/get_access_token.py +++ b/glQiwiApi/yoo_money/methods/get_access_token.py @@ -1,6 +1,6 @@ from typing import ClassVar, Optional -from glQiwiApi.core.abc.api_method import APIMethod, ReturningType +from glQiwiApi.core.abc.api_method import APIMethod from glQiwiApi.core.session.holder import HTTPResponse diff --git a/glQiwiApi/yoo_money/types/types.py b/glQiwiApi/yoo_money/types/types.py index 292f45f0..92a56b10 100644 --- a/glQiwiApi/yoo_money/types/types.py +++ b/glQiwiApi/yoo_money/types/types.py @@ -200,7 +200,7 @@ def _extract_amount_and_comment_by_operation_type( id: str = Field(..., alias='operation_id') status: str - amount: float + value: float amount_due: Optional[float] = None currency: str = Field(..., alias='amount_currency') operation_date: datetime = Field(..., alias='datetime') diff --git a/poetry.lock b/poetry.lock index 53baf444..1466964c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -231,7 +231,7 @@ toml = ["tomli"] [[package]] name = "cryptography" -version = "37.0.4" +version = "37.0.3" description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." category = "dev" optional = false @@ -300,6 +300,14 @@ category = "main" optional = false python-versions = ">=3.5" +[[package]] +name = "ijson" +version = "3.1.4" +description = "Iterative JSON parser with standard Python iterator interfaces" +category = "main" +optional = false +python-versions = "*" + [[package]] name = "imagesize" version = "1.4.1" @@ -709,7 +717,7 @@ pytest = ">=3.2.5" [[package]] name = "pytest-mock" -version = "3.8.2" +version = "3.8.1" description = "Thin-wrapper around the mock package for easier use with pytest" category = "dev" optional = false @@ -732,6 +740,17 @@ python-versions = ">=3.6" [package.dependencies] pytest = ">=5.0.0" +[[package]] +name = "python-iso4217" +version = "0.0.3" +description = "Lightweight ISO 4217 currency package" +category = "main" +optional = false +python-versions = ">=3.6,<4.0" + +[package.dependencies] +ijson = ">=3.1.4,<4.0.0" + [[package]] name = "pytz" version = "2022.1" @@ -1133,7 +1152,7 @@ fast = ["uvloop", "aiofiles"] [metadata] lock-version = "1.1" python-versions = "^3.7" -content-hash = "7615ace869b0061bf74abfe073c7734a16083591d89ed368acf9d31195cfc270" +content-hash = "c9601097a75aeeb75c9030d8040a7388b0b2e606a85d8e14ca463276a883e30d" [metadata.files] aiofiles = [ @@ -1404,28 +1423,28 @@ coverage = [ {file = "coverage-6.4.1.tar.gz", hash = "sha256:4321f075095a096e70aff1d002030ee612b65a205a0a0f5b815280d5dc58100c"}, ] cryptography = [ - {file = "cryptography-37.0.4-cp36-abi3-macosx_10_10_universal2.whl", hash = "sha256:549153378611c0cca1042f20fd9c5030d37a72f634c9326e225c9f666d472884"}, - {file = "cryptography-37.0.4-cp36-abi3-macosx_10_10_x86_64.whl", hash = "sha256:a958c52505c8adf0d3822703078580d2c0456dd1d27fabfb6f76fe63d2971cd6"}, - {file = "cryptography-37.0.4-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f721d1885ecae9078c3f6bbe8a88bc0786b6e749bf32ccec1ef2b18929a05046"}, - {file = "cryptography-37.0.4-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl", hash = "sha256:3d41b965b3380f10e4611dbae366f6dc3cefc7c9ac4e8842a806b9672ae9add5"}, - {file = "cryptography-37.0.4-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:80f49023dd13ba35f7c34072fa17f604d2f19bf0989f292cedf7ab5770b87a0b"}, - {file = "cryptography-37.0.4-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f2dcb0b3b63afb6df7fd94ec6fbddac81b5492513f7b0436210d390c14d46ee8"}, - {file = "cryptography-37.0.4-cp36-abi3-manylinux_2_24_x86_64.whl", hash = "sha256:b7f8dd0d4c1f21759695c05a5ec8536c12f31611541f8904083f3dc582604280"}, - {file = "cryptography-37.0.4-cp36-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:30788e070800fec9bbcf9faa71ea6d8068f5136f60029759fd8c3efec3c9dcb3"}, - {file = "cryptography-37.0.4-cp36-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:190f82f3e87033821828f60787cfa42bff98404483577b591429ed99bed39d59"}, - {file = "cryptography-37.0.4-cp36-abi3-win32.whl", hash = "sha256:b62439d7cd1222f3da897e9a9fe53bbf5c104fff4d60893ad1355d4c14a24157"}, - {file = "cryptography-37.0.4-cp36-abi3-win_amd64.whl", hash = "sha256:f7a6de3e98771e183645181b3627e2563dcde3ce94a9e42a3f427d2255190327"}, - {file = "cryptography-37.0.4-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6bc95ed67b6741b2607298f9ea4932ff157e570ef456ef7ff0ef4884a134cc4b"}, - {file = "cryptography-37.0.4-pp37-pypy37_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:f8c0a6e9e1dd3eb0414ba320f85da6b0dcbd543126e30fcc546e7372a7fbf3b9"}, - {file = "cryptography-37.0.4-pp38-pypy38_pp73-macosx_10_10_x86_64.whl", hash = "sha256:e007f052ed10cc316df59bc90fbb7ff7950d7e2919c9757fd42a2b8ecf8a5f67"}, - {file = "cryptography-37.0.4-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7bc997818309f56c0038a33b8da5c0bfbb3f1f067f315f9abd6fc07ad359398d"}, - {file = "cryptography-37.0.4-pp38-pypy38_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:d204833f3c8a33bbe11eda63a54b1aad7aa7456ed769a982f21ec599ba5fa282"}, - {file = "cryptography-37.0.4-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:75976c217f10d48a8b5a8de3d70c454c249e4b91851f6838a4e48b8f41eb71aa"}, - {file = "cryptography-37.0.4-pp39-pypy39_pp73-macosx_10_10_x86_64.whl", hash = "sha256:7099a8d55cd49b737ffc99c17de504f2257e3787e02abe6d1a6d136574873441"}, - {file = "cryptography-37.0.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2be53f9f5505673eeda5f2736bea736c40f051a739bfae2f92d18aed1eb54596"}, - {file = "cryptography-37.0.4-pp39-pypy39_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:91ce48d35f4e3d3f1d83e29ef4a9267246e6a3be51864a5b7d2247d5086fa99a"}, - {file = "cryptography-37.0.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:4c590ec31550a724ef893c50f9a97a0c14e9c851c85621c5650d699a7b88f7ab"}, - {file = "cryptography-37.0.4.tar.gz", hash = "sha256:63f9c17c0e2474ccbebc9302ce2f07b55b3b3fcb211ded18a42d5764f5c10a82"}, + {file = "cryptography-37.0.3-cp36-abi3-macosx_10_10_universal2.whl", hash = "sha256:d10413d493e98075060d3e62e5826de372912ea653ccc948f3c41b21ddca087f"}, + {file = "cryptography-37.0.3-cp36-abi3-macosx_10_10_x86_64.whl", hash = "sha256:cd64147ff16506632893ceb2569624b48c84daa3ba4d89695f7c7bc24188eee9"}, + {file = "cryptography-37.0.3-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:17c74f7d9e9e9bb7e84521243695c1b4bdc3a0e44ca764e6bcf8f05f3de3d0df"}, + {file = "cryptography-37.0.3-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl", hash = "sha256:0713bee6c8077786c56bdec9c5d3f099d40d2c862ff3200416f6862e9dd63156"}, + {file = "cryptography-37.0.3-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b9c2008417741cdfbe945ef2d16b7b7ba0790886a0b49e1de533acf93eb66ed6"}, + {file = "cryptography-37.0.3-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:646905ff7a712e415bf0d0f214e0eb669dd2257c4d7a27db1e8baec5d2a1d55f"}, + {file = "cryptography-37.0.3-cp36-abi3-manylinux_2_24_x86_64.whl", hash = "sha256:dcafadb5a06cb7a6bb49fb4c1de7414ee2f8c8e12b047606d97c3175d690f582"}, + {file = "cryptography-37.0.3-cp36-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:0b4bfc5ccfe4e5c7de535670680398fed4a0bbc5dfd52b3a295baad42230abdf"}, + {file = "cryptography-37.0.3-cp36-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:a03dbc0d8ce8c1146c177cd0e3a66ea106f36733fb1b997ea4d051f8a68539ff"}, + {file = "cryptography-37.0.3-cp36-abi3-win32.whl", hash = "sha256:190a24c14e91c1fa3101069aac7e77d11c5a73911c3904128367f52946bbb6fd"}, + {file = "cryptography-37.0.3-cp36-abi3-win_amd64.whl", hash = "sha256:b05c5478524deb7a019e240f2a970040c4b0f01f58f0425e6262c96b126c6a3e"}, + {file = "cryptography-37.0.3-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:891ed8312840fd43e0696468a6520a582a033c0109f7b14b96067bfe1123226b"}, + {file = "cryptography-37.0.3-pp37-pypy37_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:30d6aabf623a01affc7c0824936c3dde6590076b61f5dd299df3cc2c75fc5915"}, + {file = "cryptography-37.0.3-pp38-pypy38_pp73-macosx_10_10_x86_64.whl", hash = "sha256:31a7c1f1c2551f013d4294d06e22848e2ccd77825f0987cba3239df6ebf7b020"}, + {file = "cryptography-37.0.3-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a94fd1ff80001cb97add71d07f596d8b865b716f25ef501183e0e199390e50d3"}, + {file = "cryptography-37.0.3-pp38-pypy38_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:8a85dbcc770256918b40c2f40bd3ffd3b2ae45b0cf19068b561db8f8d61bf492"}, + {file = "cryptography-37.0.3-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:773d5b5f2e2bd2c7cbb1bd24902ad41283c88b9dd463a0f82adc9a2870d9d066"}, + {file = "cryptography-37.0.3-pp39-pypy39_pp73-macosx_10_10_x86_64.whl", hash = "sha256:0f9193428a55a4347af2d4fd8141a2002dedbcc26487e67fd2ae19f977ee8afc"}, + {file = "cryptography-37.0.3-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7bf652c73e8f7c32a3f92f7184bf7f9106dacdf5ef59c3c3683d7dae2c4972fb"}, + {file = "cryptography-37.0.3-pp39-pypy39_pp73-manylinux_2_24_x86_64.whl", hash = "sha256:c3c8b1ad2c266fdf7adc041cc4156d6a3d14db93de2f81b26a5af97ef3f209e5"}, + {file = "cryptography-37.0.3-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:2383d6c3088e863304c37c65cd2ea404b7fbb4886823eab1d74137cc27f3d2ee"}, + {file = "cryptography-37.0.3.tar.gz", hash = "sha256:ae430d51c67ac638dfbb42edf56c669ca9c74744f4d225ad11c6f3d355858187"}, ] docutils = [ {file = "docutils-0.17.1-py2.py3-none-any.whl", hash = "sha256:cf316c8370a737a022b72b56874f6602acf974a37a9fba42ec2876387549fc61"}, @@ -1504,6 +1523,70 @@ idna = [ {file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"}, {file = "idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"}, ] +ijson = [ + {file = "ijson-3.1.4-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:6c1a777096be5f75ffebb335c6d2ebc0e489b231496b7f2ca903aa061fe7d381"}, + {file = "ijson-3.1.4-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:475fc25c3d2a86230b85777cae9580398b42eed422506bf0b6aacfa936f7bfcd"}, + {file = "ijson-3.1.4-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:f587699b5a759e30accf733e37950cc06c4118b72e3e146edcea77dded467426"}, + {file = "ijson-3.1.4-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:339b2b4c7bbd64849dd69ef94ee21e29dcd92c831f47a281fdd48122bb2a715a"}, + {file = "ijson-3.1.4-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:446ef8980504da0af8d20d3cb6452c4dc3d8aa5fd788098985e899b913191fe6"}, + {file = "ijson-3.1.4-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:3997a2fdb28bc04b9ab0555db5f3b33ed28d91e9d42a3bf2c1842d4990beb158"}, + {file = "ijson-3.1.4-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:fa10a1d88473303ec97aae23169d77c5b92657b7fb189f9c584974c00a79f383"}, + {file = "ijson-3.1.4-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:9a5bf5b9d8f2ceaca131ee21fc7875d0f34b95762f4f32e4d65109ca46472147"}, + {file = "ijson-3.1.4-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:81cc8cee590c8a70cca3c9aefae06dd7cb8e9f75f3a7dc12b340c2e332d33a2a"}, + {file = "ijson-3.1.4-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:4ea5fc50ba158f72943d5174fbc29ebefe72a2adac051c814c87438dc475cf78"}, + {file = "ijson-3.1.4-cp35-cp35m-macosx_10_9_x86_64.whl", hash = "sha256:3b98861a4280cf09d267986cefa46c3bd80af887eae02aba07488d80eb798afa"}, + {file = "ijson-3.1.4-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:068c692efba9692406b86736dcc6803e4a0b6280d7f0b7534bff3faec677ff38"}, + {file = "ijson-3.1.4-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:86884ac06ac69cea6d89ab7b84683b3b4159c4013e4a20276d3fc630fe9b7588"}, + {file = "ijson-3.1.4-cp35-cp35m-manylinux2010_i686.whl", hash = "sha256:41e5886ff6fade26f10b87edad723d2db14dcbb1178717790993fcbbb8ccd333"}, + {file = "ijson-3.1.4-cp35-cp35m-manylinux2010_x86_64.whl", hash = "sha256:24b58933bf777d03dc1caa3006112ec7f9e6f6db6ffe1f5f5bd233cb1281f719"}, + {file = "ijson-3.1.4-cp35-cp35m-manylinux2014_aarch64.whl", hash = "sha256:13f80aad0b84d100fb6a88ced24bade21dc6ddeaf2bba3294b58728463194f50"}, + {file = "ijson-3.1.4-cp35-cp35m-win32.whl", hash = "sha256:fa9a25d0bd32f9515e18a3611690f1de12cb7d1320bd93e9da835936b41ad3ff"}, + {file = "ijson-3.1.4-cp35-cp35m-win_amd64.whl", hash = "sha256:c4c1bf98aaab4c8f60d238edf9bcd07c896cfcc51c2ca84d03da22aad88957c5"}, + {file = "ijson-3.1.4-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f0f2a87c423e8767368aa055310024fa28727f4454463714fef22230c9717f64"}, + {file = "ijson-3.1.4-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:15507de59d74d21501b2a076d9c49abf927eb58a51a01b8f28a0a0565db0a99f"}, + {file = "ijson-3.1.4-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:2e6bd6ad95ab40c858592b905e2bbb4fe79bbff415b69a4923dafe841ffadcb4"}, + {file = "ijson-3.1.4-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:68e295bb12610d086990cedc89fb8b59b7c85740d66e9515aed062649605d0bf"}, + {file = "ijson-3.1.4-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:3bb461352c0f0f2ec460a4b19400a665b8a5a3a2da663a32093df1699642ee3f"}, + {file = "ijson-3.1.4-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:f91c75edd6cf1a66f02425bafc59a22ec29bc0adcbc06f4bfd694d92f424ceb3"}, + {file = "ijson-3.1.4-cp36-cp36m-win32.whl", hash = "sha256:4c53cc72f79a4c32d5fc22efb85aa22f248e8f4f992707a84bdc896cc0b1ecf9"}, + {file = "ijson-3.1.4-cp36-cp36m-win_amd64.whl", hash = "sha256:ac9098470c1ff6e5c23ec0946818bc102bfeeeea474554c8d081dc934be20988"}, + {file = "ijson-3.1.4-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:dcd6f04df44b1945b859318010234651317db2c4232f75e3933f8bb41c4fa055"}, + {file = "ijson-3.1.4-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:5a2f40c053c837591636dc1afb79d85e90b9a9d65f3d9963aae31d1eb11bfed2"}, + {file = "ijson-3.1.4-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:f50337e3b8e72ec68441b573c2848f108a8976a57465c859b227ebd2a2342901"}, + {file = "ijson-3.1.4-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:454918f908abbed3c50a0a05c14b20658ab711b155e4f890900e6f60746dd7cc"}, + {file = "ijson-3.1.4-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:387c2ec434cc1bc7dc9bd33ec0b70d95d443cc1e5934005f26addc2284a437ab"}, + {file = "ijson-3.1.4-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:179ed6fd42e121d252b43a18833df2de08378fac7bce380974ef6f5e522afefa"}, + {file = "ijson-3.1.4-cp37-cp37m-win32.whl", hash = "sha256:26a6a550b270df04e3f442e2bf0870c9362db4912f0e7bdfd300f30ea43115a2"}, + {file = "ijson-3.1.4-cp37-cp37m-win_amd64.whl", hash = "sha256:ff8cf7507d9d8939264068c2cff0a23f99703fa2f31eb3cb45a9a52798843586"}, + {file = "ijson-3.1.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:09c9d7913c88a6059cd054ff854958f34d757402b639cf212ffbec201a705a0d"}, + {file = "ijson-3.1.4-cp38-cp38-manylinux1_i686.whl", hash = "sha256:702ba9a732116d659a5e950ee176be6a2e075998ef1bcde11cbf79a77ed0f717"}, + {file = "ijson-3.1.4-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:667841591521158770adc90793c2bdbb47c94fe28888cb802104b8bbd61f3d51"}, + {file = "ijson-3.1.4-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:df641dd07b38c63eecd4f454db7b27aa5201193df160f06b48111ba97ab62504"}, + {file = "ijson-3.1.4-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:9348e7d507eb40b52b12eecff3d50934fcc3d2a15a2f54ec1127a36063b9ba8f"}, + {file = "ijson-3.1.4-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:93455902fdc33ba9485c7fae63ac95d96e0ab8942224a357113174bbeaff92e9"}, + {file = "ijson-3.1.4-cp38-cp38-win32.whl", hash = "sha256:5b725f2e984ce70d464b195f206fa44bebbd744da24139b61fec72de77c03a16"}, + {file = "ijson-3.1.4-cp38-cp38-win_amd64.whl", hash = "sha256:a5965c315fbb2dc9769dfdf046eb07daf48ae20b637da95ec8d62b629be09df4"}, + {file = "ijson-3.1.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:b8ee7dbb07cec9ba29d60cfe4954b3cc70adb5f85bba1f72225364b59c1cf82b"}, + {file = "ijson-3.1.4-cp39-cp39-manylinux1_i686.whl", hash = "sha256:d9e01c55d501e9c3d686b6ee3af351c9c0c8c3e45c5576bd5601bee3e1300b09"}, + {file = "ijson-3.1.4-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:297f26f27a04cd0d0a2f865d154090c48ea11b239cabe0a17a6c65f0314bd1ca"}, + {file = "ijson-3.1.4-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:9239973100338a4138d09d7a4602bd289861e553d597cd67390c33bfc452253e"}, + {file = "ijson-3.1.4-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:2a64c66a08f56ed45a805691c2fd2e1caef00edd6ccf4c4e5eff02cd94ad8364"}, + {file = "ijson-3.1.4-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:d17fd199f0d0a4ab6e0d541b4eec1b68b5bd5bb5d8104521e22243015b51049b"}, + {file = "ijson-3.1.4-cp39-cp39-win32.whl", hash = "sha256:70ee3c8fa0eba18c80c5911639c01a8de4089a4361bad2862a9949e25ec9b1c8"}, + {file = "ijson-3.1.4-cp39-cp39-win_amd64.whl", hash = "sha256:6bf2b64304321705d03fa5e403ec3f36fa5bb27bf661849ad62e0a3a49bc23e3"}, + {file = "ijson-3.1.4-pp27-pypy_73-macosx_10_9_x86_64.whl", hash = "sha256:5d7e3fcc3b6de76a9dba1e9fc6ca23dad18f0fa6b4e6499415e16b684b2e9af1"}, + {file = "ijson-3.1.4-pp27-pypy_73-manylinux1_x86_64.whl", hash = "sha256:a72eb0359ebff94754f7a2f00a6efe4c57716f860fc040c606dedcb40f49f233"}, + {file = "ijson-3.1.4-pp27-pypy_73-manylinux2010_x86_64.whl", hash = "sha256:28fc168f5faf5759fdfa2a63f85f1f7a148bbae98f34404a6ba19f3d08e89e87"}, + {file = "ijson-3.1.4-pp36-pypy36_pp73-macosx_10_9_x86_64.whl", hash = "sha256:2844d4a38d27583897ed73f7946e205b16926b4cab2525d1ce17e8b08064c706"}, + {file = "ijson-3.1.4-pp36-pypy36_pp73-manylinux1_x86_64.whl", hash = "sha256:252defd1f139b5fb8c764d78d5e3a6df81543d9878c58992a89b261369ea97a7"}, + {file = "ijson-3.1.4-pp36-pypy36_pp73-manylinux2010_x86_64.whl", hash = "sha256:15d5356b4d090c699f382c8eb6a2bcd5992a8c8e8b88c88bc6e54f686018328a"}, + {file = "ijson-3.1.4-pp36-pypy36_pp73-win32.whl", hash = "sha256:6774ec0a39647eea70d35fb76accabe3d71002a8701c0545b9120230c182b75b"}, + {file = "ijson-3.1.4-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:f11da15ec04cc83ff0f817a65a3392e169be8d111ba81f24d6e09236597bb28c"}, + {file = "ijson-3.1.4-pp37-pypy37_pp73-manylinux1_x86_64.whl", hash = "sha256:ee13ceeed9b6cf81b3b8197ef15595fc43fd54276842ed63840ddd49db0603da"}, + {file = "ijson-3.1.4-pp37-pypy37_pp73-manylinux2010_x86_64.whl", hash = "sha256:97e4df67235fae40d6195711223520d2c5bf1f7f5087c2963fcde44d72ebf448"}, + {file = "ijson-3.1.4-pp37-pypy37_pp73-win32.whl", hash = "sha256:3d10eee52428f43f7da28763bb79f3d90bbbeea1accb15de01e40a00885b6e89"}, + {file = "ijson-3.1.4.tar.gz", hash = "sha256:1d1003ae3c6115ec9b587d29dd136860a81a23c7626b682e2b5b12c9fd30e4ea"}, +] imagesize = [ {file = "imagesize-1.4.1-py2.py3-none-any.whl", hash = "sha256:0d8d18d08f840c19d0ee7ca1fd82490fdc3729b7ac93f49870406ddde8ef8d8b"}, {file = "imagesize-1.4.1.tar.gz", hash = "sha256:69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a"}, @@ -1792,13 +1875,17 @@ pytest-lazy-fixture = [ {file = "pytest_lazy_fixture-0.6.3-py3-none-any.whl", hash = "sha256:e0b379f38299ff27a653f03eaa69b08a6fd4484e46fd1c9907d984b9f9daeda6"}, ] pytest-mock = [ - {file = "pytest-mock-3.8.2.tar.gz", hash = "sha256:77f03f4554392558700295e05aed0b1096a20d4a60a4f3ddcde58b0c31c8fca2"}, - {file = "pytest_mock-3.8.2-py3-none-any.whl", hash = "sha256:8a9e226d6c0ef09fcf20c94eb3405c388af438a90f3e39687f84166da82d5948"}, + {file = "pytest-mock-3.8.1.tar.gz", hash = "sha256:2c6d756d5d3bf98e2e80797a959ca7f81f479e7d1f5f571611b0fdd6d1745240"}, + {file = "pytest_mock-3.8.1-py3-none-any.whl", hash = "sha256:d989f11ca4a84479e288b0cd1e6769d6ad0d3d7743dcc75e460d1416a5f2135a"}, ] pytest-timeout = [ {file = "pytest-timeout-2.1.0.tar.gz", hash = "sha256:c07ca07404c612f8abbe22294b23c368e2e5104b521c1790195561f37e1ac3d9"}, {file = "pytest_timeout-2.1.0-py3-none-any.whl", hash = "sha256:f6f50101443ce70ad325ceb4473c4255e9d74e3c7cd0ef827309dfa4c0d975c6"}, ] +python-iso4217 = [ + {file = "python-iso4217-0.0.3.tar.gz", hash = "sha256:f943a77e631c0fae4557aa873df0fd91569983604ae9dcb17c7761c97f308b74"}, + {file = "python_iso4217-0.0.3-py3-none-any.whl", hash = "sha256:34f9830acd8bf4dbab096e1ff936cc8ee3bc30dc7fb78d8ed944a3d22d54020a"}, +] pytz = [ {file = "pytz-2022.1-py2.py3-none-any.whl", hash = "sha256:e68985985296d9a66a881eb3193b0906246245294a881e7c8afe623866ac6a5c"}, {file = "pytz-2022.1.tar.gz", hash = "sha256:1e760e2fe6a8163bc0b3d9a19c4f84342afa0a2affebfaa84b01b978a02ecaa7"}, diff --git a/pyproject.toml b/pyproject.toml index 84e84596..a11cbdf9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "glQiwiApi" -version = "2.11" +version = "2.12" description = "The ultrarapid and multifunctional wrapper over QIWI and YooMoney" authors = [ "Glib Garanin " @@ -64,6 +64,7 @@ pymdown-extensions = { version = "^9.4", optional = true } markdown-include = { version = "^0.6", optional = true } sphinxemoji = { version = "*", optional = true } sphinx-notfound-page = { version = "*", optional = true } +python-iso4217 = "^0.0.3" diff --git a/tests/conftest.py b/tests/conftest.py index f22f5256..2d0ee84f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,7 +4,7 @@ from glQiwiApi.qiwi.clients.wallet.types import Transaction, TransactionStatus, TransactionWebhook from glQiwiApi.qiwi.clients.wallet.types.transaction import Provider, TransactionType -from glQiwiApi.types.amount import AmountWithCurrency +from glQiwiApi.types.amount import Amount @pytest.fixture() @@ -17,10 +17,10 @@ def transaction() -> Transaction: statusText='hello', trmTxnId='world', account='+38908234234', - sum=AmountWithCurrency(amount=999, currency='643'), - total=AmountWithCurrency(amount=999, currency='643'), + sum=Amount(value=999, currency='643'), + total=Amount(value=999, currency='643'), provider=Provider(), - commission=AmountWithCurrency(amount=999, currency='643'), + commission=Amount(value=999, currency='643'), currencyRate=643, type=TransactionType.OUT, comment='my_comment', diff --git a/tests/integration/test_qiwi/test_clients/test_p2p_client.py b/tests/integration/test_qiwi/test_clients/test_p2p_client.py index a95286a0..4344a2a2 100644 --- a/tests/integration/test_qiwi/test_clients/test_p2p_client.py +++ b/tests/integration/test_qiwi/test_clients/test_p2p_client.py @@ -38,7 +38,7 @@ async def api_fixture() -> AsyncIterator[QiwiP2PClient]: async def test_create_p2p_bill(api: QiwiP2PClient, payload: Dict[str, Any]) -> None: result = await api.create_p2p_bill(**payload) assert isinstance(result, Bill) - assert payload['amount'] == result.amount.value + assert payload['amount'] == result.value.value async def test_check_p2p_bill_status(api: QiwiP2PClient) -> None: diff --git a/tests/integration/test_qiwi/test_clients/test_wallet.py b/tests/integration/test_qiwi/test_clients/test_wallet.py index fef99695..a075e4ff 100644 --- a/tests/integration/test_qiwi/test_clients/test_wallet.py +++ b/tests/integration/test_qiwi/test_clients/test_wallet.py @@ -28,7 +28,7 @@ from glQiwiApi.qiwi.clients.wallet.types.balance import AvailableBalance from glQiwiApi.qiwi.clients.wallet.types.nickname import NickName from glQiwiApi.qiwi.exceptions import MobileOperatorCannotBeDeterminedError, ObjectNotFoundError -from glQiwiApi.types.amount import AmountWithCurrency, CurrencyModel +from glQiwiApi.types.amount import Amount, Currency from glQiwiApi.types.arbitrary import File from tests.settings import QIWI_WALLET_CREDENTIALS @@ -50,8 +50,8 @@ async def api_fixture() -> AsyncIterator[QiwiWallet]: async def test_get_balance(api: QiwiWallet) -> None: result = await api.get_balance() - assert isinstance(result, AmountWithCurrency) - assert isinstance(result.currency, CurrencyModel) + assert isinstance(result, Amount) + assert isinstance(result.currency, Currency) def test_create_request_service() -> None: diff --git a/tests/unit/test_event_fetching/test_webhook/test_views/test_txn_view.py b/tests/unit/test_event_fetching/test_webhook/test_views/test_txn_view.py index 2f0cde0e..a3dd5e4f 100644 --- a/tests/unit/test_event_fetching/test_webhook/test_views/test_txn_view.py +++ b/tests/unit/test_event_fetching/test_webhook/test_views/test_txn_view.py @@ -1,5 +1,4 @@ import asyncio -import json import logging from asyncio import AbstractEventLoop @@ -82,12 +81,12 @@ async def test_with_invalid_payload( 'payment': { **txn.payment.dict(by_alias=True), 'sum': { - 'currency': txn.payment.sum.currency.code, - 'amount': txn.payment.sum.amount, + 'currency': txn.payment.sum.currency.numeric_code, + 'amount': txn.payment.sum.value, }, 'total': { - 'currency': txn.payment.sum.currency.code, - 'amount': txn.payment.sum.amount, + 'currency': txn.payment.sum.currency.numeric_code, + 'amount': txn.payment.sum.value, }, }, 'hookId': txn.id, diff --git a/tests/unit/test_utils/test_certificates.py b/tests/unit/test_utils/test_certificates.py index 2e59f631..1527ddee 100644 --- a/tests/unit/test_utils/test_certificates.py +++ b/tests/unit/test_utils/test_certificates.py @@ -1,3 +1,4 @@ +import pathlib import ssl from py.path import local @@ -10,7 +11,9 @@ def test_generate_self_signed_certificates(tmpdir: local) -> None: path_to_cert = tmpdir.join('cert.pem') path_to_pkey = tmpdir.join('pkey.pem') get_or_generate_self_signed_certificate( - hostname='45.138.24.80', cert_path=path_to_cert, pkey_path=path_to_pkey + hostname='45.138.24.80', + cert_path=pathlib.Path(path_to_cert), + pkey_path=pathlib.Path(path_to_pkey), ) assert path_to_cert.isfile() is True assert path_to_pkey.isfile() is True @@ -20,8 +23,8 @@ def test_get_ssl_context(tmpdir: local) -> None: tmpdir.mkdir('certificates') ssl_certificate = get_or_generate_self_signed_certificate( hostname='45.138.24.80', - cert_path=tmpdir.join('cert.pem'), - pkey_path=tmpdir.join('pkey.pem'), + cert_path=pathlib.Path(tmpdir.join('cert.pem')), + pkey_path=pathlib.Path(tmpdir.join('pkey.pem')), ) context = ssl_certificate.as_ssl_context() assert isinstance(context, ssl.SSLContext) @@ -31,8 +34,8 @@ def test_get_input_file(tmpdir: local) -> None: tmpdir.mkdir('certificates') ssl_certificate = get_or_generate_self_signed_certificate( hostname='45.138.24.80', - cert_path=tmpdir.join('cert.pem'), - pkey_path=tmpdir.join('pkey.pem'), + cert_path=pathlib.Path(tmpdir.join('cert.pem')), + pkey_path=pathlib.Path(tmpdir.join('pkey.pem')), ) input_file = ssl_certificate.as_input_file() assert input_file.get_file().read() == tmpdir.join('cert.pem').read().encode('utf-8') diff --git a/tests/unit/test_utils/test_currencies.py b/tests/unit/test_utils/test_currencies.py new file mode 100644 index 00000000..20b86584 --- /dev/null +++ b/tests/unit/test_utils/test_currencies.py @@ -0,0 +1,20 @@ +import pytest +from iso4217 import CurrencyNotFoundError + +from glQiwiApi.types.amount import Currency + + +def test_currency_from_code() -> None: + hryvna_currency = Currency.parse_obj(980) + assert hryvna_currency.dict(exclude_none=True) == { + 'alphabetical_code': 'UAH', + 'currency_name': 'Hryvnia', + 'entity': 'UKRAINE', + 'decimal_places': 2, + 'numeric_code': 980, + } + + +def test_fail_if_currency_not_found() -> None: + with pytest.raises(CurrencyNotFoundError): + defunct_currency = Currency.parse_obj(656) diff --git a/tests/unit/test_utils/test_currency_parser.py b/tests/unit/test_utils/test_currency_parser.py deleted file mode 100644 index ef5e4d4f..00000000 --- a/tests/unit/test_utils/test_currency_parser.py +++ /dev/null @@ -1,12 +0,0 @@ -from glQiwiApi.types._currencies import described -from glQiwiApi.types.amount import CurrencyModel -from glQiwiApi.utils.currency_util import Currency - - -def test_parse_described_currencies(): - condition = all(isinstance(Currency().get(key), CurrencyModel) for key in described.keys()) - assert condition - - -def test_parse_non_existent_currency(): - assert Currency().get(currency_code='dsfgsgdsfg') is None