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

"""
    apimaticcalculatorlatest

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

import dateutil.parser

class CancelReservationnotificationobject(object):

    """Implementation of the 'CancelReservationnotificationobject' model.

    TODO: type model description here.

    Attributes:
        reservation_id (string): Id of the reservation in BookingPal
        product_id (string): Id of the product in BookingPal
        supplier_id (int): Id of the property manager
        agent_name (string): Agent name/Channel name
        confirmation_id (string): Channel confirmation code
        unique_key (string): Unique code to identify that the request is from
            BookingPal. This value is unique for every PMS (and it will be
            different in different environments).
        new_state (string): It will always be "Cancelled" in this request
        customer_name (string): Guest full name (in format firstName,
            lastName)
        from_date (date): Reservation date from. Date is in format
            "yyyy-MM-dd"
        to_date (date): Reservation date to. Date is in format "yyyy-MM-dd"
        adult (int): Number of adults
        child (int): Number of children
        email (string): Guest email
        phone (string): Guest phone
        notes (string): Guest notes
        credit_card_type (string): Credit card type
        total (float): Best available rate (This is the total value that
            guests will pay, including rate, fees, taxes, and all commissions.
            )

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "reservation_id":'reservationId',
        "product_id":'productId',
        "supplier_id":'supplierId',
        "agent_name":'agentName',
        "confirmation_id":'confirmationId',
        "unique_key":'uniqueKey',
        "new_state":'newState',
        "customer_name":'customerName',
        "from_date":'fromDate',
        "to_date":'toDate',
        "adult":'adult',
        "child":'child',
        "email":'email',
        "total":'total',
        "phone":'phone',
        "notes":'notes',
        "credit_card_type":'creditCardType'
    }

    def __init__(self,
                 reservation_id=None,
                 product_id=None,
                 supplier_id=None,
                 agent_name=None,
                 confirmation_id=None,
                 unique_key=None,
                 new_state=None,
                 customer_name=None,
                 from_date=None,
                 to_date=None,
                 adult=None,
                 child=None,
                 email=None,
                 total=None,
                 phone=None,
                 notes=None,
                 credit_card_type=None):
        """Constructor for the CancelReservationnotificationobject class"""

        # Initialize members of the class
        self.reservation_id = reservation_id
        self.product_id = product_id
        self.supplier_id = supplier_id
        self.agent_name = agent_name
        self.confirmation_id = confirmation_id
        self.unique_key = unique_key
        self.new_state = new_state
        self.customer_name = customer_name
        self.from_date = from_date
        self.to_date = to_date
        self.adult = adult
        self.child = child
        self.email = email
        self.phone = phone
        self.notes = notes
        self.credit_card_type = credit_card_type
        self.total = total


    @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
        reservation_id = dictionary.get('reservationId')
        product_id = dictionary.get('productId')
        supplier_id = dictionary.get('supplierId')
        agent_name = dictionary.get('agentName')
        confirmation_id = dictionary.get('confirmationId')
        unique_key = dictionary.get('uniqueKey')
        new_state = dictionary.get('newState')
        customer_name = dictionary.get('customerName')
        from_date = dateutil.parser.parse(dictionary.get('fromDate')).date() if dictionary.get('fromDate') else None
        to_date = dateutil.parser.parse(dictionary.get('toDate')).date() if dictionary.get('toDate') else None
        adult = dictionary.get('adult')
        child = dictionary.get('child')
        email = dictionary.get('email')
        total = dictionary.get('total')
        phone = dictionary.get('phone')
        notes = dictionary.get('notes')
        credit_card_type = dictionary.get('creditCardType')

        # Return an object of this model
        return cls(reservation_id,
                   product_id,
                   supplier_id,
                   agent_name,
                   confirmation_id,
                   unique_key,
                   new_state,
                   customer_name,
                   from_date,
                   to_date,
                   adult,
                   child,
                   email,
                   total,
                   phone,
                   notes,
                   credit_card_type)


