diff --git a/fireblocks_sdk/api_types.py b/fireblocks_sdk/api_types.py index 78f0b88..0f49128 100644 --- a/fireblocks_sdk/api_types.py +++ b/fireblocks_sdk/api_types.py @@ -286,7 +286,7 @@ def __init__(self, total_amount_larger_than=None, asset_id=None, order_by=None, class GetSmartTransferFilters(object): """ Optional filters to apply for request Args - q (string, optional): Search query string - either ticketId, asset or network name + query (string, optional): Search query string - either ticketId, asset or network name statuses (DRAFT/PENDING_APPROVAL/OPEN/IN_SETTLEMENT/FULFILLED/EXPIRED/CANCELED, optional): array of ticket statuses network_id (string, optional): networkId used in ticket created_by_me (bool, optional): created by me flag @@ -301,10 +301,11 @@ class GetSmartTransferFilters(object): - You should only insert 'before' or 'after' (or none of them), but not both """ - def __init__(self, q: str = None, statuses: str = None, network_id: str = None, created_by_me: bool = None, - expires_after: str = None, expires_before: str = None, ticket_type: str = None, - external_ref_id: str = None, after: str = None, limit: str = None): - self.q = q + def __init__(self, query: Optional[str] = None, statuses: Optional[str] = None, network_id: Optional[str] = None, + created_by_me: Optional[bool] = None, expires_after: Optional[str] = None, + expires_before: Optional[str] = None, ticket_type: Optional[str] = None, + external_ref_id: Optional[str] = None, after: Optional[str] = None, limit: Optional[str] = None): + self.query = query self.statuses = statuses self.network_id = network_id self.created_by_me = created_by_me diff --git a/fireblocks_sdk/sdk.py b/fireblocks_sdk/sdk.py index e542bc7..b0df172 100644 --- a/fireblocks_sdk/sdk.py +++ b/fireblocks_sdk/sdk.py @@ -1973,12 +1973,12 @@ def get_smart_transfer_tickets(self, paged_smart_transfer_request_filters: GetSm paged_smart_transfer_request_filters (object, optional): Possible filters to apply for request """ - url = f"/v1/smart-transfers" + url = "/v1/smart-transfers" params = {} - if paged_smart_transfer_request_filters.q is not None: - params['q'] = paged_smart_transfer_request_filters.q + if paged_smart_transfer_request_filters.query is not None: + params['q'] = paged_smart_transfer_request_filters.query if paged_smart_transfer_request_filters.statuses is not None: params['statuses'] = paged_smart_transfer_request_filters.statuses @@ -2013,8 +2013,8 @@ def get_smart_transfer_tickets(self, paged_smart_transfer_request_filters: GetSm return self._get_request(url) def create_smart_transfer_ticket(self, ticket_type: str, created_by_network_id: str, terms=None, - expires_in: int = None, submit: bool = True, note: str = None, - external_ref_id: str = None, idempotency_key: str = None): + expires_in: Optional[int] = None, submit: bool = True, note: Optional[str] = None, + external_ref_id: Optional[str] = None, idempotency_key: str = None): """Creates new Smart Transfer ticket Args: ticket_type (str): Type of the ticket (ASYNC) @@ -2041,13 +2041,17 @@ def create_smart_transfer_ticket(self, ticket_type: str, created_by_network_id: payload = { "createdByNetworkId": created_by_network_id, "type": ticket_type, - "expiresIn": expires_in, "terms": terms, - "externalRefId": external_ref_id, - "note": note, "submit": submit } + if expires_in is not None: + payload["expiresIn"] = expires_in + if note is not None: + payload["note"] = note + if external_ref_id is not None: + payload["externalRefId"] = external_ref_id + return self._post_request(url, payload, idempotency_key) def get_smart_transfer_ticket(self, ticket_id: str): @@ -2070,7 +2074,7 @@ def set_smart_transfer_ticket_expires_in(self, ticket_id: str, expires_in: int): url = f"/v1/smart-transfers/{ticket_id}/expires-in" payload = { - "expiresIn": int(expires_in) + "expiresIn": expires_in } return self._put_request(url, payload) @@ -2085,7 +2089,7 @@ def set_smart_transfer_ticket_external_ref_id(self, ticket_id: str, external_ref url = f"/v1/smart-transfers/{ticket_id}/external-id" payload = { - "externalRefId": str(external_ref_id) + "externalRefId": external_ref_id } return self._put_request(url, payload) @@ -2100,7 +2104,7 @@ def submit_smart_transfer_ticket(self, ticket_id: str, expires_in: int): url = f"/v1/smart-transfers/{ticket_id}/submit" payload = { - "expiresIn": int(expires_in) + "expiresIn": expires_in } return self._put_request(url, payload) @@ -2140,10 +2144,10 @@ def create_smart_transfer_ticket_term(self, ticket_id: str, asset: str, amount, url = f"/v1/smart-transfers/{ticket_id}/terms" payload = { - "asset": str(asset), + "asset": asset, "amount": amount, - "fromNetworkId": str(from_network_id), - "toNetworkId": str(to_network_id), + "fromNetworkId": from_network_id, + "toNetworkId": to_network_id, } return self._post_request(url, payload, idempotency_key) @@ -2174,10 +2178,10 @@ def update_smart_transfer_ticket_term(self, ticket_id: str, term_id: str, asset: url = f"/v1/smart-transfers/{ticket_id}/terms/{term_id}" payload = { - "asset": str(asset), + "asset": asset, "amount": amount, - "fromNetworkId": str(from_network_id), - "toNetworkId": str(to_network_id), + "fromNetworkId": from_network_id, + "toNetworkId": to_network_id, } return self._put_request(url, payload) @@ -2194,7 +2198,8 @@ def delete_smart_transfer_ticket_term(self, ticket_id: str, term_id: str): return self._delete_request(url) def fund_smart_transfer_ticket_term(self, ticket_id: str, term_id, asset: str, amount, network_connection_id: str, - source_id: str, source_type: str, fee: str = None, fee_level: str = None): + source_id: str, source_type: str, fee: Optional[str] = None, + fee_level: Optional[str] = None): """Fund Smart Transfer ticket term/leg Args: ticket_id (str): Ticket ID @@ -2212,15 +2217,21 @@ def fund_smart_transfer_ticket_term(self, ticket_id: str, term_id, asset: str, a url = f"/v1/smart-transfers/{ticket_id}/terms/{term_id}/fund" payload = { - "asset": str(asset), - "amount": str(amount), - "networkConnectionId": str(network_connection_id), - "srcId": str(source_id), - "srcType": str(source_type), - "fee": str(fee), - "feeLevel": str(fee_level), + "asset": asset, + "amount": amount, + "networkConnectionId": network_connection_id, + "srcId": source_id, + "srcType": source_type, } + if fee is not None: + payload["fee"] = fee + + if fee_level is not None: + if fee_level not in FEE_LEVEL: + raise FireblocksApiException("Got invalid fee level: " + fee_level) + payload["feeLevel"] = fee_level + return self._put_request(url, payload) def manually_fund_smart_transfer_ticket_term(self, ticket_id: str, term_id, tx_hash: str): @@ -2234,7 +2245,7 @@ def manually_fund_smart_transfer_ticket_term(self, ticket_id: str, term_id, tx_h url = f"/v1/smart-transfers/{ticket_id}/terms/{term_id}/manually-fund" payload = { - "txHash": str(tx_hash), + "txHash": tx_hash, } return self._put_request(url, payload) @@ -2245,7 +2256,7 @@ def set_smart_transfer_user_group_ids(self, user_group_ids): user_group_ids (list): List of user groups ids to receive Smart Transfer notifications """ - url = f"/v1/smart-transfers/settings/user-groups" + url = "/v1/smart-transfers/settings/user-groups" payload = { "userGroupIds": user_group_ids, @@ -2257,7 +2268,7 @@ def get_smart_transfer_user_group_ids(self): """Fetch Smart Transfer user group ids that will receive Smart Transfer notifications """ - url = f"/v1/smart-transfers/settings/user-groups" + url = "/v1/smart-transfers/settings/user-groups" return self._get_request(url)