"""apimaticcalculator.

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

# ruff: noqa: D410, E501, E101, D206
from apimatic_core.request_builder import RequestBuilder
from apimatic_core.response_handler import ResponseHandler
from apimatic_core.types.parameter import Parameter

from apimaticcalculator.api_helper import APIHelper
from apimaticcalculator.apis.base_api import (
    BaseApi,
)
from apimaticcalculator.configuration import (
    Server,
)
from apimaticcalculator.http.http_method_enum import (
    HttpMethodEnum,
)


class SimpleCalculatorApi(BaseApi):
    """A Controller to access Endpoints in the apimaticcalculator API."""

    def __init__(self, config):
        """Initialize SimpleCalculatorApi object."""
        super(SimpleCalculatorApi, self).__init__(config)

    def calculate(self,
                  operation,
                  x,
                  y):
        """Perform a GET request to /{operation}.

        Calculates the expression using the specified operation.

        Args:
            operation (OperationType): The operator to apply on the variables
            x (float): The LHS value
            y (float): The RHS value

        Returns:
            ApiResponse: An object with the response value as well as other useful
                information such as status codes and headers.

        Raises:
            ApiException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/{operation}")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("operation")
                .value(operation)
                .is_required(True)
                .should_encode(True))
            .query_param(Parameter()
                .key("x")
                .value(x)
                .is_required(True))
            .query_param(Parameter()
                .key("y")
                .value(y)
                .is_required(True)),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .is_api_response(True),
        ).execute()
