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

"""
cookiesapi

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from cookiesapi.models.error_detail import ErrorDetail


class ErrorInfo(object):

    """Implementation of the 'ErrorInfo' model.

    Information describing an error that occurred while transacting with the
    API.

    Attributes:
        faultstring (string): Describes the error with a readable label or
            message.
        detail (ErrorDetail): Further info about the error.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "faultstring": 'faultstring',
        "detail": 'detail'
    }

    def __init__(self,
                 faultstring=None,
                 detail=None):
        """Constructor for the ErrorInfo class"""

        # Initialize members of the class
        self.faultstring = faultstring
        self.detail = detail

    @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
        faultstring = dictionary.get('faultstring')
        detail = ErrorDetail.from_dictionary(dictionary.get('detail')) if dictionary.get('detail') else None

        # Return an object of this model
        return cls(faultstring,
                   detail)
