"""visaacceptancemergedspec.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: E501
from visaacceptancemergedspec.api_helper import (
    APIHelper,
)


class TicketIssuer(object):
    """Implementation of the 'TicketIssuer' model.

    Attributes:
        code (str): IATA2 airline code. Format: English characters only. Required for
            Mastercard; optional for all other card types.
        name (str): Name of the ticket issuer. If you do not include this field, Visa
            Acceptance uses the value for your merchant name that is in the Visa
            Acceptance merchant configuration database.
        address (str): Address of the company issuing the ticket.
        locality (str): City in which the transaction occurred. If the name of the
            city exceeds 18 characters, use meaningful abbreviations. Format: English
            characters only. Optional request field.
        administrative_area (str): State in which transaction occured.
        postal_code (str): Zip code of the city in which transaction occured.
        country (str): Country in which transaction occured.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "code": "code",
        "name": "name",
        "address": "address",
        "locality": "locality",
        "administrative_area": "administrativeArea",
        "postal_code": "postalCode",
        "country": "country",
    }

    _optionals = [
        "code",
        "name",
        "address",
        "locality",
        "administrative_area",
        "postal_code",
        "country",
    ]

    def __init__(
        self,
        code=APIHelper.SKIP,
        name=APIHelper.SKIP,
        address=APIHelper.SKIP,
        locality=APIHelper.SKIP,
        administrative_area=APIHelper.SKIP,
        postal_code=APIHelper.SKIP,
        country=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a TicketIssuer instance."""
        # Initialize members of the class
        if code is not APIHelper.SKIP:
            self.code = code
        if name is not APIHelper.SKIP:
            self.name = name
        if address is not APIHelper.SKIP:
            self.address = address
        if locality is not APIHelper.SKIP:
            self.locality = locality
        if administrative_area is not APIHelper.SKIP:
            self.administrative_area = administrative_area
        if postal_code is not APIHelper.SKIP:
            self.postal_code = postal_code
        if country is not APIHelper.SKIP:
            self.country = country

        # Add additional model properties to the instance
        if additional_properties is None:
            additional_properties = {}
        self.additional_properties = additional_properties

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Create an instance of this model from a dictionary

        Args:
            dictionary (dictionary): A dictionary representation of the object
            as obtained from the deserialization of the server's response. The
            keys MUST match property names in the API description.

        Returns:
            object: An instance of this structure class.

        """
        if not isinstance(dictionary, dict) or dictionary is None:
            return None

        # Extract variables from the dictionary
        code =\
            dictionary.get("code")\
            if dictionary.get("code")\
                else APIHelper.SKIP
        name =\
            dictionary.get("name")\
            if dictionary.get("name")\
                else APIHelper.SKIP
        address =\
            dictionary.get("address")\
            if dictionary.get("address")\
                else APIHelper.SKIP
        locality =\
            dictionary.get("locality")\
            if dictionary.get("locality")\
                else APIHelper.SKIP
        administrative_area =\
            dictionary.get("administrativeArea")\
            if dictionary.get("administrativeArea")\
                else APIHelper.SKIP
        postal_code =\
            dictionary.get("postalCode")\
            if dictionary.get("postalCode")\
                else APIHelper.SKIP
        country =\
            dictionary.get("country")\
            if dictionary.get("country")\
                else APIHelper.SKIP

        additional_properties = APIHelper.get_additional_properties(
            dictionary={k: v for k, v in dictionary.items()
                        if k not in cls._names.values()},
            unboxing_function=lambda value: value)

        # Return an object of this model
        return cls(code,
                   name,
                   address,
                   locality,
                   administrative_area,
                   postal_code,
                   country,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _code=(
            self.code
            if hasattr(self, "code")
            else None
        )
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _address=(
            self.address
            if hasattr(self, "address")
            else None
        )
        _locality=(
            self.locality
            if hasattr(self, "locality")
            else None
        )
        _administrative_area=(
            self.administrative_area
            if hasattr(self, "administrative_area")
            else None
        )
        _postal_code=(
            self.postal_code
            if hasattr(self, "postal_code")
            else None
        )
        _country=(
            self.country
            if hasattr(self, "country")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"code={_code!r}, "
            f"name={_name!r}, "
            f"address={_address!r}, "
            f"locality={_locality!r}, "
            f"administrative_area={_administrative_area!r}, "
            f"postal_code={_postal_code!r}, "
            f"country={_country!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _code=(
            self.code
            if hasattr(self, "code")
            else None
        )
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _address=(
            self.address
            if hasattr(self, "address")
            else None
        )
        _locality=(
            self.locality
            if hasattr(self, "locality")
            else None
        )
        _administrative_area=(
            self.administrative_area
            if hasattr(self, "administrative_area")
            else None
        )
        _postal_code=(
            self.postal_code
            if hasattr(self, "postal_code")
            else None
        )
        _country=(
            self.country
            if hasattr(self, "country")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"code={_code!s}, "
            f"name={_name!s}, "
            f"address={_address!s}, "
            f"locality={_locality!s}, "
            f"administrative_area={_administrative_area!s}, "
            f"postal_code={_postal_code!s}, "
            f"country={_country!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
