-
Notifications
You must be signed in to change notification settings - Fork 3
feat: align library with latest Embed API documentation #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
02a5af9
Add missing functions and test cases
TaslimOseni c61c0bc
Bump app version
TaslimOseni 3df4516
Update ReadMe
TaslimOseni 10f649a
style: apply black formatting to resources and tests
TaslimOseni 6a9c091
Fix pre-commit checks
TaslimOseni 8810306
Update embed/version.py
TaslimOseni 807a5bf
Remove Eurobonds, Fixed Placements and Atomic Integration functionali…
TaslimOseni 6444604
Update auto-reinvest to use PATCH and add DELETE method
TaslimOseni 790dd1e
Refactor Integrations to CSCS
TaslimOseni ed59949
Add WithdrawalIntent resource and fix withdrawal intents endpoints
TaslimOseni e880242
Update ReadMe
TaslimOseni 10520fd
Fix formatting issues caught by black
TaslimOseni 5ebb0d1
Update tests to reflect API changes
TaslimOseni e84afbd
Fix trailing whitespace in test_withdrawals.py
TaslimOseni 02b1bf1
Update fixed notes update method and rename CSCS to Integrations
TaslimOseni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,49 @@ | ||
| import json | ||
|
|
||
| from embed.common import APIResponse | ||
|
|
||
|
|
||
| class Deposit(APIResponse): | ||
| """ | ||
| Handles all queries for Deposits including listing and retrieving. | ||
| """ | ||
|
|
||
| def __init__(self, api_session): | ||
| super(Deposit, self).__init__() | ||
| self.base_url = f"{api_session.base_url}/api/{api_session.api_version}/" | ||
| self.token = api_session.token | ||
| self._headers.update({"Authorization": f"Bearer {self.token}"}) | ||
|
|
||
| def list_deposits(self, **kwargs): | ||
| """ | ||
| Retrieve a list of all deposits. | ||
|
|
||
| Args: | ||
| **kwargs: Arbitrary keyword arguments for filtering and pagination. | ||
| page_size (int): Optional. | ||
| page (int): Optional. | ||
| all (bool): Optional. If True, return all without pagination. | ||
|
|
||
| Returns: | ||
| dict: The API response containing a list of deposits. | ||
| """ | ||
| query_path = self._format_query(kwargs) | ||
| method = "GET" | ||
| url = self.base_url + "deposits" | ||
| if query_path: | ||
| url = f"{url}?{query_path}" | ||
| return self.get_essential_details(method, url) | ||
|
|
||
| def get_deposit(self, deposit_id): | ||
| """ | ||
| Retrieve details of a specific deposit. | ||
|
|
||
| Args: | ||
| deposit_id (str): The unique identifier for the deposit. | ||
|
|
||
| Returns: | ||
| dict: The API response containing deposit details. | ||
| """ | ||
| method = "GET" | ||
| url = self.base_url + f"deposits/{deposit_id}" | ||
| return self.get_essential_details(method, url) |
This file contains hidden or 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,202 @@ | ||
| import json | ||
|
|
||
| from embed.common import APIResponse | ||
|
|
||
|
|
||
| class FixedNote(APIResponse): | ||
| """ | ||
| Handles all queries for Fixed Notes management including creation, withdrawal, rollover, and performance tracking. | ||
| """ | ||
|
|
||
| def __init__(self, api_session): | ||
| super(FixedNote, self).__init__() | ||
| self.base_url = f"{api_session.base_url}/api/{api_session.api_version}/" | ||
| self.token = api_session.token | ||
| self._headers.update({"Authorization": f"Bearer {self.token}"}) | ||
|
|
||
| def list_fixed_notes(self, **kwargs): | ||
| """ | ||
| Retrieve a list of all fixed notes. | ||
|
|
||
| Args: | ||
| **kwargs: Arbitrary keyword arguments for pagination. | ||
| page_size (int): Optional. | ||
| page (int): Optional. | ||
|
|
||
| Returns: | ||
| dict: The API response containing a list of fixed notes. | ||
| """ | ||
| query_path = self._format_query(kwargs) | ||
| method = "GET" | ||
| url = self.base_url + "fixed-notes" | ||
| if query_path: | ||
| url = f"{url}?{query_path}" | ||
| return self.get_essential_details(method, url) | ||
|
|
||
| def get_fixed_note(self, fixed_note_id): | ||
| """ | ||
| Retrieve details of a specific fixed note. | ||
|
|
||
| Args: | ||
| fixed_note_id (str): The unique identifier for the fixed note. | ||
|
|
||
| Returns: | ||
| dict: The API response containing fixed note details. | ||
| """ | ||
| method = "GET" | ||
| url = self.base_url + f"fixed-notes/{fixed_note_id}" | ||
| return self.get_essential_details(method, url) | ||
|
|
||
| def create_fixed_note(self, **kwargs): | ||
| """ | ||
| Create a new fixed note investment. | ||
|
|
||
| Args: | ||
| **kwargs: Arbitrary keyword arguments. | ||
| account_id (str): Required. The unique identifier for the account. | ||
| asset_code (str): Required. The asset code for the fixed note. | ||
| tenor_in_months (int): Required. Duration in months. | ||
| amount_range (str): Required. Amount range (e.g., '10M-100M'). | ||
| auto_reinvest (bool): Optional. Whether to automatically reinvest. | ||
| idempotency_key (str): Optional. Unique key to prevent duplicate requests. | ||
|
|
||
| Returns: | ||
| dict: The API response containing new fixed note details. | ||
| """ | ||
| required = ["account_id", "asset_code", "tenor_in_months", "amount_range"] | ||
| self._validate_kwargs(required, kwargs) | ||
|
|
||
| if "idempotency_key" in kwargs.keys(): | ||
| self._headers.update( | ||
| {"Embed-Idempotency-Key": str(kwargs.pop("idempotency_key"))} | ||
| ) | ||
|
|
||
| method = "POST" | ||
| url = self.base_url + "fixed-notes" | ||
| payload = json.dumps(kwargs) | ||
| return self.get_essential_details(method, url, payload) | ||
|
|
||
| def get_fixed_note_rates(self, **kwargs): | ||
| """ | ||
| Retrieve fixed note rates. | ||
|
|
||
| Args: | ||
| **kwargs: Arbitrary keyword arguments. | ||
| tenor_in_months (int): Required. Duration in months. | ||
| amount_range (str): Required. Amount range (e.g., '10M-100M'). | ||
| currency (str): Required. Currency code (e.g., 'NGN', 'USD'). | ||
|
|
||
| Returns: | ||
| dict: The API response containing rate information. | ||
| """ | ||
| required = ["tenor_in_months", "amount_range", "currency"] | ||
| self._validate_kwargs(required, kwargs) | ||
|
|
||
| query_path = "&".join(f"{k}={v}" for k, v in kwargs.items()) | ||
| method = "GET" | ||
| url = self.base_url + f"fixed-notes/rates?{query_path}" | ||
| return self.get_essential_details(method, url) | ||
|
|
||
| def get_fixed_note_performance( | ||
| self, fixed_note_id: str, start_date: str = None, end_date: str = None, **kwargs | ||
| ): | ||
| """ | ||
| Retrieve performance timeseries for a fixed note. | ||
|
|
||
| Args: | ||
| fixed_note_id (str): The unique identifier for the fixed note. | ||
| start_date (str): Optional. YYYY-MM-DD. | ||
| end_date (str): Optional. YYYY-MM-DD. | ||
| **kwargs: Additional filtering parameters. | ||
|
|
||
| Returns: | ||
| dict: The API response containing performance data. | ||
| """ | ||
| if start_date: | ||
| kwargs["start_date"] = self._validate_date_string(start_date) | ||
| if end_date: | ||
| kwargs["end_date"] = self._validate_date_string(end_date) | ||
|
|
||
| method = "GET" | ||
| url = self.base_url + f"fixed-notes/{fixed_note_id}/performance" | ||
| query_path = "&".join("{}={}".format(k, v) for k, v in kwargs.items()) | ||
| if query_path: | ||
| url = f"{url}?{query_path}" | ||
| return self.get_essential_details(method, url) | ||
|
|
||
| def get_fixed_note_returns( | ||
| self, fixed_note_id: str, start_date: str = None, end_date: str = None, **kwargs | ||
| ): | ||
| """ | ||
| Retrieve returns history for a fixed note. | ||
|
|
||
| Args: | ||
| fixed_note_id (str): The unique identifier for the fixed note. | ||
| start_date (str): Optional. YYYY-MM-DD. | ||
| end_date (str): Optional. YYYY-MM-DD. | ||
| **kwargs: Additional filtering parameters. | ||
|
|
||
| Returns: | ||
| dict: The API response containing returns data. | ||
| """ | ||
| if start_date: | ||
| kwargs["start_date"] = self._validate_date_string(start_date) | ||
| if end_date: | ||
| kwargs["end_date"] = self._validate_date_string(end_date) | ||
|
|
||
| method = "GET" | ||
| url = self.base_url + f"fixed-notes/{fixed_note_id}/returns" | ||
| query_path = "&".join("{}={}".format(k, v) for k, v in kwargs.items()) | ||
| if query_path: | ||
| url = f"{url}?{query_path}" | ||
| return self.get_essential_details(method, url) | ||
|
|
||
| def withdraw(self, fixed_note_id, **kwargs): | ||
| """ | ||
| Withdraw from a fixed note. | ||
|
|
||
| Args: | ||
| fixed_note_id (str): The unique identifier for the fixed note. | ||
| amount (float): Optional. Specific amount to withdraw. | ||
| liquidate_all (bool): Optional. Whether to liquidate all units. | ||
| same_day_if_mature (bool): Optional. Whether to process same day if mature. | ||
|
|
||
| Returns: | ||
| dict: The API response containing withdrawal details. | ||
| """ | ||
| method = "POST" | ||
| url = self.base_url + f"fixed-notes/{fixed_note_id}/withdraw" | ||
| payload = json.dumps(kwargs) | ||
| return self.get_essential_details(method, url, payload) | ||
|
|
||
| def rollover(self, fixed_note_id, tenor_in_months): | ||
| """ | ||
| Rollover a fixed note for an additional period. | ||
|
|
||
| Args: | ||
| fixed_note_id (str): The unique identifier for the fixed note. | ||
| tenor_in_months (int): Additional duration in months. | ||
|
|
||
| Returns: | ||
| dict: The API response containing rollover details. | ||
| """ | ||
| method = "POST" | ||
| url = self.base_url + f"fixed-notes/{fixed_note_id}/rollover" | ||
| payload = json.dumps({"tenor_in_months": tenor_in_months}) | ||
| return self.get_essential_details(method, url, payload) | ||
|
|
||
| def partial_update(self, fixed_note_id, **kwargs): | ||
| """ | ||
| Partially update a fixed note. | ||
|
|
||
| Args: | ||
| fixed_note_id (str): The unique identifier for the fixed note. | ||
| **kwargs: Fields to update (e.g., auto_reinvest). | ||
|
|
||
| Returns: | ||
| dict: The API response. | ||
| """ | ||
| method = "PATCH" | ||
| url = self.base_url + f"fixed-notes/{fixed_note_id}" | ||
| payload = json.dumps(kwargs) | ||
| return self.get_essential_details(method, url, payload) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.