Skip to content

Commit

Permalink
add enum support for methods get_check_image and get_rates_image
Browse files Browse the repository at this point in the history
  • Loading branch information
vovchic17 committed Feb 9, 2025
1 parent 6f32152 commit 90af6cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 10 additions & 1 deletion aiosend/client/network.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from dataclasses import dataclass
from typing import TYPE_CHECKING

from aiosend.enums import Asset, Fiat

if TYPE_CHECKING:
from typing import Literal

from aiosend.enums import Asset, Fiat
from aiosend.methods import CryptoPayMethod


Expand Down Expand Up @@ -34,6 +35,10 @@ def get_check_image(
main: "Literal['asset', 'fiat']",
) -> str:
"""Return check image url."""
if isinstance(asset, Asset):
asset = asset.value
if isinstance(fiat, Fiat):
fiat = fiat.value
return (
"https://imggen.send.tg/checks/image?"
f"asset={asset}"
Expand All @@ -51,6 +56,10 @@ def get_rates_image(
percent: float,
) -> str:
"""Return rates image url."""
if isinstance(base, Asset | Fiat):
base = base.value
if isinstance(quote, Asset | Fiat):
quote = quote.value
return (
"https://imggen.send.tg/rates/image?"
f"base={base}"
Expand Down
4 changes: 1 addition & 3 deletions aiosend/tools/get_rates_image.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from aiosend.enums import Asset, Fiat

if TYPE_CHECKING:
import aiosend
from aiosend.enums import Asset, Fiat


class GetRatesImage:
Expand Down

0 comments on commit 90af6cb

Please sign in to comment.