# This file was generated by liblab | https://liblab.com/

from .utils.validator import Validator
from .utils.base_service import BaseService
from ..net.transport.serializer import Serializer
from ..models.utils.cast_models import cast_models
from ..models.place_teaser_bet_response import PlaceTeaserBetResponse
from ..models.place_teaser_bet_request import PlaceTeaserBetRequest
from ..models.place_straight_bet_response import PlaceStraightBetResponse
from ..models.place_parlay_bet_response import PlaceParlayBetResponse
from ..models.place_parlay_bet_request import PlaceParlayBetRequest
from ..models.place_bet_request import PlaceBetRequest
from ..models.multi_bet_response_special_bet_response import (
    MultiBetResponseSpecialBetResponse,
)
from ..models.multi_bet_request_special_bet_request import (
    MultiBetRequestSpecialBetRequest,
)


class PlaceBetsService(BaseService):

    @cast_models
    def bets_straight_v2(
        self, request_body: PlaceBetRequest
    ) -> PlaceStraightBetResponse:
        """Place straight bet (SPREAD, MONEYLINE, TOTAL_POINTS, TEAM_TOTAL_POINTS).

        Please note when the status is PENDING_ACCEPTANCE and if the live delay was applied, the response will not have betId. Client would have to call /bets by uniqueRequestId to check the status if the bet was ACCEPTED.  For more details please see [How to place a bet on live events?](https://github.com/pinnacleapi/pinnacleapi-documentation/blob/master/FAQ.md#how-to-place-a-bet-on-live-events)

        Make sure you handle properly the case of an unexpected error as per
         [How to handle error on placing a bet?](https://github.com/pinnacleapi/pinnacleapi-documentation/blob/master/FAQ.md#how-to-handle-unexpected-error-on-placing-a-bet)

        :param request_body: The request body.
        :type request_body: PlaceBetRequest
        ...
        :raises RequestError: Raised when a request fails, with optional HTTP status code and details.
        ...
        :return: OK
        :rtype: PlaceStraightBetResponse
        """

        Validator(PlaceBetRequest).validate(request_body)

        serialized_request = (
            Serializer(f"{self.base_url}/v4/bets/straight", self.get_default_headers())
            .serialize()
            .set_method("POST")
            .set_body(request_body)
        )

        response = self.send_request(serialized_request)

        return PlaceStraightBetResponse._unmap(response)

    @cast_models
    def bets_parlay_v2(
        self, request_body: PlaceParlayBetRequest
    ) -> PlaceParlayBetResponse:
        """Make sure you handle properly the case of an unexpected error as per
         [How to handle error on placing a bet?](https://github.com/pinnacleapi/pinnacleapi-documentation/blob/master/FAQ.md#how-to-handle-unexpected-error-on-placing-a-bet)

        :param request_body: The request body.
        :type request_body: PlaceParlayBetRequest
        ...
        :raises RequestError: Raised when a request fails, with optional HTTP status code and details.
        ...
        :return: OK
        :rtype: PlaceParlayBetResponse
        """

        Validator(PlaceParlayBetRequest).validate(request_body)

        serialized_request = (
            Serializer(f"{self.base_url}/v4/bets/parlay", self.get_default_headers())
            .serialize()
            .set_method("POST")
            .set_body(request_body)
        )

        response = self.send_request(serialized_request)

        return PlaceParlayBetResponse._unmap(response)

    @cast_models
    def bets_teaser(
        self, request_body: PlaceTeaserBetRequest
    ) -> PlaceTeaserBetResponse:
        """Make sure you handle properly the case of an unexpected error as per
         [How to handle error on placing a bet?](https://github.com/pinnacleapi/pinnacleapi-documentation/blob/master/FAQ.md#how-to-handle-unexpected-error-on-placing-a-bet)

        :param request_body: The request body.
        :type request_body: PlaceTeaserBetRequest
        ...
        :raises RequestError: Raised when a request fails, with optional HTTP status code and details.
        ...
        :return: OK
        :rtype: PlaceTeaserBetResponse
        """

        Validator(PlaceTeaserBetRequest).validate(request_body)

        serialized_request = (
            Serializer(f"{self.base_url}/v4/bets/teaser", self.get_default_headers())
            .serialize()
            .set_method("POST")
            .set_body(request_body)
        )

        response = self.send_request(serialized_request)

        return PlaceTeaserBetResponse._unmap(response)

    @cast_models
    def bets_special(
        self, request_body: MultiBetRequestSpecialBetRequest
    ) -> MultiBetResponseSpecialBetResponse:
        """Make sure you handle properly the case of an unexpected error as per
         [How to handle error on placing a bet?](https://github.com/pinnacleapi/pinnacleapi-documentation/blob/master/FAQ.md#how-to-handle-unexpected-error-on-placing-a-bet)

        :param request_body: The request body.
        :type request_body: MultiBetRequestSpecialBetRequest
        ...
        :raises RequestError: Raised when a request fails, with optional HTTP status code and details.
        ...
        :return: OK
        :rtype: MultiBetResponseSpecialBetResponse
        """

        Validator(MultiBetRequestSpecialBetRequest).validate(request_body)

        serialized_request = (
            Serializer(f"{self.base_url}/v4/bets/special", self.get_default_headers())
            .serialize()
            .set_method("POST")
            .set_body(request_body)
        )

        response = self.send_request(serialized_request)

        return MultiBetResponseSpecialBetResponse._unmap(response)
