fix errors merchant

Co-Authored-By: itsdeka <dario.moceri@bitfinex.com>
This commit is contained in:
Davide Casale
2023-02-12 21:41:33 +01:00
parent 9ada3b05a2
commit 3c377928b2
3 changed files with 21 additions and 4 deletions

View File

@@ -339,4 +339,13 @@ class RestAuthenticatedEndpoints(Middleware):
data = to_snake_case_keys(self._POST("auth/w/ext/pay/invoice/create", body=body))
return InvoiceSubmission.parse(data)
return InvoiceSubmission.parse(data)
def get_invoices(self, id: Optional[str] = None, start: Optional[str] = None, end: Optional[str] = None, limit: Optional[int] = None) -> List[InvoiceSubmission]:
return [ InvoiceSubmission.parse(sub_data) for sub_data in self._POST("auth/r/ext/pay/invoices", body={
"id": id, "start": start, "end": end,
"limit": limit
}) ]
def get_invoice_count_stats(self, status: Literal["CREATED", "PENDING", "COMPLETED", "EXPIRED"], format: str) -> List[InvoiceCountStats]:
return [ InvoiceCountStats(**sub_data) for sub_data in self._POST("auth/r/ext/pay/invoice/stats/count", body={ "status": status, "format": format }) ]

View File

@@ -564,7 +564,6 @@ class DerivativePositionCollateralLimits(_Type):
#endregion
#region Type hinting for models which are not serializable
@compose(dataclass, partial)
class InvoiceSubmission(_Type):
id: str
@@ -590,7 +589,7 @@ class InvoiceSubmission(_Type):
for index, invoice in enumerate(data["invoices"]):
data["invoices"][index] = Invoice(**invoice)
return cls(**data)
return InvoiceSubmission(**data)
@compose(dataclass, partial)
class CustomerInfo(_Type):
@@ -614,4 +613,9 @@ class Invoice(_Type):
address: str
ext: JSON
@dataclass
class InvoiceCountStats(_Type):
time: str
count: float
#endregion

View File

@@ -27,4 +27,8 @@ print(bfx.rest.auth.submit_invoice(
order_id="order123",
customer_info=customer_info,
pay_currencies=["ETH"]
))
))
print(bfx.rest.auth.get_invoices())
print(bfx.rest.auth.get_invoice_count_stats(status="CREATED", format="Y"))