From 69da1bbf095df74e9e4dc2d28f8aab2e0d68a79d Mon Sep 17 00:00:00 2001 From: ljnsn Date: Thu, 7 Mar 2024 19:14:53 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=20refactor:=20rename=20ex?= =?UTF-8?q?change=20rate=20operations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 ++-- ...aserequest.md => getv1baseratesrequest.md} | 2 +- ...eresponse.md => getv1baseratesresponse.md} | 2 +- ...onse.md => getv1historyperiodsresponse.md} | 2 +- ...yrequest.md => getv1pairhistoryrequest.md} | 2 +- ...esponse.md => getv1pairhistoryresponse.md} | 2 +- ...request.md => getv1specificraterequest.md} | 2 +- ...sponse.md => getv1specificrateresponse.md} | 2 +- docs/sdks/exchangerates/README.md | 40 +++++++++---------- src/coinapi/exchange_rates.py | 32 +++++++-------- src/coinapi/models/operations/__init__.py | 26 +++++++----- ...asset_id_base_.py => get_v1_base_rates.py} | 12 ++---- ...y_periods.py => get_v1_history_periods.py} | 4 +- ...uote_history.py => get_v1_pair_history.py} | 17 ++------ ...ecific_rate.py => get_v1_specific_rate.py} | 4 +- tests/test_exchange_rates.py | 28 ++++++------- 16 files changed, 86 insertions(+), 99 deletions(-) rename docs/models/operations/{getv1exchangerateassetidbaserequest.md => getv1baseratesrequest.md} (98%) rename docs/models/operations/{getv1exchangerateassetidbaseresponse.md => getv1baseratesresponse.md} (98%) rename docs/models/operations/{getv1exchangeratehistoryperiodsresponse.md => getv1historyperiodsresponse.md} (98%) rename docs/models/operations/{getv1exchangerateassetidbaseassetidquotehistoryrequest.md => getv1pairhistoryrequest.md} (98%) rename docs/models/operations/{getv1exchangerateassetidbaseassetidquotehistoryresponse.md => getv1pairhistoryresponse.md} (98%) rename docs/models/operations/{getspecificraterequest.md => getv1specificraterequest.md} (98%) rename docs/models/operations/{getspecificrateresponse.md => getv1specificrateresponse.md} (98%) rename src/coinapi/models/operations/{get_v1_exchangerate_asset_id_base_.py => get_v1_base_rates.py} (86%) rename src/coinapi/models/operations/{get_v1_exchangerate_history_periods.py => get_v1_history_periods.py} (80%) rename src/coinapi/models/operations/{get_v1_exchangerate_asset_id_base_asset_id_quote_history.py => get_v1_pair_history.py} (87%) rename src/coinapi/models/operations/{get_specific_rate.py => get_v1_specific_rate.py} (93%) diff --git a/README.md b/README.md index b04bffe..a2a7e3e 100644 --- a/README.md +++ b/README.md @@ -47,10 +47,10 @@ if res.content is not None: ### [exchange_rates](docs/sdks/exchangerates/README.md) -* [get_specific_rate](docs/sdks/exchangerates/README.md#get_specific_rate) - [exchange rates] Get specific rate -* [get_v1_exchangerate_asset_id_base](docs/sdks/exchangerates/README.md#get_v1_exchangerate_asset_id_base) - [exchange rates] Get all current rates -* [get_v1_exchangerate_history_periods](docs/sdks/exchangerates/README.md#get_v1_exchangerate_history_periods) - [exchange rates] Timeseries periods -* [get_v1_exchangerate_asset_id_base_asset_id_quote_history](docs/sdks/exchangerates/README.md#get_v1_exchangerate_asset_id_base_asset_id_quote_history) - [exchange rates] Timeseries data +* [get_v1_specific_rate](docs/sdks/exchangerates/README.md#get_v1_specific_rate) - [exchange rates] Get specific rate +* [get_v1_base_rates](docs/sdks/exchangerates/README.md#get_v1_base_rates) - [exchange rates] Get all current rates +* [get_v1_history_periods](docs/sdks/exchangerates/README.md#get_v1_history_periods) - [exchange rates] Timeseries periods +* [get_v1_pair_history](docs/sdks/exchangerates/README.md#get_v1_pair_history) - [exchange rates] Timeseries data ### [indexes](docs/sdks/indexes/README.md) diff --git a/docs/models/operations/getv1exchangerateassetidbaserequest.md b/docs/models/operations/getv1baseratesrequest.md similarity index 98% rename from docs/models/operations/getv1exchangerateassetidbaserequest.md rename to docs/models/operations/getv1baseratesrequest.md index 4fd3211..9309722 100644 --- a/docs/models/operations/getv1exchangerateassetidbaserequest.md +++ b/docs/models/operations/getv1baseratesrequest.md @@ -1,4 +1,4 @@ -# GetV1ExchangerateAssetIDBaseRequest +# GetV1BaseRatesRequest ## Fields diff --git a/docs/models/operations/getv1exchangerateassetidbaseresponse.md b/docs/models/operations/getv1baseratesresponse.md similarity index 98% rename from docs/models/operations/getv1exchangerateassetidbaseresponse.md rename to docs/models/operations/getv1baseratesresponse.md index cedf3c9..bf1208e 100644 --- a/docs/models/operations/getv1exchangerateassetidbaseresponse.md +++ b/docs/models/operations/getv1baseratesresponse.md @@ -1,4 +1,4 @@ -# GetV1ExchangerateAssetIDBaseResponse +# GetV1BaseRatesResponse ## Fields diff --git a/docs/models/operations/getv1exchangeratehistoryperiodsresponse.md b/docs/models/operations/getv1historyperiodsresponse.md similarity index 98% rename from docs/models/operations/getv1exchangeratehistoryperiodsresponse.md rename to docs/models/operations/getv1historyperiodsresponse.md index d4a41a0..1b16f67 100644 --- a/docs/models/operations/getv1exchangeratehistoryperiodsresponse.md +++ b/docs/models/operations/getv1historyperiodsresponse.md @@ -1,4 +1,4 @@ -# GetV1ExchangerateHistoryPeriodsResponse +# GetV1HistoryPeriodsResponse ## Fields diff --git a/docs/models/operations/getv1exchangerateassetidbaseassetidquotehistoryrequest.md b/docs/models/operations/getv1pairhistoryrequest.md similarity index 98% rename from docs/models/operations/getv1exchangerateassetidbaseassetidquotehistoryrequest.md rename to docs/models/operations/getv1pairhistoryrequest.md index 7ba57a6..a5f6a08 100644 --- a/docs/models/operations/getv1exchangerateassetidbaseassetidquotehistoryrequest.md +++ b/docs/models/operations/getv1pairhistoryrequest.md @@ -1,4 +1,4 @@ -# GetV1ExchangerateAssetIDBaseAssetIDQuoteHistoryRequest +# GetV1PairHistoryRequest ## Fields diff --git a/docs/models/operations/getv1exchangerateassetidbaseassetidquotehistoryresponse.md b/docs/models/operations/getv1pairhistoryresponse.md similarity index 98% rename from docs/models/operations/getv1exchangerateassetidbaseassetidquotehistoryresponse.md rename to docs/models/operations/getv1pairhistoryresponse.md index 2eac021..9c2a1af 100644 --- a/docs/models/operations/getv1exchangerateassetidbaseassetidquotehistoryresponse.md +++ b/docs/models/operations/getv1pairhistoryresponse.md @@ -1,4 +1,4 @@ -# GetV1ExchangerateAssetIDBaseAssetIDQuoteHistoryResponse +# GetV1PairHistoryResponse ## Fields diff --git a/docs/models/operations/getspecificraterequest.md b/docs/models/operations/getv1specificraterequest.md similarity index 98% rename from docs/models/operations/getspecificraterequest.md rename to docs/models/operations/getv1specificraterequest.md index 0f6c59a..a657e7b 100644 --- a/docs/models/operations/getspecificraterequest.md +++ b/docs/models/operations/getv1specificraterequest.md @@ -1,4 +1,4 @@ -# GetSpecificRateRequest +# GetV1SpecificRateRequest ## Fields diff --git a/docs/models/operations/getspecificrateresponse.md b/docs/models/operations/getv1specificrateresponse.md similarity index 98% rename from docs/models/operations/getspecificrateresponse.md rename to docs/models/operations/getv1specificrateresponse.md index 0393309..bfb64ba 100644 --- a/docs/models/operations/getspecificrateresponse.md +++ b/docs/models/operations/getv1specificrateresponse.md @@ -1,4 +1,4 @@ -# GetSpecificRateResponse +# GetV1SpecificRateResponse ## Fields diff --git a/docs/sdks/exchangerates/README.md b/docs/sdks/exchangerates/README.md index 2175823..c31ed17 100644 --- a/docs/sdks/exchangerates/README.md +++ b/docs/sdks/exchangerates/README.md @@ -26,12 +26,12 @@ Algorithm is described below: ### Available Operations -* [get_specific_rate](#get_specific_rate) - [exchange rates] Get specific rate -* [get_v1_exchangerate_asset_id_base](#get_v1_exchangerate_asset_id_base) - [exchange rates] Get all current rates -* [get_v1_exchangerate_history_periods](#get_v1_exchangerate_history_periods) - [exchange rates] Timeseries periods -* [get_v1_exchangerate_asset_id_base_asset_id_quote_history](#get_v1_exchangerate_asset_id_base_asset_id_quote_history) - [exchange rates] Timeseries data +* [get_v1_specific_rate](#get_v1_specific_rate) - [exchange rates] Get specific rate +* [get_v1_base_rates](#get_v1_base_rates) - [exchange rates] Get all current rates +* [get_v1_history_periods](#get_v1_history_periods) - [exchange rates] Timeseries periods +* [get_v1_pair_history](#get_v1_pair_history) - [exchange rates] Timeseries data -## get_specific_rate +## get_v1_specific_rate Retrieves the exchange rate for a specific base and quote asset at a given time or the current rate. @@ -48,8 +48,7 @@ s = coinapi.CoinAPI( api_key="", ) - -res = s.exchange_rates.get_specific_rate(asset_id_base='', asset_id_quote='', time='') +res = s.exchange_rates.get_v1_specific_rate(asset_id_base='', asset_id_quote='', time='') if res.content is not None: # handle response @@ -67,14 +66,14 @@ if res.content is not None: ### Response -**[operations.GetSpecificRateResponse](../../models/operations/getspecificrateresponse.md)** +**[operations.GetV1SpecificRateResponse](../../models/operations/getv1specificrateresponse.md)** ### Errors | Error Object | Status Code | Content Type | | --------------- | --------------- | --------------- | | errors.CoinAPIError | 4x-5xx | */* | -## get_v1_exchangerate_asset_id_base +## get_v1_base_rates Get the current exchange rate between requested asset and all other assets. @@ -95,8 +94,8 @@ s = coinapi.CoinAPI( api_key="", ) - -res = s.exchange_rates.get_v1_exchangerate_asset_id_base(asset_id_base='', filter_asset_id='', invert=False, time='') +res = s.exchange_rates.get_v1_base_rates(asset_id_base='', filter_asset_id='', invert=False, + time='') if res.content is not None: # handle response @@ -115,14 +114,14 @@ if res.content is not None: ### Response -**[operations.GetV1ExchangerateAssetIDBaseResponse](../../models/operations/getv1exchangerateassetidbaseresponse.md)** +**[operations.GetV1BaseRatesResponse](../../models/operations/getv1baseratesresponse.md)** ### Errors | Error Object | Status Code | Content Type | | --------------- | --------------- | --------------- | | errors.CoinAPIError | 4x-5xx | */* | -## get_v1_exchangerate_history_periods +## get_v1_history_periods You can also obtain historical exchange rates of any asset pair, grouped into time periods. Get full list of supported time periods available for requesting exchange rates historical timeseries data. @@ -144,8 +143,7 @@ s = coinapi.CoinAPI( api_key="", ) - -res = s.exchange_rates.get_v1_exchangerate_history_periods() +res = s.exchange_rates.get_v1_history_periods() if res.content is not None: # handle response @@ -155,14 +153,14 @@ if res.content is not None: ### Response -**[operations.GetV1ExchangerateHistoryPeriodsResponse](../../models/operations/getv1exchangeratehistoryperiodsresponse.md)** +**[operations.GetV1HistoryPeriodsResponse](../../models/operations/getv1historyperiodsresponse.md)** ### Errors | Error Object | Status Code | Content Type | | --------------- | --------------- | --------------- | | errors.CoinAPIError | 4x-5xx | */* | -## get_v1_exchangerate_asset_id_base_asset_id_quote_history +## get_v1_pair_history Get the historical exchange rates between two assets in the form of the timeseries. @@ -176,12 +174,12 @@ s = coinapi.CoinAPI( api_key="", ) -req = operations.GetV1ExchangerateAssetIDBaseAssetIDQuoteHistoryRequest( +req = operations.GetV1PairHistoryRequest( asset_id_base='', asset_id_quote='', ) -res = s.exchange_rates.get_v1_exchangerate_asset_id_base_asset_id_quote_history(req) +res = s.exchange_rates.get_v1_pair_history(req) if res.content is not None: # handle response @@ -192,12 +190,12 @@ if res.content is not None: | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `request` | [operations.GetV1ExchangerateAssetIDBaseAssetIDQuoteHistoryRequest](../../models/operations/getv1exchangerateassetidbaseassetidquotehistoryrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `request` | [operations.GetV1PairHistoryRequest](../../models/operations/getv1pairhistoryrequest.md) | :heavy_check_mark: | The request object to use for the request. | ### Response -**[operations.GetV1ExchangerateAssetIDBaseAssetIDQuoteHistoryResponse](../../models/operations/getv1exchangerateassetidbaseassetidquotehistoryresponse.md)** +**[operations.GetV1PairHistoryResponse](../../models/operations/getv1pairhistoryresponse.md)** ### Errors | Error Object | Status Code | Content Type | diff --git a/src/coinapi/exchange_rates.py b/src/coinapi/exchange_rates.py index 9fc4c68..23637f2 100644 --- a/src/coinapi/exchange_rates.py +++ b/src/coinapi/exchange_rates.py @@ -24,13 +24,13 @@ class ExchangeRates(Base): 1. By traversing the tree structure using the BFS algorithm and our secret sauce, we are able to establish the final exchange rates. """ - def get_specific_rate( + def get_v1_specific_rate( self, asset_id_base: str, asset_id_quote: str, time: str | None = None, accept_header_override: AcceptEnum | None = None, - ) -> operations.GetSpecificRateResponse: + ) -> operations.GetV1SpecificRateResponse: r"""[exchange rates] Get specific rate. Retrieves the exchange rate for a specific base and quote asset at a given time or the current rate. @@ -41,23 +41,23 @@ def get_specific_rate( """ return self._make_request( "Get specific rate", - operations.GetSpecificRateRequest( + operations.GetV1SpecificRateRequest( asset_id_base=asset_id_base, asset_id_quote=asset_id_quote, time=time, ), - operations.GetSpecificRateResponse, + operations.GetV1SpecificRateResponse, accept_header_override=accept_header_override, ) - def get_v1_exchangerate_asset_id_base( # noqa: PLR0913 + def get_v1_base_rates( # noqa: PLR0913 self, asset_id_base: str, filter_asset_id: str | None = None, invert: bool | None = None, time: str | None = None, accept_header_override: AcceptEnum | None = None, - ) -> operations.GetV1ExchangerateAssetIDBaseResponse: + ) -> operations.GetV1BaseRatesResponse: r"""[exchange rates] Get all current rates. Get the current exchange rate between requested asset and all other assets. @@ -72,20 +72,20 @@ def get_v1_exchangerate_asset_id_base( # noqa: PLR0913 """ return self._make_request( "get_/v1/exchangerate/{asset_id_base}", - operations.GetV1ExchangerateAssetIDBaseRequest( + operations.GetV1BaseRatesRequest( asset_id_base=asset_id_base, filter_asset_id=filter_asset_id, invert=invert, time=time, ), - operations.GetV1ExchangerateAssetIDBaseResponse, + operations.GetV1BaseRatesResponse, accept_header_override=accept_header_override, ) - def get_v1_exchangerate_history_periods( + def get_v1_history_periods( self, accept_header_override: AcceptEnum | None = None, - ) -> operations.GetV1ExchangerateHistoryPeriodsResponse: + ) -> operations.GetV1HistoryPeriodsResponse: r"""[exchange rates] Timeseries periods. You can also obtain historical exchange rates of any asset pair, grouped into time periods. @@ -101,16 +101,16 @@ def get_v1_exchangerate_history_periods( """ return self._make_request( "get_/v1/exchangerate/history/periods", - operations.GetV1ExchangerateHistoryPeriodsRequest(), - operations.GetV1ExchangerateHistoryPeriodsResponse, + operations.GetV1HistoryPeriodsRequest(), + operations.GetV1HistoryPeriodsResponse, accept_header_override=accept_header_override, ) - def get_v1_exchangerate_asset_id_base_asset_id_quote_history( + def get_v1_pair_history( self, - request: operations.GetV1ExchangerateAssetIDBaseAssetIDQuoteHistoryRequest, + request: operations.GetV1PairHistoryRequest, accept_header_override: AcceptEnum | None = None, - ) -> operations.GetV1ExchangerateAssetIDBaseAssetIDQuoteHistoryResponse: + ) -> operations.GetV1PairHistoryResponse: r"""[exchange rates] Timeseries data. Get the historical exchange rates between two assets in the form of the timeseries. @@ -118,6 +118,6 @@ def get_v1_exchangerate_asset_id_base_asset_id_quote_history( return self._make_request( "get_/v1/exchangerate/{asset_id_base}/{asset_id_quote}/history", request, - operations.GetV1ExchangerateAssetIDBaseAssetIDQuoteHistoryResponse, + operations.GetV1PairHistoryResponse, accept_header_override=accept_header_override, ) diff --git a/src/coinapi/models/operations/__init__.py b/src/coinapi/models/operations/__init__.py index 59fcc01..3906208 100644 --- a/src/coinapi/models/operations/__init__.py +++ b/src/coinapi/models/operations/__init__.py @@ -3,25 +3,21 @@ __all__ = ( "CoinAPIRequest", "CoinAPIResponse", - "GetSpecificRateRequest", - "GetSpecificRateResponse", "GetV1AssetsAssetIDRequest", "GetV1AssetsAssetIDResponse", "GetV1AssetsIconsSizeRequest", "GetV1AssetsIconsSizeResponse", "GetV1AssetsRequest", "GetV1AssetsResponse", - "GetV1ExchangerateAssetIDBaseAssetIDQuoteHistoryRequest", - "GetV1ExchangerateAssetIDBaseAssetIDQuoteHistoryResponse", - "GetV1ExchangerateAssetIDBaseRequest", - "GetV1ExchangerateAssetIDBaseResponse", - "GetV1ExchangerateHistoryPeriodsResponse", + "GetV1BaseRatesRequest", + "GetV1BaseRatesResponse", "GetV1ExchangesExchangeIDRequest", "GetV1ExchangesExchangeIDResponse", "GetV1ExchangesIconsSizeRequest", "GetV1ExchangesIconsSizeResponse", "GetV1ExchangesRequest", "GetV1ExchangesResponse", + "GetV1HistoryPeriodsResponse", "GetV1IndexesIndexIDHistoryRequest", "GetV1IndexesIndexIDHistoryResponse", "GetV1IndexesIndexIDRequest", @@ -70,6 +66,8 @@ "GetV1OrderbooksSymbolIDHistoryResponse", "GetV1OrderbooksSymbolIDLatestRequest", "GetV1OrderbooksSymbolIDLatestResponse", + "GetV1PairHistoryRequest", + "GetV1PairHistoryResponse", "GetV1QuotesCurrentRequest", "GetV1QuotesCurrentResponse", "GetV1QuotesLatestRequest", @@ -80,6 +78,8 @@ "GetV1QuotesSymbolIDHistoryResponse", "GetV1QuotesSymbolIDLatestRequest", "GetV1QuotesSymbolIDLatestResponse", + "GetV1SpecificRateRequest", + "GetV1SpecificRateResponse", "GetV1SymbolsExchangeIDRequest", "GetV1SymbolsExchangeIDResponse", "GetV1SymbolsMapExchangeIDRequest", @@ -96,17 +96,16 @@ "PutV1IndexesIndexIDJSONRequest", "PutV1IndexesIndexIDJSONResponse", ) + from coinapi.models.operations.base import CoinAPIRequest, CoinAPIResponse -from coinapi.models.operations.get_specific_rate import * from coinapi.models.operations.get_v1_assets import * from coinapi.models.operations.get_v1_assets_asset_id_ import * from coinapi.models.operations.get_v1_assets_icons_size_ import * -from coinapi.models.operations.get_v1_exchangerate_asset_id_base_ import * -from coinapi.models.operations.get_v1_exchangerate_asset_id_base_asset_id_quote_history import * -from coinapi.models.operations.get_v1_exchangerate_history_periods import * +from coinapi.models.operations.get_v1_base_rates import * from coinapi.models.operations.get_v1_exchanges import * from coinapi.models.operations.get_v1_exchanges_exchange_id_ import * from coinapi.models.operations.get_v1_exchanges_icons_size_ import * +from coinapi.models.operations.get_v1_history_periods import * from coinapi.models.operations.get_v1_indexes import * from coinapi.models.operations.get_v1_indexes_index_id_ import * from coinapi.models.operations.get_v1_indexes_index_id_history import * @@ -133,11 +132,16 @@ from coinapi.models.operations.get_v1_orderbooks_symbol_id_depth_current import * from coinapi.models.operations.get_v1_orderbooks_symbol_id_history import * from coinapi.models.operations.get_v1_orderbooks_symbol_id_latest import * +from coinapi.models.operations.get_v1_pair_history import ( + GetV1PairHistoryRequest, + GetV1PairHistoryResponse, +) from coinapi.models.operations.get_v1_quotes_current import * from coinapi.models.operations.get_v1_quotes_latest import * from coinapi.models.operations.get_v1_quotes_symbol_id_current import * from coinapi.models.operations.get_v1_quotes_symbol_id_history import * from coinapi.models.operations.get_v1_quotes_symbol_id_latest import * +from coinapi.models.operations.get_v1_specific_rate import * from coinapi.models.operations.get_v1_symbols import * from coinapi.models.operations.get_v1_symbols_exchange_id_ import * from coinapi.models.operations.get_v1_symbols_map_exchange_id_ import * diff --git a/src/coinapi/models/operations/get_v1_exchangerate_asset_id_base_.py b/src/coinapi/models/operations/get_v1_base_rates.py similarity index 86% rename from src/coinapi/models/operations/get_v1_exchangerate_asset_id_base_.py rename to src/coinapi/models/operations/get_v1_base_rates.py index dd6e800..e40e6c7 100644 --- a/src/coinapi/models/operations/get_v1_exchangerate_asset_id_base_.py +++ b/src/coinapi/models/operations/get_v1_base_rates.py @@ -6,13 +6,11 @@ import msgspec -from coinapi.models.components import ( - v1_exchangeratesrate as components_v1_exchangeratesrate, -) +from coinapi.models.components import v1_exchangeratesrate from coinapi.models.operations.base import CoinAPIRequest, CoinAPIResponse -class GetV1ExchangerateAssetIDBaseRequest(CoinAPIRequest, frozen=True): +class GetV1BaseRatesRequest(CoinAPIRequest, frozen=True): """Get specific exchange rate for a specific base and quote asset at a given time or the current rate.""" method = "GET" @@ -69,10 +67,8 @@ class GetV1ExchangerateAssetIDBaseRequest(CoinAPIRequest, frozen=True): # NOTE: the spec for this response is wrong. Supposedly, the `V1ExchangeRatesRate` array is returned directly, # but the actual response is a JSON object with a `rates` field containing the array. -class GetV1ExchangerateAssetIDBaseResponse(CoinAPIResponse, omit_defaults=True): +class GetV1BaseRatesResponse(CoinAPIResponse, omit_defaults=True): """Get specific exchange rate for a specific base and quote asset at a given time or the current rate.""" - content: components_v1_exchangeratesrate.V1ExchangeRates | None = msgspec.field( - default=None, - ) + content: v1_exchangeratesrate.V1ExchangeRates | None = msgspec.field(default=None) r"""successful operation""" diff --git a/src/coinapi/models/operations/get_v1_exchangerate_history_periods.py b/src/coinapi/models/operations/get_v1_history_periods.py similarity index 80% rename from src/coinapi/models/operations/get_v1_exchangerate_history_periods.py rename to src/coinapi/models/operations/get_v1_history_periods.py index d46d5d1..a8fa620 100644 --- a/src/coinapi/models/operations/get_v1_exchangerate_history_periods.py +++ b/src/coinapi/models/operations/get_v1_history_periods.py @@ -10,14 +10,14 @@ from coinapi.models.operations.base import CoinAPIRequest, CoinAPIResponse -class GetV1ExchangerateHistoryPeriodsRequest(CoinAPIRequest, frozen=True): +class GetV1HistoryPeriodsRequest(CoinAPIRequest, frozen=True): """Get historical exchange rate data for a specific asset pair and time period.""" method = "GET" endpoint = "/v1/exchangerate/history/periods" -class GetV1ExchangerateHistoryPeriodsResponse(CoinAPIResponse, omit_defaults=True): +class GetV1HistoryPeriodsResponse(CoinAPIResponse, omit_defaults=True): """Get historical exchange rate data for a specific asset pair and time period.""" content: list[components_v1_timeseriesperiod.V1TimeseriesPeriod] | None = ( diff --git a/src/coinapi/models/operations/get_v1_exchangerate_asset_id_base_asset_id_quote_history.py b/src/coinapi/models/operations/get_v1_pair_history.py similarity index 87% rename from src/coinapi/models/operations/get_v1_exchangerate_asset_id_base_asset_id_quote_history.py rename to src/coinapi/models/operations/get_v1_pair_history.py index b6a98ea..812817d 100644 --- a/src/coinapi/models/operations/get_v1_exchangerate_asset_id_base_asset_id_quote_history.py +++ b/src/coinapi/models/operations/get_v1_pair_history.py @@ -6,16 +6,11 @@ import msgspec -from coinapi.models.components import ( - v1_exchangeratestimeseriesitem as components_v1_exchangeratestimeseriesitem, -) +from coinapi.models.components import v1_exchangeratestimeseriesitem from coinapi.models.operations.base import CoinAPIRequest, CoinAPIResponse -class GetV1ExchangerateAssetIDBaseAssetIDQuoteHistoryRequest( - CoinAPIRequest, - frozen=True, -): +class GetV1PairHistoryRequest(CoinAPIRequest, frozen=True): """Get historical exchange rate data for a specific asset pair and time period.""" method = "GET" @@ -100,14 +95,10 @@ class GetV1ExchangerateAssetIDBaseAssetIDQuoteHistoryRequest( r"""Amount of items to return (optional, mininum is 1, maximum is 100000, default value is 100, if the parameter is used then every 100 output items are counted as one request)""" -class GetV1ExchangerateAssetIDBaseAssetIDQuoteHistoryResponse( - CoinAPIResponse, - omit_defaults=True, -): +class GetV1PairHistoryResponse(CoinAPIResponse, omit_defaults=True): """Get historical exchange rate data for a specific asset pair and time period.""" content: ( - list[components_v1_exchangeratestimeseriesitem.V1ExchangeRatesTimeseriesItem] - | None + list[v1_exchangeratestimeseriesitem.V1ExchangeRatesTimeseriesItem] | None ) = msgspec.field(default=None) r"""successful operation""" diff --git a/src/coinapi/models/operations/get_specific_rate.py b/src/coinapi/models/operations/get_v1_specific_rate.py similarity index 93% rename from src/coinapi/models/operations/get_specific_rate.py rename to src/coinapi/models/operations/get_v1_specific_rate.py index f181578..07f1ca3 100644 --- a/src/coinapi/models/operations/get_specific_rate.py +++ b/src/coinapi/models/operations/get_v1_specific_rate.py @@ -10,7 +10,7 @@ from coinapi.models.operations.base import CoinAPIRequest, CoinAPIResponse -class GetSpecificRateRequest(CoinAPIRequest, frozen=True): +class GetV1SpecificRateRequest(CoinAPIRequest, frozen=True): """[exchange rates] Get specific rate.""" method = "GET" @@ -52,7 +52,7 @@ class GetSpecificRateRequest(CoinAPIRequest, frozen=True): r"""Time at which exchange rate is calculated (optional, if not supplied then current rate is returned)""" -class GetSpecificRateResponse(CoinAPIResponse, omit_defaults=True): +class GetV1SpecificRateResponse(CoinAPIResponse, omit_defaults=True): """[exchange rates] Get specific rate.""" content: components_v1_exchangerate.V1ExchangeRate | None = msgspec.field( diff --git a/tests/test_exchange_rates.py b/tests/test_exchange_rates.py index 9377b2b..173671c 100644 --- a/tests/test_exchange_rates.py +++ b/tests/test_exchange_rates.py @@ -8,9 +8,9 @@ @pytest.mark.vcr() -def test_get_specific_rate(coinapi: CoinAPI, snapshot: SnapshotAssertion) -> None: - """Test get_specific_rate.""" - response = coinapi.exchange_rates.get_specific_rate( +def test_get_v1_specific_rate(coinapi: CoinAPI, snapshot: SnapshotAssertion) -> None: + """Test get_v1_specific_rate.""" + response = coinapi.exchange_rates.get_v1_specific_rate( asset_id_base="BTC", asset_id_quote="USD", time="2021-01-01", @@ -22,12 +22,12 @@ def test_get_specific_rate(coinapi: CoinAPI, snapshot: SnapshotAssertion) -> Non @pytest.mark.vcr() -def test_get_v1_exchangerate_asset_id_base( +def test_get_v1_base_rates( coinapi: CoinAPI, snapshot: SnapshotAssertion, ) -> None: - """Test get_v1_exchangerate_asset_id_base.""" - response = coinapi.exchange_rates.get_v1_exchangerate_asset_id_base( + """Test get_v1_base_rates.""" + response = coinapi.exchange_rates.get_v1_base_rates( asset_id_base="IOTA", ) @@ -37,12 +37,12 @@ def test_get_v1_exchangerate_asset_id_base( @pytest.mark.vcr() -def test_get_v1_exchangerate_history_periods( +def test_get_v1_history_periods( coinapi: CoinAPI, snapshot: SnapshotAssertion, ) -> None: - """Test get_v1_exchangerate_history_periods.""" - response = coinapi.exchange_rates.get_v1_exchangerate_history_periods() + """Test get_v1_history_periods.""" + response = coinapi.exchange_rates.get_v1_history_periods() assert response.status_code == 200 assert response.content is not None @@ -50,21 +50,19 @@ def test_get_v1_exchangerate_history_periods( @pytest.mark.vcr() -def test_get_v1_exchangerate_asset_id_base_asset_id_quote_history( +def test_get_v1_pair_history( coinapi: CoinAPI, snapshot: SnapshotAssertion, ) -> None: """Test getting exchange rate history between two assets.""" - request = operations.GetV1ExchangerateAssetIDBaseAssetIDQuoteHistoryRequest( + request = operations.GetV1PairHistoryRequest( asset_id_base="BTC", asset_id_quote="USD", period_id="1DAY", limit=10, ) - response = ( - coinapi.exchange_rates.get_v1_exchangerate_asset_id_base_asset_id_quote_history( - request, - ) + response = coinapi.exchange_rates.get_v1_pair_history( + request, ) assert response.status_code == 200