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

"""
    apimaticcalculatorlatest

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

import apimaticcalculatorlatest.models.rates_availability

class RatesAvailabilityresponse(object):

    """Implementation of the 'RatesAvailabilityresponse' model.

    Rates Availability response

    Attributes:
        message (string): text info message
        error_message (list of string): List of error messages
        is_error (bool): Is error (default = false)
        code (string): Code of message
        data (list of RatesAvailability): List of models. This is a deprecated
            field. It will be removed in version 3.3. (This is only for Create
            and update requests, so you will not get this data in response).
            On GET request you will get data here.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "message":'message',
        "error_message":'errorMessage',
        "is_error":'is_error',
        "code":'code',
        "data":'data'
    }

    def __init__(self,
                 message=None,
                 error_message=None,
                 is_error=None,
                 code=None,
                 data=None):
        """Constructor for the RatesAvailabilityresponse class"""

        # Initialize members of the class
        self.message = message
        self.error_message = error_message
        self.is_error = is_error
        self.code = code
        self.data = data


    @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
        message = dictionary.get('message')
        error_message = dictionary.get('errorMessage')
        is_error = dictionary.get('is_error')
        code = dictionary.get('code')
        data = None
        if dictionary.get('data') != None:
            data = list()
            for structure in dictionary.get('data'):
                data.append(apimaticcalculatorlatest.models.rates_availability.RatesAvailability.from_dictionary(structure))

        # Return an object of this model
        return cls(message,
                   error_message,
                   is_error,
                   code,
                   data)


