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

"""
    apimaticcalculatorlatest

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

import dateutil.parser

class AvailabilityModel(object):

    """Implementation of the 'AvailabilityModel' model.

    TODO: type model description here.

    Attributes:
        begin_date (date): Beginning date of date range for which availability
            is applied. Date should be in format "yyyy-MM-dd"
        end_date (date): End date of date range for which availability is
            applied. Additional clarification: If you have reservation from
            2020/08/05 - 2020/08/09, so checkout is on 2020/08/09 - you should
            send end date 2020/08/08, since 2020/08/09 is actually open for
            new reservation. Date should be in format "yyyy-MM-dd"
        availability (bool): Determines if the dates are available or not. Our
            system saves only not available dates, so it is enough that you
            sent only not available dates. But if you want to open dates that
            you previously sent that are not available, you need to send that
            these dates are available over API.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "begin_date":'beginDate',
        "end_date":'endDate',
        "availability":'availability'
    }

    def __init__(self,
                 begin_date=None,
                 end_date=None,
                 availability=None):
        """Constructor for the AvailabilityModel class"""

        # Initialize members of the class
        self.begin_date = begin_date
        self.end_date = end_date
        self.availability = availability


    @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
        begin_date = dateutil.parser.parse(dictionary.get('beginDate')).date() if dictionary.get('beginDate') else None
        end_date = dateutil.parser.parse(dictionary.get('endDate')).date() if dictionary.get('endDate') else None
        availability = dictionary.get('availability')

        # Return an object of this model
        return cls(begin_date,
                   end_date,
                   availability)


