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

"""
uexcorpapi

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

from uexcorpapi.api_helper import APIHelper
from uexcorpapi.exceptions.api_exception import ApiException


class BadRequestException(ApiException):
    def __init__(self, reason, response):
        """Constructor for the BadRequestException class

        Args:
            reason (string): The reason (or error message) for the Exception
                to be raised.
            response (HttpResponse): The HttpResponse of the API call.

        """
        super(BadRequestException, self).__init__(reason, response)
        dictionary = APIHelper.json_deserialize(self.response.text)
        if isinstance(dictionary, dict):
            self.unbox(dictionary)

    def unbox(self, dictionary):
        """Populates the properties of this object by extracting them 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.

        """
        self.data = dictionary.get("data") if dictionary.get("data") else None
        self.http_code = dictionary.get("http_code") if dictionary.get("http_code") else None
        self.message = dictionary.get("message") if dictionary.get("message") else None
        self.status = dictionary.get("status") if dictionary.get("status") else None

    def __str__(self):
        base_str = super().__str__()
        return (f'{self.__class__.__name__}('
                f'{base_str[base_str.find("(") + 1:-1]}, '
                f'data={self.data!s}, '
                f'http_code={self.http_code!s}, '
                f'message={self.message!s}, '
                f'status={self.status!s})')
