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

"""
    pagarmecoreapi

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

from pagarmecoreapi.api_helper import APIHelper
import pagarmecoreapi.models.get_address_response

class GetShippingResponse(object):

    """Implementation of the 'GetShippingResponse' model.

    Response object for getting the shipping data

    Attributes:
        amount (int): TODO: type description here.
        description (string): TODO: type description here.
        recipient_name (string): TODO: type description here.
        recipient_phone (string): TODO: type description here.
        address (GetAddressResponse): TODO: type description here.
        max_delivery_date (datetime): Data máxima de entrega
        estimated_delivery_date (datetime): Prazo estimado de entrega
        mtype (string): Shipping Type

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "amount":'amount',
        "description":'description',
        "recipient_name":'recipient_name',
        "recipient_phone":'recipient_phone',
        "address":'address',
        "mtype":'type',
        "max_delivery_date":'max_delivery_date',
        "estimated_delivery_date":'estimated_delivery_date'
    }

    def __init__(self,
                 amount=None,
                 description=None,
                 recipient_name=None,
                 recipient_phone=None,
                 address=None,
                 mtype=None,
                 max_delivery_date=None,
                 estimated_delivery_date=None):
        """Constructor for the GetShippingResponse class"""

        # Initialize members of the class
        self.amount = amount
        self.description = description
        self.recipient_name = recipient_name
        self.recipient_phone = recipient_phone
        self.address = address
        self.max_delivery_date = APIHelper.RFC3339DateTime(max_delivery_date) if max_delivery_date else None
        self.estimated_delivery_date = APIHelper.RFC3339DateTime(estimated_delivery_date) if estimated_delivery_date else None
        self.mtype = mtype


    @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 dictionary is None:
            return None

        # Extract variables from the dictionary
        amount = dictionary.get('amount')
        description = dictionary.get('description')
        recipient_name = dictionary.get('recipient_name')
        recipient_phone = dictionary.get('recipient_phone')
        address = pagarmecoreapi.models.get_address_response.GetAddressResponse.from_dictionary(dictionary.get('address')) if dictionary.get('address') else None
        mtype = dictionary.get('type')
        max_delivery_date = APIHelper.RFC3339DateTime.from_value(dictionary.get("max_delivery_date")).datetime if dictionary.get("max_delivery_date") else None
        estimated_delivery_date = APIHelper.RFC3339DateTime.from_value(dictionary.get("estimated_delivery_date")).datetime if dictionary.get("estimated_delivery_date") else None

        # Return an object of this model
        return cls(amount,
                   description,
                   recipient_name,
                   recipient_phone,
                   address,
                   mtype,
                   max_delivery_date,
                   estimated_delivery_date)


