Skip to content

Commit

Permalink
Merge pull request #3 from Trevypants/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Trevypants authored May 19, 2024
2 parents 3962c2f + c13e4f6 commit 5c7ec61
Show file tree
Hide file tree
Showing 80 changed files with 2,339 additions and 161 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ setup:
$(MAKE) setup-dev

### Commands to run the tests ###
# base64 encode the credentials: base64 -i tests/test_creds.json
test-gen-creds:
@poetry run pyrevolut auth-manual --credentials-json tests/test_creds.json

Expand Down
78 changes: 39 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ Upon completion, you will have a `.json` file that you can use to authenticate y

The SDK currently supports the following APIs:

- [ ] Accounts
- [ ] Retrieve all accounts
- [ ] Retrieve an account
- [ ] Retrieve account's full bank details
- [ ] Cards
- [x] Accounts
- [x] Retrieve all accounts
- [x] Retrieve an account
- [x] Retrieve account's full bank details
- [ ] Cards (Live only)
- [ ] Retrieve a list of cards
- [ ] Create a card
- [ ] Retrieve card details
Expand All @@ -110,48 +110,48 @@ The SDK currently supports the following APIs:
- [ ] Freeze a card
- [ ] Unfreeze a card
- [ ] Retrieve sensitive card details
- [ ] Counterparties
- [ ] Retrieve a list of counterparties
- [ ] Retrieve a counterparty
- [ ] Delete a counterparty
- [ ] Create a counterparty
- [ ] Validate an account name (CoP)
- [x] Counterparties
- [x] Retrieve a list of counterparties
- [x] Retrieve a counterparty
- [x] Delete a counterparty
- [x] Create a counterparty (Personal)
- [x] Create a counterparty (Business)
- [x] Validate an account name (CoP)
- [ ] Foreign exchange
- [ ] Get an exchange rate
- [x] Get an exchange rate
- [ ] Exchange money
- [ ] Payment drafts
- [ ] Retrieve all payments drafts
- [x] Retrieve all payments drafts
- [ ] Create a payment draft
- [ ] Retrieve a payment draft
- [x] Retrieve a payment draft
- [ ] Delete a payment draft
- [ ] Payout links
- [ ] Retrieve a list of payout links
- [ ] Retrieve a payout link
- [ ] Create a payout link
- [ ] Cancel a payout link
- [ ] Get transfer reasons
- [ ] Simulations
- [ ] Simulate a transfer state update (Sandbox only)
- [ ] Simulate an account top-up (Sandbox only)
- [ ] Team members
- [x] Payout links
- [x] Retrieve a list of payout links
- [x] Retrieve a payout link
- [x] Create a payout link
- [x] Cancel a payout link
- [ ] Simulations (Sandbox only)
- [ ] Simulate a transfer state update
- [x] Simulate an account top-up
- [ ] Team members (Live only)
- [ ] Retrieve a list of team members
- [ ] Invite a new memebr to your business
- [ ] Retrieve team roles
- [ ] Transactions
- [ ] Retrieve a list of transactions
- [ ] Retrieve a transaction
- [ ] Transfers
- [ ] Move money between your accounts
- [ ] Create a transfer to another account
- [ ] Get transfer reasons
- [ ] Webhooks (v2)
- [ ] Create a new webhook
- [ ] Retrieve a list of webhooks
- [ ] Retrieve a webhook
- [ ] Update a webhook
- [ ] Delete a webhook
- [ ] Rotate a webhook signing secret
- [ ] Retrieve a list of failed webhook events
- [x] Transactions
- [x] Retrieve a list of transactions
- [x] Retrieve a transaction
- [x] Transfers
- [x] Move money between your accounts
- [x] Create a transfer to another account
- [x] Get transfer reasons
- [x] Webhooks (v2)
- [x] Create a new webhook
- [x] Retrieve a list of webhooks
- [x] Retrieve a webhook
- [x] Update a webhook
- [x] Delete a webhook
- [x] Rotate a webhook signing secret
- [x] Retrieve a list of failed webhook events

## **Contributing**

Expand Down
1 change: 1 addition & 0 deletions pyrevolut/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
from .transactions import *
from .transfers import *
from .webhooks import *
from .common import *
2 changes: 1 addition & 1 deletion pyrevolut/api/accounts/endpoint/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ async def get_full_bank_details(
**kwargs,
)

return endpoint.Response(**response.json()).model_dump()
return endpoint.Response(**response.json()[0]).model_dump()
2 changes: 1 addition & 1 deletion pyrevolut/api/accounts/endpoint/synchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ def get_full_bank_details(
**kwargs,
)

return endpoint.Response(**response.json()).model_dump()
return endpoint.Response(**response.json()[0]).model_dump()
2 changes: 1 addition & 1 deletion pyrevolut/api/accounts/get/retrieve_all_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class RetrieveAllAccounts:
Get a list of all your accounts.
"""

ROUTE = "/accounts"
ROUTE = "/1.0/accounts"

class Params(BaseModel):
"""
Expand Down
2 changes: 1 addition & 1 deletion pyrevolut/api/accounts/get/retrieve_an_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class RetrieveAnAccount:
Get the information about one of your accounts. Specify the account by its ID.
"""

ROUTE = "/accounts/{account_id}"
ROUTE = "/1.0/accounts/{account_id}"

class Params(BaseModel):
"""
Expand Down
30 changes: 15 additions & 15 deletions pyrevolut/api/accounts/get/retrieve_full_bank_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class RetrieveFullBankDetails:
Get all the bank details of one of your accounts. Specify the account by its ID.
"""

ROUTE = "/accounts/{account_id}/bank-details"
ROUTE = "/1.0/accounts/{account_id}/bank-details"

class Params(BaseModel):
"""
Expand All @@ -31,19 +31,19 @@ class ModelBeneficiaryAddress(BaseModel):
street_line1: Annotated[
str | None,
Field(description="Street line 1 information."),
]
] = None
street_line2: Annotated[
str | None,
Field(description="Street line 2 information."),
]
] = None
region: Annotated[
str | None,
Field(description="The name of the region."),
]
] = None
city: Annotated[
str | None,
Field(description="The name of the city."),
]
] = None
country: Annotated[
CountryAlpha2,
Field(description="The country of the counterparty as the 2-letter ISO 3166 code."),
Expand All @@ -65,32 +65,32 @@ class ModelEstimatedTime(BaseModel):
min: Annotated[
int | None,
Field(description="The minimum time estimate.", ge=0),
]
] = None
max: Annotated[
int | None,
Field(description="The maximum time estimate.", ge=0),
]
] = None

iban: Annotated[
str | None,
Field(description="The IBAN number."),
]
] = None
bic: Annotated[
str | None,
Field(description="The BIC number, also known as SWIFT code."),
]
] = None
account_no: Annotated[
str | None,
Field(description="The account number."),
]
] = None
sort_code: Annotated[
str | None,
Field(description="The sort code of the account."),
]
] = None
routing_number: Annotated[
str | None,
Field(description="The routing number of the account."),
]
] = None
beneficiary: Annotated[
str,
Field(description="The name of the counterparty."),
Expand All @@ -102,15 +102,15 @@ class ModelEstimatedTime(BaseModel):
bank_country: Annotated[
CountryAlpha2 | None,
Field(description="The country of the bank as the 2-letter ISO 3166 code."),
]
] = None
pooled: Annotated[
bool | None,
Field(description="Indicates whether the account address is pooled or unique."),
]
] = None
unique_reference: Annotated[
str | None,
Field(description="The reference of the pooled account."),
]
] = None
schemes: Annotated[
list[EnumPaymentScheme],
Field(description="The schemes that are available for this currency account."),
Expand Down
20 changes: 20 additions & 0 deletions pyrevolut/api/cards/endpoint/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ async def get_all_cards(
list
The list of all cards in your organisation.
"""
self.__check_sandbox()
endpoint = RetrieveListOfCards
path = endpoint.ROUTE
params = endpoint.Params(
Expand Down Expand Up @@ -89,6 +90,7 @@ async def get_card(
dict
The details of the card.
"""
self.__check_sandbox()
endpoint = RetrieveCardDetails
path = endpoint.ROUTE.format(card_id=card_id)
params = endpoint.Params()
Expand Down Expand Up @@ -120,6 +122,7 @@ async def get_card_sensitive_details(
dict
The sensitive details of the card.
"""
self.__check_sandbox()
endpoint = RetrieveSensitiveCardDetails
path = endpoint.ROUTE.format(card_id=card_id)
params = endpoint.Params()
Expand Down Expand Up @@ -213,6 +216,7 @@ async def create_card(
dict
The details of the created card.
"""
self.__check_sandbox()
endpoint = CreateCard
path = endpoint.ROUTE

Expand Down Expand Up @@ -314,6 +318,7 @@ async def freeze_card(
dict
An empty dictionary.
"""
self.__check_sandbox()
endpoint = FreezeCard
path = endpoint.ROUTE.format(card_id=card_id)
body = endpoint.Body()
Expand Down Expand Up @@ -348,6 +353,7 @@ async def unfreeze_card(
dict
An empty dictionary.
"""
self.__check_sandbox()
endpoint = UnfreezeCard
path = endpoint.ROUTE.format(card_id=card_id)
body = endpoint.Body()
Expand Down Expand Up @@ -442,6 +448,7 @@ async def update_card(
dict
The updated details of the card.
"""
self.__check_sandbox()
endpoint = UpdateCardDetails
path = endpoint.ROUTE.format(card_id=card_id)

Expand Down Expand Up @@ -544,6 +551,7 @@ async def delete_card(
dict
An empty dictionary.
"""
self.__check_sandbox()
endpoint = TerminateCard
path = endpoint.ROUTE.format(card_id=card_id)
params = endpoint.Params()
Expand Down Expand Up @@ -573,3 +581,15 @@ def __process_limit_model(
elif amount == "null" and currency == "null":
return "null"
return None

def __check_sandbox(self):
"""
Check if the sandbox is enabled.
Raises
------
ValueError
If the sandbox is enabled.
"""
if self.client.sandbox:
raise ValueError("This feature is not available in Sandbox.")
20 changes: 20 additions & 0 deletions pyrevolut/api/cards/endpoint/synchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def get_all_cards(
list
The list of all cards in your organisation.
"""
self.__check_sandbox()
endpoint = RetrieveListOfCards
path = endpoint.ROUTE
params = endpoint.Params(
Expand Down Expand Up @@ -89,6 +90,7 @@ def get_card(
dict
The details of the card.
"""
self.__check_sandbox()
endpoint = RetrieveCardDetails
path = endpoint.ROUTE.format(card_id=card_id)
params = endpoint.Params()
Expand Down Expand Up @@ -120,6 +122,7 @@ def get_card_sensitive_details(
dict
The sensitive details of the card.
"""
self.__check_sandbox()
endpoint = RetrieveSensitiveCardDetails
path = endpoint.ROUTE.format(card_id=card_id)
params = endpoint.Params()
Expand Down Expand Up @@ -213,6 +216,7 @@ def create_card(
dict
The details of the created card.
"""
self.__check_sandbox()
endpoint = CreateCard
path = endpoint.ROUTE

Expand Down Expand Up @@ -314,6 +318,7 @@ def freeze_card(
dict
An empty dictionary.
"""
self.__check_sandbox()
endpoint = FreezeCard
path = endpoint.ROUTE.format(card_id=card_id)
body = endpoint.Body()
Expand Down Expand Up @@ -348,6 +353,7 @@ def unfreeze_card(
dict
An empty dictionary.
"""
self.__check_sandbox()
endpoint = UnfreezeCard
path = endpoint.ROUTE.format(card_id=card_id)
body = endpoint.Body()
Expand Down Expand Up @@ -442,6 +448,7 @@ def update_card(
dict
The updated details of the card.
"""
self.__check_sandbox()
endpoint = UpdateCardDetails
path = endpoint.ROUTE.format(card_id=card_id)

Expand Down Expand Up @@ -544,6 +551,7 @@ def delete_card(
dict
An empty dictionary.
"""
self.__check_sandbox()
endpoint = TerminateCard
path = endpoint.ROUTE.format(card_id=card_id)
params = endpoint.Params()
Expand Down Expand Up @@ -573,3 +581,15 @@ def __process_limit_model(
elif amount == "null" and currency == "null":
return "null"
return None

def __check_sandbox(self):
"""
Check if the sandbox is enabled.
Raises
------
ValueError
If the sandbox is enabled.
"""
if self.client.sandbox:
raise ValueError("This feature is not available in Sandbox.")
Loading

0 comments on commit 5c7ec61

Please sign in to comment.