"""visaacceptancemergedspec.

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

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


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

    Attributes:
        locality (str): #### Visa Platform Connect  Merchant’s service location city
            name. When merchant provides services from a location other than the
            location identified as merchant location.
        country_subdivision_code (str): #### Visa Platform Connect  Merchant’s
            service location country subdivision code. When merchant provides
            services from a location other than the location identified as merchant
            location.
        country_code (str): #### Visa Platform Connect  Merchant’s service location
            country code. When merchant provides services from a location other than
            the location identified as merchant location.
        postal_code (str): #### Visa Platform Connect  Merchant’s service location
            postal code. When merchant provides services from a location other than
            the location identified as merchant location.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "locality": "locality",
        "country_subdivision_code": "countrySubdivisionCode",
        "country_code": "countryCode",
        "postal_code": "postalCode",
    }

    _optionals = [
        "locality",
        "country_subdivision_code",
        "country_code",
        "postal_code",
    ]

    def __init__(
        self,
        locality=APIHelper.SKIP,
        country_subdivision_code=APIHelper.SKIP,
        country_code=APIHelper.SKIP,
        postal_code=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a ServiceLocation instance."""
        # Initialize members of the class
        if locality is not APIHelper.SKIP:
            self.locality = locality
        if country_subdivision_code is not APIHelper.SKIP:
            self.country_subdivision_code = country_subdivision_code
        if country_code is not APIHelper.SKIP:
            self.country_code = country_code
        if postal_code is not APIHelper.SKIP:
            self.postal_code = postal_code

        # 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
        locality =\
            dictionary.get("locality")\
            if dictionary.get("locality")\
                else APIHelper.SKIP
        country_subdivision_code =\
            dictionary.get("countrySubdivisionCode")\
            if dictionary.get("countrySubdivisionCode")\
                else APIHelper.SKIP
        country_code =\
            dictionary.get("countryCode")\
            if dictionary.get("countryCode")\
                else APIHelper.SKIP
        postal_code =\
            dictionary.get("postalCode")\
            if dictionary.get("postalCode")\
                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(locality,
                   country_subdivision_code,
                   country_code,
                   postal_code,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _locality=(
            self.locality
            if hasattr(self, "locality")
            else None
        )
        _country_subdivision_code=(
            self.country_subdivision_code
            if hasattr(self, "country_subdivision_code")
            else None
        )
        _country_code=(
            self.country_code
            if hasattr(self, "country_code")
            else None
        )
        _postal_code=(
            self.postal_code
            if hasattr(self, "postal_code")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"locality={_locality!r}, "
            f"country_subdivision_code={_country_subdivision_code!r}, "
            f"country_code={_country_code!r}, "
            f"postal_code={_postal_code!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _locality=(
            self.locality
            if hasattr(self, "locality")
            else None
        )
        _country_subdivision_code=(
            self.country_subdivision_code
            if hasattr(self, "country_subdivision_code")
            else None
        )
        _country_code=(
            self.country_code
            if hasattr(self, "country_code")
            else None
        )
        _postal_code=(
            self.postal_code
            if hasattr(self, "postal_code")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"locality={_locality!s}, "
            f"country_subdivision_code={_country_subdivision_code!s}, "
            f"country_code={_country_code!s}, "
            f"postal_code={_postal_code!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
