|
| 1 | +from dataclasses import asdict |
1 | 2 | from enum import Enum |
2 | 3 | from typing import Any, Dict, List, Optional, Union |
3 | 4 |
|
|
8 | 9 | from cryptomarket.dataclasses import (Address, AmountLock, Balance, Candle, |
9 | 10 | Commission, Currency, Order, OrderBook, |
10 | 11 | Price, PriceHistory, SubAccount, Symbol, |
11 | | - Ticker, Trade, Transaction) |
| 12 | + Ticker, Trade, Transaction, Fee) |
12 | 13 | from cryptomarket.dataclasses.aclSettings import ACLSettings |
13 | 14 | from cryptomarket.dataclasses.publicTrade import PublicTrade |
14 | 15 | from cryptomarket.http_client import HttpClient |
@@ -52,18 +53,20 @@ def _delete(self, endpoint: str, params=None): |
52 | 53 |
|
53 | 54 | # PUBLIC METHOD CALLS |
54 | 55 |
|
55 | | - def get_currencies(self, currencies: List[str] = None) -> Dict[str, Currency]: |
| 56 | + def get_currencies(self, currencies: List[str] = None, preferred_network: Optional[str] = None) -> Dict[str, Currency]: |
56 | 57 | """Get a dict of all currencies or specified currencies |
57 | 58 |
|
58 | 59 | Requires no API key Access Rights |
59 | 60 |
|
60 | 61 | https://api.exchange.cryptomkt.com/#currencies |
61 | 62 |
|
62 | 63 | :param currencies: Optional. A list of currencies ids |
| 64 | + :param preferred_network: Optional. Code of the default network for currencies |
63 | 65 |
|
64 | 66 | :returns: A dict of available currencies. indexed by currency id |
65 | 67 | """ |
66 | | - params = args.DictBuilder().currencies(currencies).build() |
| 68 | + params = args.DictBuilder().currencies( |
| 69 | + currencies).preferred_network(preferred_network).build() |
67 | 70 | response = self._get(endpoint='public/currency', params=params) |
68 | 71 | return {key: from_dict(data_class=Currency, data=response[key]) |
69 | 72 | for key in response} |
@@ -981,6 +984,20 @@ def get_estimate_withdrawal_fee(self, currency: str, amount: str) -> str: |
981 | 984 | params = args.DictBuilder().amount(amount).currency(currency).build() |
982 | 985 | return self._get(endpoint='wallet/crypto/fee/estimate', params=params)['fee'] |
983 | 986 |
|
| 987 | + def get_estimate_withdrawal_fees(self, fee_requests: List[args.FeeRequest]) -> List[Fee]: |
| 988 | + """Get a list of estimates of withdrawal fees |
| 989 | +
|
| 990 | + Requires the "Payment information" API key Access Right |
| 991 | +
|
| 992 | + https://api.exchange.cryptomkt.com/#estimate-withdraw-fee |
| 993 | +
|
| 994 | + :returns: A list of expected withdrawal fees |
| 995 | + """ |
| 996 | + params = [asdict(fee_request) for fee_request in fee_requests] |
| 997 | + result = self._post( |
| 998 | + endpoint='wallet/crypto/fees/estimate', params=params) |
| 999 | + return [Fee.from_dict(fee_data) for fee_data in result] |
| 1000 | + |
984 | 1001 | def check_if_crypto_address_belong_to_current_account(self, address: str) -> bool: |
985 | 1002 | """Check if an address is from this account |
986 | 1003 |
|
|
0 commit comments