Source code for q2_sdk.hq.db.currency_code

from argparse import _SubParsersAction
from functools import partial
from typing import List

from lxml.objectify import IntElement, StringElement, BoolElement
from .db_object import DbObject
from .representation_row_base import RepresentationRowBase


[docs] class CurrencyCodeRowBase(RepresentationRowBase): CurrencyCodeID: IntElement = "CurrencyCodeID" CurrencyCode: StringElement = "CurrencyCode" CurrencyName: StringElement = "CurrencyName" CurrencySymbol: StringElement = "CurrencySymbol" IsValidForIntWires: BoolElement = "IsValidForIntWires" CurrencyGroupSizes: IntElement = "CurrencyGroupSizes" CurrencyGroupSeparator: StringElement = "CurrencyGroupSeparator" CurrencyDecimalSeparator: StringElement = "CurrencyDecimalSeparator" CurrencyDecimalDigits: IntElement = "CurrencyDecimalDigits" CultureInfo: StringElement = "CultureInfo"
[docs] class CurrencyCode(DbObject): GET_BY_NAME_KEY = "CurrencyCode" NAME = "CurrencyCode" REPRESENTATION_ROW_CLASS = CurrencyCodeRowBase
[docs] def add_arguments(self, parser: _SubParsersAction): subparser = parser.add_parser("get_currency_codes") subparser.set_defaults(parser="get_currency_codes") subparser.set_defaults(func=partial(self.get, serialize_for_cli=True)) subparser.add_argument( "-i", "--valid_for_international_wires", action="store_true", help="Q2_CurrencyCode.IsValidForIntWires", )
[docs] async def get( self, valid_for_international_wires: bool = False, serialize_for_cli=False ) -> List[CurrencyCodeRowBase]: response = await self.call_hq("sdk_GetCurrencyCode") if valid_for_international_wires: response = [x for x in response if x.IsValidForIntWires.pyval] if serialize_for_cli: columns = [ "CurrencyCodeID", "CurrencyCode", "CurrencyName", "CurrencySymbol", "IsValidForIntWires", "CurrencyDecimalDigits", "CultureInfo", ] response = self.serialize_for_cli(response, columns) return response