from pyuspostalservice.endpoints.base.base_endpoint import USPSEndpoint
from pyuspostalservice.endpoints.usps.TeamMembersIdEndpoint import TeamMembersIdEndpoint
from pyuspostalservice.interfaces import (
    IPostable,
)
from pyuspostalservice.models.usps import TeamMember
from pyuspostalservice.types import (
    JSON,
    USPSRequestParams,
)


class TeamMembersEndpoint(
    USPSEndpoint,
    IPostable[TeamMember, USPSRequestParams],
):
    def __init__(self, client, parent_endpoint=None) -> None:
        USPSEndpoint.__init__(self, client, "team-members", parent_endpoint=parent_endpoint)
        IPostable.__init__(self, TeamMember)

    def id(self, id: int) -> TeamMembersIdEndpoint:
        """
        Sets the ID for this endpoint and returns an initialized TeamMembersIdEndpoint object to move down the chain.

        Parameters:
            id (int): The ID to set.
        Returns:
            TeamMembersIdEndpoint: The initialized TeamMembersIdEndpoint object.
        """
        child = TeamMembersIdEndpoint(self.client, parent_endpoint=self)
        child._id = id
        return child

    def post(self, data: JSON | None = None, params: USPSRequestParams | None = None) -> TeamMember:
        """
        Performs a POST request against the /team-members endpoint.

        Parameters:
            data (dict[str, Any]): The data to send in the request body.
            params (dict[str, int | str]): The parameters to send in the request query string.
        Returns:
            TeamMember: The parsed response data.
        """
        return self._parse_one(TeamMember, super()._make_request("POST", data=data, params=params).json())
