"""cellpointapi.

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

# ruff: noqa: D410, E501, E101, D206
from apimatic_core.authentication.multiple.single_auth import (
    Single,
)
from apimatic_core.request_builder import RequestBuilder
from apimatic_core.response_handler import ResponseHandler
from apimatic_core.types.parameter import Parameter

from cellpointapi.api_helper import APIHelper
from cellpointapi.apis.base_api import BaseApi
from cellpointapi.configuration import Server
from cellpointapi.exceptions.problem_exception import (
    ProblemException,
)
from cellpointapi.http.http_method_enum import (
    HttpMethodEnum,
)
from cellpointapi.models.wallet_tokenized_token import (
    WalletTokenizedToken,
)


class WalletApi(BaseApi):
    """A Controller to access Endpoints in the cellpointapi API."""

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

    def wallet_store_original_token(self,
                                    order_id,
                                    body=None):
        """Perform a POST request to
        /payments/v1/orders/{orderId}/wallet-tokens.

        Store original wallet token

        Args:
            order_id (str): The order to store the wallet token against.
            body (SaveWalletPaymentTokenRequest, optional): Request body containing
                the wallet token details.

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

        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("/payments/v1/orders/{orderId}/wallet-tokens")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("orderId")
                .value(order_id)
                .is_required(True)
                .should_encode(True))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .body_param(Parameter()
                .value(body))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("cpdIssuedJWT")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(WalletTokenizedToken.from_dictionary)
            .is_api_response(True)
            .local_error("400", "Bad Request", ProblemException),
        ).execute()
