from pyuspostalservice.endpoints.base.base_endpoint import USPSEndpoint
from pyuspostalservice.endpoints.usps.TrackingTrackingEndpoint import TrackingTrackingEndpoint
from pyuspostalservice.endpoints.usps.TrackingIdEndpoint import TrackingIdEndpoint


class TrackingEndpoint(
    USPSEndpoint,
):
    def __init__(self, client, parent_endpoint=None) -> None:
        USPSEndpoint.__init__(self, client, "tracking/v3r2", parent_endpoint=parent_endpoint)
        self.tracking = self._register_child_endpoint(TrackingTrackingEndpoint(client, parent_endpoint=self))

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

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