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

"""
shelldatareportingapis

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from shelldatareportingapis.api_helper import APIHelper
from shelldatareportingapis.models.default_error_fault_detail import DefaultErrorFaultDetail


class DefaultErrorFault(object):

    """Implementation of the 'DefaultErrorFault' model.

    Error object

    Attributes:
        faultstring (str): Error Description
        detail (DefaultErrorFaultDetail): Details about the error

    """

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

    _optionals = [
        'faultstring',
        'detail',
    ]

    def __init__(self,
                 faultstring=APIHelper.SKIP,
                 detail=APIHelper.SKIP):
        """Constructor for the DefaultErrorFault class"""

        # Initialize members of the class
        if faultstring is not APIHelper.SKIP:
            self.faultstring = faultstring 
        if detail is not APIHelper.SKIP:
            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 not isinstance(dictionary, dict) or dictionary is None:
            return None

        # Extract variables from the dictionary
        faultstring = dictionary.get("faultstring") if dictionary.get("faultstring") else APIHelper.SKIP
        detail = DefaultErrorFaultDetail.from_dictionary(dictionary.get('detail')) if 'detail' in dictionary.keys() else APIHelper.SKIP
        # Return an object of this model
        return cls(faultstring,
                   detail)
