Skip to content

Commit

Permalink
added withdraw_methods and withdraw_addresses to kraken.spot.Funding
Browse files Browse the repository at this point in the history
  • Loading branch information
btschwertfeger committed Dec 6, 2023
1 parent 93cd118 commit d821a4d
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 0 deletions.
84 changes: 84 additions & 0 deletions kraken/spot/funding.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,5 +494,89 @@ def wallet_transfer(
extra_params=extra_params,
)

def withdraw_methods(
self: Funding,
asset: Optional[str] = None,
aclass: Optional[str] = None,
network: Optional[str] = None,
*,
extra_params: Optional[dict] = None,
) -> dict:
"""
Returns the list of available withdraw methods for that user.
Requires the ``Funds permissions - Query`` and ``Funds permissions -
Withdraw`` API key permissions.
:param asset: Filter by asset
:type asset: Optional[str]
:param aclass: Filter by asset class (default: ``currency``)
:type aclass: Optional[str]
:param network: Filter by network
:type network: Optional[str]
:return: List of available withdraw methods
:rtype: list[dict]
"""
params: dict = {}
if defined(asset):
params["asset"] = asset
if defined(aclass):
params["network"] = aclass
if defined(network):
params["network"] = network
return self._request( # type: ignore[return-value]
method="POST",
uri="/private/WithdrawMethods",
params=params,
extra_params=extra_params,
)

def withdraw_addresses(
self: Funding,
asset: Optional[str] = None,
aclass: Optional[str] = None,
method: Optional[str] = None,
key: Optional[str] = None,
verified: Optional[bool] = None,
*,
extra_params: Optional[dict] = None,
) -> dict:
"""
Returns the list of available withdrawal addresses for that user.
Requires the ``Funds permissions - Query`` and ``Funds permissions -
Withdraw`` API key permissions.
:param asset: Filter by asset
:type asset: Optional[str]
:param aclass: Filter by asset class (default: ``currency``)
:type aclass: Optional[str]
:param method: Filter by method
:type method: Optional[str]
:param key: Filter by key
:type key: Optional[str]
:param verified: List only addresses which are confirmed via E-Mail
:type verified: Optional[str]
:return: List of available addresses for withdrawal
:rtype: list[dict]
"""
params: dict = {}
if defined(asset):
params["asset"] = asset
if defined(aclass):
params["network"] = aclass
if defined(method):
params["method"] = method
if defined(key):
params["key"] = key
if defined(verified):
params["verified"] = verified
return self._request( # type: ignore[return-value]
method="POST",
uri="/private/WithdrawMethods",
params=params,
extra_params=extra_params,
)


__all__ = ["Funding"]
44 changes: 44 additions & 0 deletions tests/spot/test_spot_funding.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,47 @@ def test_wallet_transfer(spot_auth_funding: Funding) -> None:
amount=10000,
),
)


@pytest.mark.spot()
@pytest.mark.wip()
@pytest.mark.spot_auth()
@pytest.mark.spot_funding()
@pytest.mark.skip(reason="CI does not have withdraw permission")
def test_withdraw_methods(spot_auth_funding: Funding) -> None:
"""
Checks the withdraw_methods function for retrieving the correct data type
which is sufficient to validate the functionality.
"""
response: list[dict] = spot_auth_funding.withdraw_methods()
assert isinstance(response, list)
response = spot_auth_funding.withdraw_methods(
asset="ZUSD",
aclass="currency",
)
assert isinstance(response, list)
response = spot_auth_funding.withdraw_methods(asset="XBT", network="Bitcoin")
assert isinstance(response, list)
response = spot_auth_funding.withdraw_methods(aclass="forex")
assert isinstance(response, list)


@pytest.mark.spot()
@pytest.mark.wip()
@pytest.mark.spot_auth()
@pytest.mark.spot_funding()
@pytest.mark.skip(reason="CI does not have withdraw permission")
def test_withdraw_addresses(spot_auth_funding: Funding) -> None:
"""
Checks the withdraw_addresses function for retrieving the correct data type
which is sufficient to validate the functionality.
"""
response: list[dict] = spot_auth_funding.withdraw_addresses()
assert isinstance(response, list)
response = spot_auth_funding.withdraw_addresses(
asset="ZUSD",
method="Bank Frick (SWIFT)",
)
assert isinstance(response, list)
response = spot_auth_funding.withdraw_addresses(asset="XLM", verified=True)
assert isinstance(response, list)

0 comments on commit d821a4d

Please sign in to comment.