# -*- coding: utf-8 -*-

"""
paypalserversdk

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from paypalserversdk.api_helper import APIHelper


class CardResponseAddress(object):

    """Implementation of the 'Card Response Address' model.

    Address request details.

    Attributes:
        address_line_1 (str): The first line of the address, such as number
            and street, for example, `173 Drury Lane`. Needed for data entry,
            and Compliance and Risk checks. This field needs to pass the full
            address.
        address_line_2 (str): The second line of the address, for example, a
            suite or apartment number.
        admin_area_2 (str): A city, town, or village. Smaller than
            `admin_area_level_1`.
        admin_area_1 (str): The highest-level sub-division in a country, which
            is usually a province, state, or ISO-3166-2 subdivision. This data
            is formatted for postal delivery, for example, `CA` and not
            `California`. Value, by country, is: UK. A county. US. A state.
            Canada. A province. Japan. A prefecture. Switzerland. A *kanton*.
        postal_code (str): The postal code, which is the ZIP code or
            equivalent. Typically required for countries with a postal code or
            an equivalent. See [postal
            code](https://en.wikipedia.org/wiki/Postal_code).
        country_code (str): The [2-character ISO 3166-1
            code](/api/rest/reference/country-codes/) that identifies the
            country or region. Note: The country code for Great Britain is GB
            and not UK as used in the top-level domain names for that country.
            Use the `C2` country code for China worldwide for comparable
            uncontrolled price (CUP) method, bank card, and cross-border
            transactions.
        id (str): The resource ID of the address.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "country_code": 'country_code',
        "address_line_1": 'address_line_1',
        "address_line_2": 'address_line_2',
        "admin_area_2": 'admin_area_2',
        "admin_area_1": 'admin_area_1',
        "postal_code": 'postal_code',
        "id": 'id'
    }

    _optionals = [
        'address_line_1',
        'address_line_2',
        'admin_area_2',
        'admin_area_1',
        'postal_code',
        'id',
    ]

    def __init__(self,
                 country_code=None,
                 address_line_1=APIHelper.SKIP,
                 address_line_2=APIHelper.SKIP,
                 admin_area_2=APIHelper.SKIP,
                 admin_area_1=APIHelper.SKIP,
                 postal_code=APIHelper.SKIP,
                 id=APIHelper.SKIP):
        """Constructor for the CardResponseAddress class"""

        # Initialize members of the class
        if address_line_1 is not APIHelper.SKIP:
            self.address_line_1 = address_line_1 
        if address_line_2 is not APIHelper.SKIP:
            self.address_line_2 = address_line_2 
        if admin_area_2 is not APIHelper.SKIP:
            self.admin_area_2 = admin_area_2 
        if admin_area_1 is not APIHelper.SKIP:
            self.admin_area_1 = admin_area_1 
        if postal_code is not APIHelper.SKIP:
            self.postal_code = postal_code 
        self.country_code = country_code 
        if id is not APIHelper.SKIP:
            self.id = id 

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Creates 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
        country_code = dictionary.get("country_code") if dictionary.get("country_code") else None
        address_line_1 = dictionary.get("address_line_1") if dictionary.get("address_line_1") else APIHelper.SKIP
        address_line_2 = dictionary.get("address_line_2") if dictionary.get("address_line_2") else APIHelper.SKIP
        admin_area_2 = dictionary.get("admin_area_2") if dictionary.get("admin_area_2") else APIHelper.SKIP
        admin_area_1 = dictionary.get("admin_area_1") if dictionary.get("admin_area_1") else APIHelper.SKIP
        postal_code = dictionary.get("postal_code") if dictionary.get("postal_code") else APIHelper.SKIP
        id = dictionary.get("id") if dictionary.get("id") else APIHelper.SKIP
        # Return an object of this model
        return cls(country_code,
                   address_line_1,
                   address_line_2,
                   admin_area_2,
                   admin_area_1,
                   postal_code,
                   id)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'address_line_1={(self.address_line_1 if hasattr(self, "address_line_1") else None)!r}, '
                f'address_line_2={(self.address_line_2 if hasattr(self, "address_line_2") else None)!r}, '
                f'admin_area_2={(self.admin_area_2 if hasattr(self, "admin_area_2") else None)!r}, '
                f'admin_area_1={(self.admin_area_1 if hasattr(self, "admin_area_1") else None)!r}, '
                f'postal_code={(self.postal_code if hasattr(self, "postal_code") else None)!r}, '
                f'country_code={self.country_code!r}, '
                f'id={(self.id if hasattr(self, "id") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'address_line_1={(self.address_line_1 if hasattr(self, "address_line_1") else None)!s}, '
                f'address_line_2={(self.address_line_2 if hasattr(self, "address_line_2") else None)!s}, '
                f'admin_area_2={(self.admin_area_2 if hasattr(self, "admin_area_2") else None)!s}, '
                f'admin_area_1={(self.admin_area_1 if hasattr(self, "admin_area_1") else None)!s}, '
                f'postal_code={(self.postal_code if hasattr(self, "postal_code") else None)!s}, '
                f'country_code={self.country_code!s}, '
                f'id={(self.id if hasattr(self, "id") else None)!s})')
