Skip to main content

FiscusResponse Class (API Reference)

The FiscusResponse class represents the result of executing an operation in the Fiscus SDK. It contains information about the success or failure of the operation, as well as additional details such as the result, error messages, status codes, headers, and logs.

Initialization

__init__

__init__(self, success: bool, result: Any = None, error_message: Optional[str] = None, status_code: Optional[int] = None, headers: Optional[Dict[str, Any]] = None, raw_response: Optional[Any] = None, logs: Optional[List[Dict[str, Any]]] = None)

Initializes a new FiscusResponse instance.

Parameters:
  • success (bool): Indicates whether the operation was successful.
  • result (Any, optional): The result of the operation, if successful.
  • error_message (Optional[str], optional): The error message if the operation failed.
  • status_code (Optional[int], optional): The HTTP status code associated with the operation, if applicable.
  • headers (Optional[Dict[str, Any]], optional): A dictionary containing response headers.
  • raw_response (Optional[Any], optional): The raw response from the API or service.
  • logs (Optional[List[Dict[str, Any]]], optional): A list of logs associated with the operation.

Methods

to_json

to_json(self) -> Dict[str, Any]

Converts the FiscusResponse object to a JSON-serializable dictionary.

Parameters:
  • None.
Returns:
  • Dict[str, Any]: A dictionary containing the success status, result, error message, status code, headers, and raw response.

to_text

to_text(self) -> str

Converts the FiscusResponse object to a human-readable string format.

Parameters:
  • None.
Returns:
  • str: A string representation of the result if successful, or an error message if the operation failed.

get_header

get_header(self, key: str) -> Any

Retrieves a specific header from the response, if available.

Parameters:
  • key (str): The name of the header to retrieve.
Returns:
  • Any: The value of the requested header, or None if the header is not found.

get_logs

get_logs(self) -> List[Dict[str, Any]]

Retrieves the logs associated with the response.

Parameters:
  • None.
Returns:
  • List[Dict[str, Any]]: A list of log entries related to the operation.