auto repr from rich

This commit is contained in:
2022-04-23 18:43:12 +02:00
parent 13e5d326ea
commit 5cc90be8b6
2 changed files with 25 additions and 16 deletions

View File

@@ -1,8 +1,11 @@
import typing
import rich.repr
WHAT = "client"
@rich.repr.auto
class FreshbooksContact(typing.NamedTuple):
contact_id: int
first_name: str
@@ -22,6 +25,7 @@ class FreshbooksContact(typing.NamedTuple):
}
@rich.repr.auto
class FreshbooksClient(typing.NamedTuple):
client_id: int
email: str

View File

@@ -3,6 +3,9 @@ import decimal
import functools
import typing
import rich.repr
WHAT = "invoice"
@@ -22,6 +25,7 @@ class InvalidField(Exception):
pass
@rich.repr.auto
class FreshbooksLine(typing.NamedTuple):
invoice_id: int
client_id: int
@@ -54,15 +58,16 @@ class FreshbooksLine(typing.NamedTuple):
"quantity": str(self.quantity),
}
def __rich_repr__(self):
yield "line_id", self.line_id
yield "description", self.description
yield "amount", self.amount
yield "quantity", self.quantity
yield "rate", self.rate
yield "name", self.name
# def __rich_repr__(self):
# yield "line_id", self.line_id
# yield "description", self.description
# yield "amount", self.amount
# yield "quantity", self.quantity
# yield "rate", self.rate
# yield "name", self.name
@rich.repr.auto
class FreshbooksInvoice(typing.NamedTuple):
lines: list[FreshbooksLine]
notes: str
@@ -115,15 +120,15 @@ class FreshbooksInvoice(typing.NamedTuple):
status=kwargs["v3_status"],
)
def __rich_repr__(self):
yield "invoice_id", self.invoice_id
yield "organization", self.organization
yield "date", self.date
yield "status", self.status
yield "amount", self.amount
yield "lines", self.lines
yield "contacts", self.contacts
yield "invoice_number", self.number
# def __rich_repr__(self):
# yield "invoice_id", self.invoice_id
# yield "organization", self.organization
# yield "date", self.date
# yield "status", self.status
# yield "amount", self.amount
# yield "lines", self.lines
# yield "contacts", self.contacts
# yield "invoice_number", self.number
def get_all_draft_invoices(*, get_func: typing.Callable) -> list[FreshbooksInvoice]: