Skip to content

Commit

Permalink
Merge pull request #18 from chmoder/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
chmoder authored Nov 6, 2022
2 parents af6b059 + d8b2977 commit a4c5fef
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 80 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
36 changes: 18 additions & 18 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion strike_api/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down
19 changes: 9 additions & 10 deletions strike_api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down
18 changes: 9 additions & 9 deletions strike_api/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand All @@ -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 <https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-odata/7d6c4117-317d-4860-915b-7e321be017e3>`_. Ordering syntax can be seen `here <https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-odata/793b1e83-95ee-4446-8434-f5b634f20d1e>`_.
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"

Expand Down
35 changes: 17 additions & 18 deletions strike_api/invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-odata/7d6c4117-317d-4860-915b-7e321be017e3>`_. Ordering syntax can be seen `here <https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-odata/793b1e83-95ee-4446-8434-f5b634f20d1e>`_.
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"

Expand All @@ -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}"

Expand All @@ -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}"
Expand Down Expand Up @@ -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"

Expand All @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions strike_api/models/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]


Expand Down
5 changes: 3 additions & 2 deletions strike_api/models/generic.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions strike_api/models/invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]


Expand Down
5 changes: 3 additions & 2 deletions strike_api/models/rates.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from typing import List
import typing

from strike_api.models.generic import StrikeAPIModel

Expand All @@ -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]
Loading

0 comments on commit a4c5fef

Please sign in to comment.