-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3078e0
commit 0e91d93
Showing
13 changed files
with
1,372 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"""Module that contains the API classes.""" | ||
|
||
# flake8: noqa: F401, F403 | ||
from .accounts import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"""Get the balances, full banking details, and other details of your business accounts. | ||
Reference link: https://developer.revolut.com/docs/business/accounts | ||
""" | ||
|
||
# flake8: noqa: F401 | ||
from .endpoint import EndpointAccounts | ||
from .enums import EnumAccountState, EnumPaymentScheme, EnumTimeUnit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
from uuid import UUID | ||
from httpx import Response | ||
|
||
from pyrevolut.api.common import BaseEndpoint | ||
|
||
from .retrieve_all_accounts import RetrieveAllAccounts | ||
from .retrieve_an_account import RetrieveAnAccount | ||
from .retrieve_full_bank_details import RetrieveFullBankDetails | ||
|
||
|
||
class EndpointAccounts(BaseEndpoint): | ||
"""The Accounts API | ||
Get the balances, full banking details, and other details of your business accounts. | ||
""" | ||
|
||
def get_all_accounts( | ||
self, | ||
**kwargs, | ||
): | ||
""" | ||
Get a list of all your accounts. | ||
Parameters | ||
---------- | ||
None | ||
Returns | ||
------- | ||
list | ||
The list of all your accounts | ||
""" | ||
endpoint = RetrieveAllAccounts | ||
path = endpoint.ROUTE | ||
params = endpoint.Params() | ||
|
||
response = self.client.get( | ||
path=path, | ||
params=params, | ||
**kwargs, | ||
) | ||
|
||
return [endpoint.Response(**resp) for resp in response.json()] | ||
|
||
def get_account( | ||
self, | ||
account_id: UUID, | ||
**kwargs, | ||
): | ||
""" | ||
Get the information about one of your accounts. Specify the account by its ID. | ||
Parameters | ||
---------- | ||
account_id : UUID | ||
The account ID. | ||
Returns | ||
------- | ||
dict | ||
The information about the account | ||
""" | ||
endpoint = RetrieveAnAccount | ||
path = endpoint.ROUTE.format(account_id=account_id) | ||
params = endpoint.Params() | ||
|
||
response: Response = self.client.get( | ||
path=path, | ||
params=params, | ||
**kwargs, | ||
) | ||
|
||
return endpoint.Response(**response.json()).model_dump() | ||
|
||
def get_full_bank_details( | ||
self, | ||
account_id: UUID, | ||
**kwargs, | ||
): | ||
""" | ||
Get all the bank details of one of your accounts. Specify the account by its ID. | ||
Parameters | ||
---------- | ||
account_id : UUID | ||
The account ID. | ||
Returns | ||
------- | ||
dict | ||
The bank details of the account | ||
""" | ||
endpoint = RetrieveFullBankDetails | ||
path = endpoint.ROUTE.format(account_id=account_id) | ||
params = endpoint.Params() | ||
|
||
response: Response = self.client.get( | ||
path=path, | ||
params=params, | ||
**kwargs, | ||
) | ||
|
||
return endpoint.Response(**response.json()).model_dump() | ||
|
||
async def aget_all_accounts( | ||
self, | ||
**kwargs, | ||
): | ||
""" | ||
Get a list of all your accounts. | ||
Parameters | ||
---------- | ||
None | ||
Returns | ||
------- | ||
list | ||
The list of all your accounts | ||
""" | ||
endpoint = RetrieveAllAccounts | ||
path = endpoint.ROUTE | ||
params = endpoint.Params() | ||
|
||
response = await self.client.aget( | ||
path=path, | ||
params=params, | ||
**kwargs, | ||
) | ||
|
||
return [endpoint.Response(**resp) for resp in response.json()] | ||
|
||
async def aget_account( | ||
self, | ||
account_id: UUID, | ||
**kwargs, | ||
): | ||
""" | ||
Get the information about one of your accounts. Specify the account by its ID. | ||
Parameters | ||
---------- | ||
account_id : UUID | ||
The account ID. | ||
Returns | ||
------- | ||
dict | ||
The information about the account | ||
""" | ||
endpoint = RetrieveAnAccount | ||
path = endpoint.ROUTE.format(account_id=account_id) | ||
params = endpoint.Params() | ||
|
||
response: Response = await self.client.aget( | ||
path=path, | ||
params=params, | ||
**kwargs, | ||
) | ||
|
||
return endpoint.Response(**response.json()).model_dump() | ||
|
||
async def aget_full_bank_details( | ||
self, | ||
account_id: UUID, | ||
**kwargs, | ||
): | ||
""" | ||
Get all the bank details of one of your accounts. Specify the account by its ID. | ||
Parameters | ||
---------- | ||
account_id : UUID | ||
The account ID. | ||
Returns | ||
------- | ||
dict | ||
The bank details of the account | ||
""" | ||
endpoint = RetrieveFullBankDetails | ||
path = endpoint.ROUTE.format(account_id=account_id) | ||
params = endpoint.Params() | ||
|
||
response: Response = await self.client.aget( | ||
path=path, | ||
params=params, | ||
**kwargs, | ||
) | ||
|
||
return endpoint.Response(**response.json()).model_dump() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from enum import StrEnum | ||
|
||
|
||
class EnumAccountState(StrEnum): | ||
"""Account state enum""" | ||
|
||
ACTIVE = "active" | ||
INACTIVE = "inactive" | ||
|
||
|
||
class EnumPaymentScheme(StrEnum): | ||
"""Payment scheme enum""" | ||
|
||
CHAPS = "chaps" | ||
BACS = "bacs" | ||
FASTER_PAYMENTS = "faster_payments" | ||
SEPA = "sepa" | ||
SWIFT = "swift" | ||
ACH = "ach" | ||
ELIXIR = "elixir" | ||
SORBNET = "sorbnet" | ||
NICS = "nics" | ||
RIX = "rix" | ||
SUMCLEARING = "sumclearing" | ||
|
||
|
||
class EnumTimeUnit(StrEnum): | ||
"""Time unit enum""" | ||
|
||
DAYS = "days" | ||
HOURS = "hours" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from typing import Annotated | ||
from uuid import UUID | ||
from decimal import Decimal | ||
|
||
from pydantic import BaseModel, Field | ||
from pydantic_extra_types.currency_code import Currency | ||
|
||
from pyrevolut.utils import DateTime | ||
from .enums import EnumAccountState | ||
|
||
|
||
class RetrieveAllAccounts: | ||
""" | ||
Get a list of all your accounts. | ||
""" | ||
|
||
ROUTE = "/accounts" | ||
|
||
class Params(BaseModel): | ||
""" | ||
Query parameters for the endpoint. | ||
""" | ||
|
||
pass | ||
|
||
class Response(BaseModel): | ||
""" | ||
Response model for the endpoint. | ||
""" | ||
|
||
id: Annotated[ | ||
UUID, | ||
Field(description="The account ID."), | ||
] | ||
name: Annotated[ | ||
str, | ||
Field(description="The account name."), | ||
] | ||
balance: Annotated[ | ||
Decimal, | ||
Field(description="The current balance on the account."), | ||
] | ||
currency: Annotated[ | ||
Currency, | ||
Field(description="ISO 4217 currency code in upper case."), | ||
] | ||
state: Annotated[ | ||
EnumAccountState, | ||
Field(description="Indicates the state of the account."), | ||
] | ||
public: Annotated[ | ||
bool, | ||
Field( | ||
description="Indicates whether the account is visible to other businesses on Revolut." | ||
), | ||
] | ||
created_at: Annotated[ | ||
DateTime, | ||
Field(description="The date and time the account was created in ISO 8601 format."), | ||
] | ||
updated_at: Annotated[ | ||
DateTime, | ||
Field(description="The date and time the account was last updated in ISO 8601 format."), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from typing import Annotated | ||
from uuid import UUID | ||
from decimal import Decimal | ||
|
||
from pydantic import BaseModel, Field | ||
from pydantic_extra_types.currency_code import Currency | ||
|
||
from pyrevolut.utils import DateTime | ||
from .enums import EnumAccountState | ||
|
||
|
||
class RetrieveAnAccount: | ||
""" | ||
Get the information about one of your accounts. Specify the account by its ID. | ||
""" | ||
|
||
ROUTE = "/accounts/{account_id}" | ||
|
||
class Params(BaseModel): | ||
""" | ||
Query parameters for the endpoint. | ||
""" | ||
|
||
pass | ||
|
||
class Response(BaseModel): | ||
""" | ||
Response model for the endpoint. | ||
""" | ||
|
||
id: Annotated[ | ||
UUID, | ||
Field(description="The account ID."), | ||
] | ||
name: Annotated[ | ||
str, | ||
Field(description="The account name."), | ||
] | ||
balance: Annotated[ | ||
Decimal, | ||
Field(description="The current balance on the account."), | ||
] | ||
currency: Annotated[ | ||
Currency, | ||
Field(description="ISO 4217 currency code in upper case."), | ||
] | ||
state: Annotated[ | ||
EnumAccountState, | ||
Field(description="Indicates the state of the account."), | ||
] | ||
public: Annotated[ | ||
bool, | ||
Field( | ||
description="Indicates whether the account is visible to other businesses on Revolut." | ||
), | ||
] | ||
created_at: Annotated[ | ||
DateTime, | ||
Field(description="The date and time the account was created in ISO 8601 format."), | ||
] | ||
updated_at: Annotated[ | ||
DateTime, | ||
Field(description="The date and time the account was last updated in ISO 8601 format."), | ||
] |
Oops, something went wrong.