from argparse import _SubParsersAction
from functools import partial
from typing import List
from lxml.objectify import IntElement, StringElement
from .db_object import DbObject
from .representation_row_base import RepresentationRowBase
[docs]
class TransactionTypeRow(RepresentationRowBase):
TransactionTypeID: IntElement = "TransactionTypeID"
ShortName: StringElement = "ShortName"
Description: StringElement = "Description"
BitFlags: IntElement = "BitFlags"
UiTextElementID: IntElement = "UiTextElementID"
TransactionTypeRowBase = TransactionTypeRow # Backwards compatibility. Remove in 3.0
[docs]
class TransactionType(DbObject):
GET_BY_NAME_KEY = "ShortName"
NAME = "TransactionType"
REPRESENTATION_ROW_CLASS = TransactionTypeRow
[docs]
def add_arguments(self, parser: _SubParsersAction):
subparser = parser.add_parser("get_transaction_types")
subparser.set_defaults(parser="get")
subparser.set_defaults(func=partial(self.get, serialize_for_cli=True))
[docs]
async def get(self, serialize_for_cli=False) -> List[TransactionTypeRow]:
response = await self.call_hq("sdk_GetTransactionTypes")
if serialize_for_cli:
columns = [
"TransactionTypeID",
"ShortName",
"Description",
"BitFlags",
"UiTextElementID",
]
response = self.serialize_for_cli(response, columns)
return response