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

"""
paypalserversdk

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


class SimplePostalAddressCoarseGrained(object):

    """Implementation of the 'Simple Postal Address (Coarse-Grained)' model.

    A simple postal address with coarse-grained fields. Do not use for an
    international address. Use for backward compatibility only. Does not
    contain phone.

    Attributes:
        line_1 (str): The first line of the address. For example, number or
            street.
        line_2 (str): The second line of the address. For example, suite or
            apartment number.
        city (str): The city name.
        state (str): The [code](/docs/api/reference/state-codes/) for a US
            state or the equivalent for other countries. Required for
            transactions if the address is in one of these countries:
            [Argentina](/docs/api/reference/state-codes/#argentina),
            [Brazil](/docs/api/reference/state-codes/#brazil),
            [Canada](/docs/api/reference/state-codes/#canada),
            [China](/docs/api/reference/state-codes/#china),
            [India](/docs/api/reference/state-codes/#india),
            [Italy](/docs/api/reference/state-codes/#italy),
            [Japan](/docs/api/reference/state-codes/#japan),
            [Mexico](/docs/api/reference/state-codes/#mexico),
            [Thailand](/docs/api/reference/state-codes/#thailand), or [United
            States](/docs/api/reference/state-codes/#usa). Maximum length is
            40 single-byte characters.
        country_code (str): The [two-character ISO 3166-1
            code](/docs/integration/direct/rest/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.
        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).

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "line_1": 'line1',
        "city": 'city',
        "country_code": 'country_code',
        "line_2": 'line2',
        "state": 'state',
        "postal_code": 'postal_code'
    }

    _optionals = [
        'line_2',
        'state',
        'postal_code',
    ]

    def __init__(self,
                 line_1=None,
                 city=None,
                 country_code=None,
                 line_2=APIHelper.SKIP,
                 state=APIHelper.SKIP,
                 postal_code=APIHelper.SKIP):
        """Constructor for the SimplePostalAddressCoarseGrained class"""

        # Initialize members of the class
        self.line_1 = line_1 
        if line_2 is not APIHelper.SKIP:
            self.line_2 = line_2 
        self.city = city 
        if state is not APIHelper.SKIP:
            self.state = state 
        self.country_code = country_code 
        if postal_code is not APIHelper.SKIP:
            self.postal_code = postal_code 

    @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
        line_1 = dictionary.get("line1") if dictionary.get("line1") else None
        city = dictionary.get("city") if dictionary.get("city") else None
        country_code = dictionary.get("country_code") if dictionary.get("country_code") else None
        line_2 = dictionary.get("line2") if dictionary.get("line2") else APIHelper.SKIP
        state = dictionary.get("state") if dictionary.get("state") else APIHelper.SKIP
        postal_code = dictionary.get("postal_code") if dictionary.get("postal_code") else APIHelper.SKIP
        # Return an object of this model
        return cls(line_1,
                   city,
                   country_code,
                   line_2,
                   state,
                   postal_code)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'line_1={self.line_1!r}, '
                f'line_2={(self.line_2 if hasattr(self, "line_2") else None)!r}, '
                f'city={self.city!r}, '
                f'state={(self.state if hasattr(self, "state") else None)!r}, '
                f'country_code={self.country_code!r}, '
                f'postal_code={(self.postal_code if hasattr(self, "postal_code") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'line_1={self.line_1!s}, '
                f'line_2={(self.line_2 if hasattr(self, "line_2") else None)!s}, '
                f'city={self.city!s}, '
                f'state={(self.state if hasattr(self, "state") else None)!s}, '
                f'country_code={self.country_code!s}, '
                f'postal_code={(self.postal_code if hasattr(self, "postal_code") else None)!s})')
