Skip to content

Commit

Permalink
architecture change
Browse files Browse the repository at this point in the history
  • Loading branch information
DroidZed committed Apr 10, 2024
1 parent 36584f6 commit 5b5f3d2
Show file tree
Hide file tree
Showing 36 changed files with 111 additions and 104 deletions.
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

26 changes: 9 additions & 17 deletions coinpaprika_async_client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
from .__version__ import __title__, __description__, __version__

from .api import (
CoinPaprikaAsyncClient,
CoinpaprikaAPI,
CoinsEndpoint,
ExchangesEndpoint,
KeyEndpoint,
MarketEndpoint,
MiscellaneousEndpoints,
PeopleEndpoint,
TagsEndpoint,
TickersEndpoint,
ApiError,
Result,
)
from .coins import *
from .exchanges import *
from .key import *
from .market import *
from .people import *
from .misc import *
from .tags import *
from .tickers import *


__all__ = [
"__description__",
"__title__",
"__version__",
"CoinPaprikaAsyncClient",
"CoinpaprikaAPI",
"CoinsEndpoint",
"ExchangesEndpoint",
"KeyEndpoint",
Expand All @@ -30,5 +23,4 @@
"TagsEndpoint",
"TickersEndpoint",
"ApiError",
"Result",
]
10 changes: 0 additions & 10 deletions coinpaprika_async_client/api/__init__.py

This file was deleted.

7 changes: 0 additions & 7 deletions coinpaprika_async_client/api/coinpaprika_api.py

This file was deleted.

13 changes: 0 additions & 13 deletions coinpaprika_async_client/api/market/api.py

This file was deleted.

3 changes: 0 additions & 3 deletions coinpaprika_async_client/api/networking_layer/__init__.py

This file was deleted.

1 change: 1 addition & 0 deletions coinpaprika_async_client/client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .coinpaprika_async_client import CoinPaprikaAsyncClient
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Optional

from . import Result, HttpAsyncClient
from ..networking_layer import HttpAsyncClient, Result


class CoinPaprikaAsyncClient:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
from ..client import CoinPaprikaAsyncClient

from ..networking_layer import Result, ApiError
from ..coinpaprika_api import CoinpaprikaAPI

from .models import *


class CoinsEndpoint(CoinpaprikaAPI):
class CoinsEndpoint:
def __init__(self) -> None:
self.__internal = CoinPaprikaAsyncClient()

async def get_all(self) -> ApiError | list[CoinItem]:
res = await self.internal.call_api("coins")
res = await self.__internal.call_api("coins")

if res.Error:
return res.Error

return [CoinItem(**e) for e in res.Data]

async def coin_by_id(self, coin_id: str) -> Result:
return await self.internal.call_api(f"coins/{coin_id}")
return await self.__internal.call_api(f"coins/{coin_id}")

async def tweets_of_coin(
self, coin_id: str
Expand All @@ -23,7 +28,7 @@ async def tweets_of_coin(
Args:
coin_id: Required id for the coin
"""
res = await self.internal.call_api(f"coins/{coin_id}/twitter")
res = await self.__internal.call_api(f"coins/{coin_id}/twitter")

if res.Error:
return res.Error
Expand All @@ -38,7 +43,7 @@ async def events_of_coin(
Args:
coin_id: Required id for the coin
"""
res = await self.internal.call_api(f"coins/{coin_id}/events")
res = await self.__internal.call_api(f"coins/{coin_id}/events")

if res.Error:
return res.Error
Expand All @@ -53,7 +58,7 @@ async def exchanges_of_coin(
Args:
coin_id: Required id for the coin
"""
res = await self.internal.call_api(f"coins/{coin_id}/exchanges")
res = await self.__internal.call_api(f"coins/{coin_id}/exchanges")

if res.Error:
return res.Error
Expand All @@ -77,7 +82,7 @@ async def markets_of_coin(
coin_id: Required id for the coin
quotes: Comma separated list of quotes to return. Currently allowed values: BTC, ETH, USD, EUR, PLN, KRW, GBP, CAD, JPY, RUB, TRY, NZD, AUD, CHF, UAH, HKD, SGD, NGN, PHP, MXN, BRL, THB, CLP, CNY, CZK, DKK, HUF, IDR, ILS, INR, MYR, NOK, PKR, SEK, TWD, ZAR, VND, BOB, COP, PEN, ARS and ISK.
"""
res = await self.internal.call_api(
res = await self.__internal.call_api(
f"coins/{coin_id}/markets", quotes=quotes
)

Expand Down Expand Up @@ -115,7 +120,7 @@ async def latest_ohlcv(
coin_id: Required id for the coin
quote: returned data quote (available values: usd & btc).
"""
res = await self.internal.call_api(
res = await self.__internal.call_api(
f"coins/{coin_id}/ohlcv/latest",
quote=quote,
)
Expand All @@ -141,7 +146,7 @@ async def historical_ohlcv(
interval: returned OHLCV point interval (available values: 15m, 30m, 1h, 6h, 12h, 24h)
quote: returned data quote (available values: usd & btc)
"""
res = await self.internal.call_api(
res = await self.__internal.call_api(
f"coins/{coin_id}/ohlcv/historical",
start=start,
end=end,
Expand All @@ -160,7 +165,7 @@ async def ohlcv_of_today(
coin_id: Required id for the coin
quote: returned data quote (available values: usd & btc)
"""
res = await self.internal.call_api(
res = await self.__internal.call_api(
f"coins/{coin_id}/ohlcv/today",
quote=quote,
)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from typing import Optional, Any
from typing import Any

from coinpaprika_async_client.api.networking_layer.http_models import ApiError
from ..client import CoinPaprikaAsyncClient

from ..networking_layer import ApiError

from ..coinpaprika_api import CoinpaprikaAPI
from .models import *


class ExchangesEndpoint(CoinpaprikaAPI):
class ExchangesEndpoint:
def __init__(self) -> None:
self.__internal = CoinPaprikaAsyncClient()

async def exchange_list(self, **params: Any) -> ApiError | list[Exchange]:
res = await self.internal.call_api("exchanges", **params)
res = await self.__internal.call_api("exchanges", **params)

if res.Error:
return res.Error
Expand All @@ -18,7 +22,9 @@ async def exchange_list(self, **params: Any) -> ApiError | list[Exchange]:
async def get_exchange(
self, exchange_id: str, **params: Any
) -> ApiError | Exchange:
res = await self.internal.call_api(f"exchanges/{exchange_id}", **params)
res = await self.__internal.call_api(
f"exchanges/{exchange_id}", **params
)

if res.Error:
return res.Error
Expand All @@ -28,7 +34,7 @@ async def get_exchange(
async def exchange_markets(
self, exchange_id: str, **params: Any
) -> ApiError | ExchangeMarket:
res = await self.internal.call_api(
res = await self.__internal.call_api(
f"exchanges/{exchange_id}/markets", **params
)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
from typing import Dict, Any

from ..client import CoinPaprikaAsyncClient

from ..networking_layer import ApiError
from ..coinpaprika_api import CoinpaprikaAPI

from .models import KeyInfo, APIUsage, CurrentMonthUsage


class KeyEndpoint(CoinpaprikaAPI):
class KeyEndpoint:
def __init__(self) -> None:
self.__internal = CoinPaprikaAsyncClient()

async def get_key_info(self) -> ApiError | KeyInfo:
res = await self.internal.call_api("key/info")
res = await self.__internal.call_api("key/info")

if res.Error:
return res.Error
Expand Down
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions coinpaprika_async_client/market/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from ..client import CoinPaprikaAsyncClient

from ..networking_layer import ApiError

from .models import MarketData


class MarketEndpoint:
def __init__(self) -> None:
self.__internal = CoinPaprikaAsyncClient()

async def get_market_info(self) -> ApiError | MarketData:
res = await self.__internal.call_api("global")

if res.Error:
return res.Error

return MarketData(**res.Data)
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
from typing import Optional, Any, Dict, List

from ..client import CoinPaprikaAsyncClient

from ..networking_layer import ApiError
from ..coinpaprika_api import CoinpaprikaAPI

from .models import *


class MiscellaneousEndpoints(CoinpaprikaAPI):
class MiscellaneousEndpoints:
def __init__(self) -> None:
self.__internal = CoinPaprikaAsyncClient()

async def people(self, person_id: str) -> ApiError | list[PeopleItem]:
res = await self.internal.call_api(f"people/{person_id}")
res = await self.__internal.call_api(f"people/{person_id}")

if res.Error:
return res.Error
Expand Down Expand Up @@ -58,7 +63,7 @@ async def search(
Returns:
A list of the search result items.
"""
res = await self.internal.call_api(
res = await self.__internal.call_api(
"search",
q=q,
c=categories,
Expand Down Expand Up @@ -87,7 +92,7 @@ async def price_converter(
quote_currency_id: str,
amount: Optional[int] = 0,
) -> ApiError | ConvertResult:
res = await self.internal.call_api(
res = await self.__internal.call_api(
"price-converter",
base_currency_id=base_currency_id,
quote_currency_id=quote_currency_id,
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions coinpaprika_async_client/networking_layer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .http_async_client import *
from .http_models import *
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
from typing import Any, Dict, List

from ..client import CoinPaprikaAsyncClient

from ..networking_layer import ApiError
from ..coinpaprika_api import CoinpaprikaAPI

from .models import *


class PeopleEndpoint(CoinpaprikaAPI):
class PeopleEndpoint:
def __init__(self) -> None:
self.__internal = CoinPaprikaAsyncClient()

async def people(self, person_id: str) -> ApiError | list[PeopleItem]:
res = await self.internal.call_api(f"people/{person_id}")
res = await self.__internal.call_api(f"people/{person_id}")

if res.Error:
return res.Error
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
from typing import Dict, List, Any, Optional

from ..client import CoinPaprikaAsyncClient

from ..networking_layer import ApiError
from ..coinpaprika_api import CoinpaprikaAPI

from .models import *


class TagsEndpoint(CoinpaprikaAPI):
class TagsEndpoint:
def __init__(self) -> None:
self.__internal = CoinPaprikaAsyncClient()

async def tags(
self, additional_fields: Optional[str] = None
) -> ApiError | list[Tag]:
res = await self.internal.call_api(
res = await self.__internal.call_api(
"tags", additional_fields=additional_fields
)

Expand All @@ -23,7 +28,7 @@ async def tags(
async def tag(
self, tag_id: str, additional_fields: Optional[str] = None
) -> ApiError | Tag:
res = await self.internal.call_api(
res = await self.__internal.call_api(
f"tags/{tag_id}", additional_fields=additional_fields
)

Expand Down
File renamed without changes.
Loading

0 comments on commit 5b5f3d2

Please sign in to comment.