mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-18 22:34:21 +01:00
get invoices paginated
Co-Authored-By: itsdeka <dario.moceri@bitfinex.com>
This commit is contained in:
@@ -31,6 +31,19 @@ class RestMerchantEndpoints(Middleware):
|
||||
"id": id, "start": start, "end": end,
|
||||
"limit": limit
|
||||
})) ]
|
||||
|
||||
def get_invoices_paginated(self, page: int = 1, page_size: int = 10, sort: Literal["asc", "desc"] = "asc",
|
||||
sort_field: Literal["t", "amount", "status"] = "t", status: Optional[List[Literal["CREATED", "PENDING", "COMPLETED", "EXPIRED"]]] = None, fiat: Optional[List[str]] = None,
|
||||
crypto: Optional[List[str]] = None, id: Optional[str] = None, order_id: Optional[str] = None) -> InvoicePage:
|
||||
body = to_camel_case_keys({
|
||||
"page": page, "page_size": page_size, "sort": sort,
|
||||
"sort_field": sort_field, "status": status, "fiat": fiat,
|
||||
"crypto": crypto, "id": id, "order_id": order_id
|
||||
})
|
||||
|
||||
data = to_snake_case_keys(self._POST("auth/r/ext/pay/invoices/paginated", body=body))
|
||||
|
||||
return InvoicePage.parse(data)
|
||||
|
||||
def get_invoice_count_stats(self, status: Literal["CREATED", "PENDING", "COMPLETED", "EXPIRED"], format: str) -> List[InvoiceStats]:
|
||||
return [ InvoiceStats(**sub_data) for sub_data in self._POST("auth/r/ext/pay/invoice/stats/count", body={ "status": status, "format": format }) ]
|
||||
|
||||
@@ -638,6 +638,23 @@ class InvoiceSubmission(_Type):
|
||||
force_completed: bool
|
||||
amount_diff: str
|
||||
|
||||
@dataclass
|
||||
class InvoicePage(_Type):
|
||||
page: int
|
||||
page_size: int
|
||||
sort: Literal["asc", "desc"]
|
||||
sort_field: Literal["t", "amount", "status"]
|
||||
total_pages: int
|
||||
total_items: int
|
||||
items: List[InvoiceSubmission]
|
||||
|
||||
@classmethod
|
||||
def parse(cls, data: Dict[str, Any]) -> "InvoicePage":
|
||||
for index, item in enumerate(data["items"]):
|
||||
data["items"][index] = InvoiceSubmission.parse(item)
|
||||
|
||||
return InvoicePage(**data)
|
||||
|
||||
@dataclass
|
||||
class InvoiceStats(_Type):
|
||||
time: str
|
||||
|
||||
@@ -40,4 +40,6 @@ print(bfx.rest.merchant.complete_invoice(
|
||||
deposit_id=1
|
||||
))
|
||||
|
||||
print(bfx.rest.merchant.get_invoices(limit=25))
|
||||
print(bfx.rest.merchant.get_invoices(limit=25))
|
||||
|
||||
print(bfx.rest.merchant.get_invoices_paginated(page=1, page_size=60, sort="asc", sort_field="t"))
|
||||
Reference in New Issue
Block a user