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

"""
paypalserversdk

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


class ShippingInformation(object):

    """Implementation of the 'Shipping Information' model.

    The shipping information.

    Attributes:
        name (str): The recipient's name.
        method (str): The shipping method that is associated with this order.
        address (SimplePostalAddressCoarseGrained): A simple postal address
            with coarse-grained fields. Do not use for an international
            address. Use for backward compatibility only. Does not contain
            phone.
        secondary_shipping_address (SimplePostalAddressCoarseGrained): A
            simple postal address with coarse-grained fields. Do not use for
            an international address. Use for backward compatibility only.
            Does not contain phone.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "name": 'name',
        "method": 'method',
        "address": 'address',
        "secondary_shipping_address": 'secondary_shipping_address'
    }

    _optionals = [
        'name',
        'method',
        'address',
        'secondary_shipping_address',
    ]

    def __init__(self,
                 name=APIHelper.SKIP,
                 method=APIHelper.SKIP,
                 address=APIHelper.SKIP,
                 secondary_shipping_address=APIHelper.SKIP):
        """Constructor for the ShippingInformation class"""

        # Initialize members of the class
        if name is not APIHelper.SKIP:
            self.name = name 
        if method is not APIHelper.SKIP:
            self.method = method 
        if address is not APIHelper.SKIP:
            self.address = address 
        if secondary_shipping_address is not APIHelper.SKIP:
            self.secondary_shipping_address = secondary_shipping_address 

    @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
        name = dictionary.get("name") if dictionary.get("name") else APIHelper.SKIP
        method = dictionary.get("method") if dictionary.get("method") else APIHelper.SKIP
        address = SimplePostalAddressCoarseGrained.from_dictionary(dictionary.get('address')) if 'address' in dictionary.keys() else APIHelper.SKIP
        secondary_shipping_address = SimplePostalAddressCoarseGrained.from_dictionary(dictionary.get('secondary_shipping_address')) if 'secondary_shipping_address' in dictionary.keys() else APIHelper.SKIP
        # Return an object of this model
        return cls(name,
                   method,
                   address,
                   secondary_shipping_address)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'name={(self.name if hasattr(self, "name") else None)!r}, '
                f'method={(self.method if hasattr(self, "method") else None)!r}, '
                f'address={(self.address if hasattr(self, "address") else None)!r}, '
                f'secondary_shipping_address={(self.secondary_shipping_address if hasattr(self, "secondary_shipping_address") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'name={(self.name if hasattr(self, "name") else None)!s}, '
                f'method={(self.method if hasattr(self, "method") else None)!s}, '
                f'address={(self.address if hasattr(self, "address") else None)!s}, '
                f'secondary_shipping_address={(self.secondary_shipping_address if hasattr(self, "secondary_shipping_address") else None)!s})')
