Source code for q2_sdk.hq.db.country

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

from lxml.objectify import StringElement, IntElement, BoolElement

from .db_object import DbObject
from .representation_row_base import RepresentationRowBase


[docs] class CountryRow(RepresentationRowBase): CountryID: IntElement = "CountryID" IsoCode: IntElement = "IsoCode" IsoCodeA2: StringElement = "IsoCodeA2" IsoCodeA3: StringElement = "IsoCodeA3" Name: StringElement = "Name" DialingCode: IntElement = "DialingCode" CityAreaCodeEditMask: StringElement = "CityAreaCodeEditMask" LocalNumberEditMask: StringElement = "LocalNumberEditMask" IsValidForInternationalAddress: BoolElement = "IsValidForInternationalAddress" SmsDialingCode: IntElement = "SmsDialingCode" PostalCodeRequired: BoolElement = "PostalCodeRequired" ProvinceRequired: BoolElement = "ProvinceRequired"
[docs] class Country(DbObject): GET_BY_NAME_KEY = "Name" NAME = "Country" REPRESENTATION_ROW_CLASS = CountryRow
[docs] def add_arguments(self, parser: _SubParsersAction): subparser = parser.add_parser("get_countries") subparser.set_defaults(parser="get_countries") subparser.set_defaults(func=partial(self.get, serialize_for_cli=True))
[docs] async def get(self, serialize_for_cli=False) -> List[CountryRow]: response = await self.call_hq("sdk_GetCountries") if serialize_for_cli: response = self.serialize_for_cli(response, ["CountryID", "Name"]) return response