mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-18 22:34:21 +01:00
@@ -1,9 +1,11 @@
|
||||
from typing import TypedDict, List, Union, Literal, Optional
|
||||
from typing import TypedDict, List, Union, Literal, Optional, Any
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
from .. types import *
|
||||
from .. enums import MerchantSettingsKey
|
||||
from .. middleware import Middleware
|
||||
|
||||
from ...utils.camel_and_snake_case_helpers import to_snake_case_keys, to_camel_case_keys
|
||||
|
||||
_CustomerInfo = TypedDict("_CustomerInfo", {
|
||||
@@ -79,4 +81,23 @@ class RestMerchantEndpoints(Middleware):
|
||||
return bool(self._POST("auth/w/ext/pay/settings/convert/remove", body={
|
||||
"baseCcy": base_currency,
|
||||
"convertCcy": convert_currency
|
||||
}))
|
||||
}))
|
||||
|
||||
def set_merchant_settings(self, key: MerchantSettingsKey, val: Any) -> bool:
|
||||
return bool(self._POST("auth/w/ext/pay/settings/set", body={ "key": key, "val": val }))
|
||||
|
||||
def get_merchant_settings(self, key: MerchantSettingsKey) -> Any:
|
||||
return self._POST("auth/r/ext/pay/settings/get", body={ "key": key })
|
||||
|
||||
def list_merchant_settings(self, keys: List[MerchantSettingsKey] = list()) -> Dict[MerchantSettingsKey, Any]:
|
||||
return self._POST("auth/r/ext/pay/settings/list", body={ "keys": keys })
|
||||
|
||||
def get_deposits(self, start: int, end: int, ccy: Optional[str] = None, unlinked: Optional[bool] = None) -> List[MerchantDeposit]:
|
||||
return [ MerchantDeposit(**sub_data) for sub_data in to_snake_case_keys(self._POST("auth/r/ext/pay/deposits", body={
|
||||
"from": start, "to": end, "ccy": ccy, "unlinked": unlinked
|
||||
})) ]
|
||||
|
||||
def get_unlinked_deposits(self, ccy: str, start: Optional[int] = None, end: Optional[int] = None) -> List[MerchantUnlinkedDeposit]:
|
||||
return [ MerchantUnlinkedDeposit(**sub_data) for sub_data in to_snake_case_keys(self._POST("/auth/r/ext/pay/deposits/unlinked", body={
|
||||
"ccy": ccy, "start": start, "end": end
|
||||
})) ]
|
||||
@@ -21,7 +21,7 @@ class Config(str, Enum):
|
||||
INFO_PAIR_FUTURES = "pub:info:pair:futures"
|
||||
INFO_TX_STATUS = "pub:info:tx:status"
|
||||
|
||||
SPEC_MARGIN = "pub:spec:margin",
|
||||
SPEC_MARGIN = "pub:spec:margin"
|
||||
FEES = "pub:fees"
|
||||
|
||||
class Precision(str, Enum):
|
||||
@@ -33,4 +33,14 @@ class Precision(str, Enum):
|
||||
|
||||
class Sort(int, Enum):
|
||||
ASCENDING = +1
|
||||
DESCENDING = -1
|
||||
DESCENDING = -1
|
||||
|
||||
class MerchantSettingsKey(str, Enum):
|
||||
PREFERRED_FIAT = "bfx_pay_preferred_fiat"
|
||||
RECOMMEND_STORE = "bfx_pay_recommend_store"
|
||||
NOTIFY_PAYMENT_COMPLETED = "bfx_pay_notify_payment_completed"
|
||||
NOTIFY_PAYMENT_COMPLETED_EMAIL = "bfx_pay_notify_payment_completed_email"
|
||||
NOTIFY_AUTOCONVERT_EXECUTED = "bfx_pay_notify_autoconvert_executed"
|
||||
DUST_BALANCE_UI = "bfx_pay_dust_balance_ui"
|
||||
MERCHANT_CUSTOMER_SUPPORT_URL = "bfx_pay_merchant_customer_support_url"
|
||||
MERCHANT_UNDERPAID_THRESHOLD = "bfx_pay_merchant_underpaid_threshold"
|
||||
@@ -666,4 +666,32 @@ class CurrencyConversion(_Type):
|
||||
convert_currency: str
|
||||
created: int
|
||||
|
||||
@dataclass
|
||||
class MerchantDeposit(_Type):
|
||||
id: int
|
||||
invoice_id: Optional[str]
|
||||
order_id: Optional[str]
|
||||
type: Literal["ledger", "deposit"]
|
||||
amount: float
|
||||
t: int
|
||||
txid: str
|
||||
currency: str
|
||||
method: str
|
||||
pay_method: str
|
||||
|
||||
@dataclass
|
||||
class MerchantUnlinkedDeposit(_Type):
|
||||
id: int
|
||||
method: str
|
||||
currency: str
|
||||
created_at: int
|
||||
updated_at: int
|
||||
amount: float
|
||||
fee: float
|
||||
txid: str
|
||||
address: str
|
||||
payment_id: Optional[int]
|
||||
status: str
|
||||
note: Optional[str]
|
||||
|
||||
#endregion
|
||||
28
examples/rest/merchant/settings.py
Normal file
28
examples/rest/merchant/settings.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# python -c "import examples.rest.merchant.settings"
|
||||
|
||||
import os
|
||||
|
||||
from bfxapi import Client, REST_HOST
|
||||
|
||||
from bfxapi.rest.enums import MerchantSettingsKey
|
||||
|
||||
bfx = Client(
|
||||
REST_HOST=REST_HOST,
|
||||
API_KEY=os.getenv("BFX_API_KEY"),
|
||||
API_SECRET=os.getenv("BFX_API_SECRET")
|
||||
)
|
||||
|
||||
if not bfx.rest.merchant.set_merchant_settings(MerchantSettingsKey.RECOMMEND_STORE, 1):
|
||||
print(f"Cannot set <{MerchantSettingsKey.RECOMMEND_STORE}> to <1>.")
|
||||
|
||||
print(f"The current <{MerchantSettingsKey.PREFERRED_FIAT}> value is:",
|
||||
bfx.rest.merchant.get_merchant_settings(MerchantSettingsKey.PREFERRED_FIAT))
|
||||
|
||||
settings = bfx.rest.merchant.list_merchant_settings([
|
||||
MerchantSettingsKey.DUST_BALANCE_UI,
|
||||
MerchantSettingsKey.MERCHANT_CUSTOMER_SUPPORT_URL,
|
||||
MerchantSettingsKey.MERCHANT_UNDERPAID_THRESHOLD
|
||||
])
|
||||
|
||||
for key, value in settings.items():
|
||||
print(f"<{key}>:", value)
|
||||
Reference in New Issue
Block a user