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

"""
    apimaticcalculatorlatest

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

import apimaticcalculatorlatest.models.rate
import apimaticcalculatorlatest.models.min_stay_model
import apimaticcalculatorlatest.models.max_stay_model
import apimaticcalculatorlatest.models.restriction
import apimaticcalculatorlatest.models.availability_model
import apimaticcalculatorlatest.models.available_count

class RatesAvailability(object):

    """Implementation of the 'RatesAvailability' model.

    Rates Availability model

    Attributes:
        product_id (int): ID of the product
        lead_time (int): Number of days before reservation in which
            reservation couldn’t be made. Allowed values are 0-7. If this
            value is set on property level - it will be used before than value
            on PM level.
        rates (list of Rate): List of models
        min_stays (list of MinStayModel): List of models
        max_stays (list of MaxStayModel): List of models
        restrictions (list of Restriction): List of models
        availabilities (list of AvailabilityModel): List of models
        available_count (list of AvailableCount): List of models (Only for MLT
            properties)

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "product_id":'productId',
        "lead_time":'leadTime',
        "rates":'rates',
        "min_stays":'minStays',
        "max_stays":'maxStays',
        "restrictions":'restrictions',
        "availabilities":'availabilities',
        "available_count":'availableCount'
    }

    def __init__(self,
                 product_id=None,
                 lead_time=None,
                 rates=None,
                 min_stays=None,
                 max_stays=None,
                 restrictions=None,
                 availabilities=None,
                 available_count=None):
        """Constructor for the RatesAvailability class"""

        # Initialize members of the class
        self.product_id = product_id
        self.lead_time = lead_time
        self.rates = rates
        self.min_stays = min_stays
        self.max_stays = max_stays
        self.restrictions = restrictions
        self.availabilities = availabilities
        self.available_count = available_count


    @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
        product_id = dictionary.get('productId')
        lead_time = dictionary.get('leadTime')
        rates = None
        if dictionary.get('rates') != None:
            rates = list()
            for structure in dictionary.get('rates'):
                rates.append(apimaticcalculatorlatest.models.rate.Rate.from_dictionary(structure))
        min_stays = None
        if dictionary.get('minStays') != None:
            min_stays = list()
            for structure in dictionary.get('minStays'):
                min_stays.append(apimaticcalculatorlatest.models.min_stay_model.MinStayModel.from_dictionary(structure))
        max_stays = None
        if dictionary.get('maxStays') != None:
            max_stays = list()
            for structure in dictionary.get('maxStays'):
                max_stays.append(apimaticcalculatorlatest.models.max_stay_model.MaxStayModel.from_dictionary(structure))
        restrictions = None
        if dictionary.get('restrictions') != None:
            restrictions = list()
            for structure in dictionary.get('restrictions'):
                restrictions.append(apimaticcalculatorlatest.models.restriction.Restriction.from_dictionary(structure))
        availabilities = None
        if dictionary.get('availabilities') != None:
            availabilities = list()
            for structure in dictionary.get('availabilities'):
                availabilities.append(apimaticcalculatorlatest.models.availability_model.AvailabilityModel.from_dictionary(structure))
        available_count = None
        if dictionary.get('availableCount') != None:
            available_count = list()
            for structure in dictionary.get('availableCount'):
                available_count.append(apimaticcalculatorlatest.models.available_count.AvailableCount.from_dictionary(structure))

        # Return an object of this model
        return cls(product_id,
                   lead_time,
                   rates,
                   min_stays,
                   max_stays,
                   restrictions,
                   availabilities,
                   available_count)


