diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ecf364d..c0a5a1c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,7 +11,9 @@ env: jobs: build-test: runs-on: ubuntu-latest - + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 - name: Set up Python @@ -25,6 +27,9 @@ jobs: code-quality: needs: build-test runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 - name: Set up Python @@ -59,6 +64,9 @@ jobs: code-coverage: needs: code-quality runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] env: STRIKE_API_KEY: ${{ secrets.STRIKE_DEV_KEY }} steps: diff --git a/poetry.lock b/poetry.lock index 44cacad..910ec21 100644 --- a/poetry.lock +++ b/poetry.lock @@ -22,7 +22,7 @@ tests-no-zope = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy [[package]] name = "babel" -version = "2.10.3" +version = "2.11.0" description = "Internationalization utilities" category = "dev" optional = false @@ -136,7 +136,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "exceptiongroup" -version = "1.0.0" +version = "1.0.1" description = "Backport of PEP 654 (exception groups)" category = "dev" optional = false @@ -186,7 +186,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [[package]] name = "importlib-metadata" -version = "4.13.0" +version = "5.0.0" description = "Read metadata from Python packages" category = "dev" optional = false @@ -397,7 +397,7 @@ vcrpy = ">=2.0.1" [[package]] name = "pytz" -version = "2022.5" +version = "2022.6" description = "World timezone definitions, modern and historical" category = "dev" optional = false @@ -487,18 +487,18 @@ test = ["cython", "html5lib", "pytest (>=4.6)", "typed_ast"] [[package]] name = "sphinx-rtd-theme" -version = "1.0.0" +version = "1.1.1" description = "Read the Docs theme for Sphinx" category = "dev" optional = false -python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*" +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7" [package.dependencies] docutils = "<0.18" -sphinx = ">=1.6" +sphinx = ">=1.6,<6" [package.extras] -dev = ["bump2version", "sphinxcontrib-httpdomain", "transifex-client"] +dev = ["bump2version", "sphinxcontrib-httpdomain", "transifex-client", "wheel"] [[package]] name = "sphinxcontrib-applehelp" @@ -682,8 +682,8 @@ attrs = [ {file = "attrs-22.1.0.tar.gz", hash = "sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6"}, ] babel = [ - {file = "Babel-2.10.3-py3-none-any.whl", hash = "sha256:ff56f4892c1c4bf0d814575ea23471c230d544203c7748e8c68f0089478d48eb"}, - {file = "Babel-2.10.3.tar.gz", hash = "sha256:7614553711ee97490f732126dc077f8d0ae084ebc6a96e23db1482afabdb2c51"}, + {file = "Babel-2.11.0-py3-none-any.whl", hash = "sha256:1ad3eca1c885218f6dce2ab67291178944f810a10a9b5f3cb8382a5a232b64fe"}, + {file = "Babel-2.11.0.tar.gz", hash = "sha256:5ef4b3226b0180dedded4229651c8b0e1a3a6a2837d45a073272f313e4cf97f6"}, ] bandit = [ {file = "bandit-1.7.4-py3-none-any.whl", hash = "sha256:412d3f259dab4077d0e7f0c11f50f650cc7d10db905d98f6520a95a18049658a"}, @@ -785,8 +785,8 @@ docutils = [ {file = "docutils-0.17.1.tar.gz", hash = "sha256:686577d2e4c32380bb50cbb22f575ed742d58168cee37e99117a854bcd88f125"}, ] exceptiongroup = [ - {file = "exceptiongroup-1.0.0-py3-none-any.whl", hash = "sha256:2ac84b496be68464a2da60da518af3785fff8b7ec0d090a581604bc870bdee41"}, - {file = "exceptiongroup-1.0.0.tar.gz", hash = "sha256:affbabf13fb6e98988c38d9c5650e701569fe3c1de3233cfb61c5f33774690ad"}, + {file = "exceptiongroup-1.0.1-py3-none-any.whl", hash = "sha256:4d6c0aa6dd825810941c792f53d7b8d71da26f5e5f84f20f9508e8f2d33b140a"}, + {file = "exceptiongroup-1.0.1.tar.gz", hash = "sha256:73866f7f842ede6cb1daa42c4af078e2035e5f7607f0e2c762cc51bb31bbe7b2"}, ] gitdb = [ {file = "gitdb-4.0.9-py3-none-any.whl", hash = "sha256:8033ad4e853066ba6ca92050b9df2f89301b8fc8bf7e9324d412a63f8bf1a8fd"}, @@ -805,8 +805,8 @@ imagesize = [ {file = "imagesize-1.4.1.tar.gz", hash = "sha256:69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a"}, ] importlib-metadata = [ - {file = "importlib_metadata-4.13.0-py3-none-any.whl", hash = "sha256:8a8a81bcf996e74fee46f0d16bd3eaa382a7eb20fd82445c3ad11f4090334116"}, - {file = "importlib_metadata-4.13.0.tar.gz", hash = "sha256:dd0173e8f150d6815e098fd354f6414b0f079af4644ddfe90c71e2fc6174346d"}, + {file = "importlib_metadata-5.0.0-py3-none-any.whl", hash = "sha256:ddb0e35065e8938f867ed4928d0ae5bf2a53b7773871bfe6bcc7e4fcdc7dea43"}, + {file = "importlib_metadata-5.0.0.tar.gz", hash = "sha256:da31db32b304314d044d3c12c79bd59e307889b287ad12ff387b3500835fc2ab"}, ] iniconfig = [ {file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"}, @@ -1006,8 +1006,8 @@ pytest-recording = [ {file = "pytest_recording-0.12.1-py3-none-any.whl", hash = "sha256:6b5546b822b270b8d7338f70950453be45e4aa5bfd884d97583dfa47288380f9"}, ] pytz = [ - {file = "pytz-2022.5-py2.py3-none-any.whl", hash = "sha256:335ab46900b1465e714b4fda4963d87363264eb662aab5e65da039c25f1f5b22"}, - {file = "pytz-2022.5.tar.gz", hash = "sha256:c4d88f472f54d615e9cd582a5004d1e5f624854a6a27a6211591c251f22a6914"}, + {file = "pytz-2022.6-py2.py3-none-any.whl", hash = "sha256:222439474e9c98fced559f1709d89e6c9cbf8d79c794ff3eb9f8800064291427"}, + {file = "pytz-2022.6.tar.gz", hash = "sha256:e89512406b793ca39f5971bc999cc538ce125c0e51c27941bef4568b460095e2"}, ] pyyaml = [ {file = "PyYAML-6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53"}, @@ -1072,8 +1072,8 @@ sphinx = [ {file = "sphinx-5.3.0-py3-none-any.whl", hash = "sha256:060ca5c9f7ba57a08a1219e547b269fadf125ae25b06b9fa7f66768efb652d6d"}, ] sphinx-rtd-theme = [ - {file = "sphinx_rtd_theme-1.0.0-py2.py3-none-any.whl", hash = "sha256:4d35a56f4508cfee4c4fb604373ede6feae2a306731d533f409ef5c3496fdbd8"}, - {file = "sphinx_rtd_theme-1.0.0.tar.gz", hash = "sha256:eec6d497e4c2195fa0e8b2016b337532b8a699a68bcb22a512870e16925c6a5c"}, + {file = "sphinx_rtd_theme-1.1.1-py2.py3-none-any.whl", hash = "sha256:31faa07d3e97c8955637fc3f1423a5ab2c44b74b8cc558a51498c202ce5cbda7"}, + {file = "sphinx_rtd_theme-1.1.1.tar.gz", hash = "sha256:6146c845f1e1947b3c3dd4432c28998a1693ccc742b4f9ad7c63129f0757c103"}, ] sphinxcontrib-applehelp = [ {file = "sphinxcontrib-applehelp-1.0.2.tar.gz", hash = "sha256:a072735ec80e7675e3f432fcae8610ecf509c5f1869d17e2eecff44389cdbc58"}, diff --git a/pyproject.toml b/pyproject.toml index 8452f8e..de78918 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "strike-api" -version = "0.2.0" +version = "0.2.1" description = "A python client for the strike api" authors = ["Thomas Cross "] readme = "README.md" diff --git a/strike_api/accounts.py b/strike_api/accounts.py index 11537b7..052dd60 100644 --- a/strike_api/accounts.py +++ b/strike_api/accounts.py @@ -15,7 +15,7 @@ def get_account( handle (typing.Optional[str]): Handle attached to the account to fetch Returns: - dict: account schema + Account: account schema """ url = "" diff --git a/strike_api/base.py b/strike_api/base.py index 1b62667..fa1f0bb 100644 --- a/strike_api/base.py +++ b/strike_api/base.py @@ -9,10 +9,13 @@ def set_default_headers( """Sets the default headers for strike api HTTP requests Args: - headers (typing.Optional[dict], optional): HTTP Headers. Defaults to None. + headers (typing.Optional[typing.Dict[str, str]], optional): HTTP Headers. Defaults to None. + + Raises: + EnvironmentError: When STRIKE_API_KEY is not found in system environment variables Returns: - dict: headers with default headers included + typing.Dict[str, str]: headers with default headers included """ strike_api_key = os.environ.get("STRIKE_API_KEY") if not strike_api_key: @@ -41,17 +44,13 @@ def call_api( Args: method (str): HTTP Method url (str): Fully qualifed url to interact with a strike endpoint - headers (typing.Optional[dict], optional): HTTP Headers. Defaults to None. - params (typing.Optional[typing.Union[dict, str]], optional): params to pass to Strike as query string. Defaults to None. - data (typing.Optional[typing.Union[dict, str]], optional): Data to pass to Strike as body. Defaults to None. - - Raises: - EnvironmentError: The Strike API key must be in env + headers (typing.Optional[typing.Dict[str, str]], optional): HTTP Headers. Defaults to None. + params (typing.Optional[typing.Union[typing.Dict[str, typing.Any], str]], optional): params to pass to Strike as query string. Defaults to None. + data (typing.Optional[typing.Union[typing.Dict[str, str], str]], optional): Data to pass to Strike as body. Defaults to None. Returns: - typing.Any: response from api call + typing.Union[ typing.Dict[str, typing.Any], typing.List[typing.Dict[str, typing.Any]] ]: response from api call """ - headers = set_default_headers(headers) response = requests.request(method, url, headers=headers, params=params, data=data) response.raise_for_status() diff --git a/strike_api/events.py b/strike_api/events.py index 3ffb6c6..60627ae 100644 --- a/strike_api/events.py +++ b/strike_api/events.py @@ -6,13 +6,13 @@ def get_event( event_id: str, ) -> Event: - """Find event by id + """Finds an event by event id. Args: - event_id (str): Event id + event_id (str): id of the event Returns: - dict: event schema + Event: an event object """ url = f"https://api.strike.me/v1/events/{event_id}" @@ -26,18 +26,18 @@ def get_events( skip: typing.Optional[int] = None, top: typing.Optional[int] = None, ) -> EventItems: - """Get Events + """Gets a list of events matching optional search criteria. Required scopes: partner.webhooks.manage OData filtering syntax can be seen `here `_. Ordering syntax can be seen `here `_. Args: - filter_ (str, optional): Filter the results using OData syntax. Supported properties: created, eventType, deliverySuccess. Defaults to None. - orderby (str, optional): Order the results using OData syntax. Supported properties: created. Defaults to None. - skip (int, optional): Skip the specified number of entries. Defaults to None. - top (int, optional): Get the top X number of records. Default value: 50. Max value: 100. Defaults to None. + filter_ (typing.Optional[str], optional): Filter the results using OData syntax. Supported properties: created, eventType, deliverySuccess.. Defaults to None. + orderby (typing.Optional[str], optional): Order the results using OData syntax. Supported properties: created.. Defaults to None. + skip (typing.Optional[int], optional): Skip the specified number of entries.. Defaults to None. + top (typing.Optional[int], optional): Get the top X number of records. Default value: 50. Max value: 100.. Defaults to None. Returns: - dict: events + EventItems: list of events and the count """ url = "https://api.strike.me/v1/events" diff --git a/strike_api/invoices.py b/strike_api/invoices.py index 96595be..ce7516e 100644 --- a/strike_api/invoices.py +++ b/strike_api/invoices.py @@ -12,18 +12,18 @@ def get_invoices( skip: typing.Optional[int] = None, top: typing.Optional[int] = None, ) -> InvoiceItems: - """Get Invoices + """Get invoices with optional search criteria. Required scopes: partner.webhooks.manage OData filtering syntax can be seen `here `_. Ordering syntax can be seen `here `_. Args: - filter_ (str, optional): Filter the results using OData syntax. Supported properties: invoiceId, created, currency, state, issuerId, receiverId, payerId, correlationId. Defaults to None. - orderby (str, optional): Order the results using OData syntax. Supported properties: created. Defaults to None. - skip (int, optional): Skip the specified number of entries. Defaults to None. - top (int, optional): Get the top X number of records. Default value: 50. Max value: 100. Defaults to None. + filter_ (typing.Optional[str], optional): Filter the results using OData syntax. Supported properties: invoiceId, created, currency, state, issuerId, receiverId, payerId, correlationId.. Defaults to None. + orderby (typing.Optional[str], optional): Order the results using OData syntax. Supported properties: created. Defaults to None. + skip (typing.Optional[int], optional): Skip the specified number of entries. Defaults to None. + top (typing.Optional[int], optional): Get the top X number of records. Default value: 50. Max value: 100. Defaults to None. Returns: - dict: invoices + InvoiceItems: List of invoices and a count """ url = "https://api.strike.me/v1/invoices" @@ -34,13 +34,13 @@ def get_invoices( def get_invoice(invoice_id: str) -> Invoice: - """get invoice by id + """Gets an invoice by it's id Args: - invoice_id (str): Invoice id + invoice_id (str): An invoice id Returns: - dict: invoice + Invoice: invoice """ url = f"https://api.strike.me/v1/invoices/{invoice_id}" @@ -56,18 +56,17 @@ def issue_invoice( amount: typing.Optional[str] = None, ) -> Invoice: """Issue a new invoice - - Only currencies which are invoiceable for the caller's account can be used. Invoiceable currencies can be found using get account profile endpoint. + Only currencies which are invoiceable for the caller's account can be used. Invoiceable currencies can be found using get account profile endpoint. Args: handle (typing.Optional[str], optional): handle, if specifying a receiver. Defaults to None. - correlation_id (str, optional): Invoice correlation id. Must be a unique value. Can be used to correlate the invoice with an external entity. Defaults to None. - description (str, optional): Invoice description. Defaults to None. - currency (str, optional): Currency code [BTC, USD, EUR, USDT, GBP]. Defaults to None. - amount (str, optional): Currency amount in decimal format. Defaults to None. + correlation_id (typing.Optional[str], optional): Invoice correlation id. Must be a unique value. Can be used to correlate the invoice with an external entity. Defaults to None. + description (typing.Optional[str], optional): Invoice description. Defaults to None. + currency (typing.Optional[str], optional): Currency code [BTC, USD, EUR, USDT, GBP]. Defaults to None. + amount (typing.Optional[str], optional): Currency amount in decimal format. Defaults to None. Returns: - dict: invoice + Invoice: _description_ """ if handle: url = f"https://api.strike.me/v1/invoices/handle/{handle}" @@ -95,7 +94,7 @@ def issue_quote(invoice_id: str) -> Quote: invoice_id (str): Id of invoice for which the quote is requested Returns: - dict: quote + Quote: quote """ url = f"https://api.strike.me/v1/invoices/{invoice_id}/quote" @@ -112,7 +111,7 @@ def cancel_invoice(invoice_id: str) -> Invoice: invoice_id (str): Id of invoice for which the cancellation is requested Returns: - dict: invoice + Invoice: invoice """ url = f"https://api.strike.me/v1/invoices/{invoice_id}/cancel" diff --git a/strike_api/models/events.py b/strike_api/models/events.py index 5f882ea..05abadd 100644 --- a/strike_api/models/events.py +++ b/strike_api/models/events.py @@ -21,10 +21,10 @@ class Event(StrikeAPIModel): class Events(StrikeAPIModel): __root__: typing.List[Event] - def __iter__(self): + def __iter__(self) -> typing.Iterator[Event]: # type: ignore return iter(self.__root__) - def __getitem__(self, index): + def __getitem__(self, index: int): return self.__root__[index] diff --git a/strike_api/models/generic.py b/strike_api/models/generic.py index f18997a..58b2345 100644 --- a/strike_api/models/generic.py +++ b/strike_api/models/generic.py @@ -1,14 +1,15 @@ from __future__ import annotations import humps +import typing from pydantic import BaseModel class StrikeAPIModel(BaseModel): class Config: - alias_generator = humps.camelize + alias_generator = humps.camelize # type: ignore class ItemsResponse(StrikeAPIModel): - items: StrikeAPIModel + items: typing.List[typing.Any] count: int diff --git a/strike_api/models/invoices.py b/strike_api/models/invoices.py index 20d1562..f15c0e3 100644 --- a/strike_api/models/invoices.py +++ b/strike_api/models/invoices.py @@ -32,10 +32,10 @@ class Invoice(StrikeAPIModel): class Invoices(StrikeAPIModel): __root__: typing.List[Invoice] - def __iter__(self): + def __iter__(self) -> typing.Iterator[Invoice]: # type: ignore return iter(self.__root__) - def __getitem__(self, index): + def __getitem__(self, index: int): return self.__root__[index] diff --git a/strike_api/models/rates.py b/strike_api/models/rates.py index 34aeeb1..f553ab0 100644 --- a/strike_api/models/rates.py +++ b/strike_api/models/rates.py @@ -1,6 +1,7 @@ from __future__ import annotations from typing import List +import typing from strike_api.models.generic import StrikeAPIModel @@ -14,8 +15,8 @@ class Rate(StrikeAPIModel): class Rates(StrikeAPIModel): __root__: List[Rate] - def __iter__(self): + def __iter__(self) -> typing.Iterable[Rate]: # type: ignore return iter(self.__root__) - def __getitem__(self, index): + def __getitem__(self, index: int): return self.__root__[index] diff --git a/strike_api/rates.py b/strike_api/rates.py index 50d110f..57dd54a 100644 --- a/strike_api/rates.py +++ b/strike_api/rates.py @@ -5,10 +5,8 @@ def get_ticker() -> Rates: """Get currency exchange rate tickers - Response will include list of all possible pairs for the following currencies: BTC, USD, USDT - Returns: - dict: ticker rates + Rates: list of all possible pairs for the following currencies: BTC, USD, USDT """ url = f"https://api.strike.me/v1/rates/ticker" diff --git a/strike_api/subscriptions.py b/strike_api/subscriptions.py index 2443717..7924833 100644 --- a/strike_api/subscriptions.py +++ b/strike_api/subscriptions.py @@ -9,9 +9,8 @@ def get_subscriptions() -> Subscriptions: """Get subscriptions Returns: - typing.List[dict]: list of subscriptions + Subscriptions: list of subscriptions """ - url = f"https://api.strike.me/v1/subscriptions" response = call_api("GET", url) @@ -25,7 +24,7 @@ def get_subscription(subscription_id: str) -> Subscription: subscription_id (str): id of subscription Returns: - dict: subscription + Subscription: subscription """ url = f"https://api.strike.me/v1/subscriptions/{subscription_id}" @@ -42,9 +41,7 @@ def create_subscription( enabled: bool, event_type: typing.List[str], ) -> Subscription: - """Create a new subscription - - You can create at most 50 subscriptions + """Creates a new subscription. You can create at most 50 subscriptions. Args: webhook_url (str): Webhook HTTPS endpoint url. @@ -54,7 +51,7 @@ def create_subscription( event_type (typing.List[str]): List of event types for the subscription. Each time that some event type from the list occurs, the webhook will be triggered. Returns: - dict: subscription + Subscription: The created subscription. """ url = "https://api.strike.me/v1/subscriptions" @@ -82,7 +79,7 @@ def update_subscription( enabled: bool, event_type: typing.List[str], ) -> Subscription: - """Update a subscription + """Update a subscription. Args: subscription_id (str): Id of subscription to update. @@ -93,7 +90,7 @@ def update_subscription( event_type (typing.List[str]): List of event types for the subscription. Each time that some event type from the list occurs, the webhook will be triggered. Returns: - dict: _description_ + Subscription: The updated subscription. """ url = f"https://api.strike.me/v1/subscriptions/{subscription_id}" @@ -116,10 +113,10 @@ def delete_subscription(subscription_id: str) -> None: """Delete a subscription Args: - subscription_id (str): Id of subscription to update + subscription_id (str): Id of subscription to delete Returns: - dict: subscription + None """ url = f"https://api.strike.me/v1/subscriptions/{subscription_id}"