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

"""
    apimaticcalculatorlatest

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

import dateutil.parser

class Thread(object):

    """Implementation of the 'Thread' model.

    TODO: type model description here.

    Attributes:
        id (int): Thread ID
        last_message_sent_at (string): Time when last message was sent
        last_message_text (string): Last message text
        channel_name (string): Channel from where come reservation
        channel_abb (ChannelABBEnum): TODO: type description here.
        guest_name (string): Name of guest
        guest_email_address (string): Email of guest
        product_id (int): ID of product in BookingPal database
        reservation_id (int): ID of reservation
        date_from (date): Start date of reservation. Date is in format
            "yyyy-MM-dd"
        date_to (date): End date of reservation. Date is in format
            "yyyy-MM-dd"

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "id":'id',
        "last_message_sent_at":'lastMessageSentAt',
        "last_message_text":'lastMessageText',
        "channel_name":'channelName',
        "channel_abb":'channelABB',
        "guest_name":'guestName',
        "guest_email_address":'guestEmailAddress',
        "product_id":'productId',
        "date_from":'dateFrom',
        "date_to":'dateTo',
        "reservation_id":'reservationId'
    }

    def __init__(self,
                 id=None,
                 last_message_sent_at=None,
                 last_message_text=None,
                 channel_name=None,
                 channel_abb=None,
                 guest_name=None,
                 guest_email_address=None,
                 product_id=None,
                 date_from=None,
                 date_to=None,
                 reservation_id=None):
        """Constructor for the Thread class"""

        # Initialize members of the class
        self.id = id
        self.last_message_sent_at = last_message_sent_at
        self.last_message_text = last_message_text
        self.channel_name = channel_name
        self.channel_abb = channel_abb
        self.guest_name = guest_name
        self.guest_email_address = guest_email_address
        self.product_id = product_id
        self.reservation_id = reservation_id
        self.date_from = date_from
        self.date_to = date_to


    @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
        id = dictionary.get('id')
        last_message_sent_at = dictionary.get('lastMessageSentAt')
        last_message_text = dictionary.get('lastMessageText')
        channel_name = dictionary.get('channelName')
        channel_abb = dictionary.get('channelABB')
        guest_name = dictionary.get('guestName')
        guest_email_address = dictionary.get('guestEmailAddress')
        product_id = dictionary.get('productId')
        date_from = dateutil.parser.parse(dictionary.get('dateFrom')).date() if dictionary.get('dateFrom') else None
        date_to = dateutil.parser.parse(dictionary.get('dateTo')).date() if dictionary.get('dateTo') else None
        reservation_id = dictionary.get('reservationId')

        # Return an object of this model
        return cls(id,
                   last_message_sent_at,
                   last_message_text,
                   channel_name,
                   channel_abb,
                   guest_name,
                   guest_email_address,
                   product_id,
                   date_from,
                   date_to,
                   reservation_id)


