
"""
staxfattmerchantapi

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

from apimatic_core.http.response.api_response import ApiResponse as CoreApiResponse
from apimatic_core.http.response.http_response import HttpResponse


class ApiResponse(CoreApiResponse):
    """
    Represent a processed API response returned by an SDK operation.

    This class wraps the underlying HTTP response and provides convenient
    access to the response body, headers, and any errors returned by the API.
    """

    def __init__(self, http_response, body=None, errors=None):
        """
        Initialize an ApiResponse instance.

        Args:
            http_response (HttpResponse): The original HTTP response.
            body (object | None): The parsed response body.
            errors (list[str] | None): Any errors returned by the API.

        """
        super().__init__(http_response, body, errors)

    def __repr__(self):
        """
        Return a concise string representation of the response.

        Returns:
            str: A string identifying the ApiResponse instance.

        """
        return f"<ApiResponse {self.text}>"

    @classmethod
    def create(cls, parent_instance):
        """
        Create an ApiResponse instance from another response-like object.

        This method is typically used to adapt an internal or intermediate
        response object into a concrete ApiResponse instance.

        Args:
            parent_instance: An object containing HTTP response data.

        Returns:
            ApiResponse: A new ApiResponse instance.

        """
        return cls(
            HttpResponse(
                parent_instance.status_code,
                parent_instance.reason_phrase,
                parent_instance.headers,
                parent_instance.text,
                parent_instance.request),
            parent_instance.body,
            parent_instance.errors,
        )
