diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b5db7ce..c373724 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.7" + ".": "0.1.0-alpha.8" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index fa549e7..85cf09d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 16 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-7a71bec90a568b0dbefc3d81206069d9759259460cffa0543b162f6835be1e9a.yml +configured_endpoints: 17 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/open-transit%2Fopen-transit-160e2615de51b1febaeb9f4a2fbbb7e70939e1ebec74946e7ec1e026868fed7e.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index fdbe776..3657eed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.1.0-alpha.8 (2024-07-30) + +Full Changelog: [v0.1.0-alpha.7...v0.1.0-alpha.8](https://github.com/OneBusAway/python-sdk/compare/v0.1.0-alpha.7...v0.1.0-alpha.8) + +### Features + +* **api:** OpenAPI spec update via Stainless API ([#31](https://github.com/OneBusAway/python-sdk/issues/31)) ([891cdf5](https://github.com/OneBusAway/python-sdk/commit/891cdf59961594e7bfb21fc25e8615b3c536dc8e)) + ## 0.1.0-alpha.7 (2024-07-29) Full Changelog: [v0.1.0-alpha.6...v0.1.0-alpha.7](https://github.com/OneBusAway/python-sdk/compare/v0.1.0-alpha.6...v0.1.0-alpha.7) diff --git a/api.md b/api.md index ac324dd..8404d9c 100644 --- a/api.md +++ b/api.md @@ -112,6 +112,18 @@ Methods: - client.stop_ids_for_agency.list(agency_id) -> StopIDsForAgencyListResponse +# ScheduleForStop + +Types: + +```python +from onebusaway.types import ScheduleForStopRetrieveResponse +``` + +Methods: + +- client.schedule_for_stop.retrieve(stop_id, \*\*params) -> ScheduleForStopRetrieveResponse + # Route Types: diff --git a/examples/schedule_for_stop.py b/examples/schedule_for_stop.py new file mode 100644 index 0000000..05eaf2f --- /dev/null +++ b/examples/schedule_for_stop.py @@ -0,0 +1,16 @@ +import onebusaway + + +def main_sync() -> None: + client = onebusaway.OnebusawaySDK(api_key="TEST") + stop_id = "1_75403" + schedule_for_stop = client.schedule_for_stop.retrieve(stop_id) + + if schedule_for_stop.data and schedule_for_stop.data.entry: + print(schedule_for_stop.data.entry) + else: + print("schedule data or entry is None.") + + +if __name__ == "__main__": + main_sync() diff --git a/pyproject.toml b/pyproject.toml index 63a507b..e7d967d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "onebusaway" -version = "0.1.0-alpha.7" +version = "0.1.0-alpha.8" description = "The official Python library for the onebusaway-sdk API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/onebusaway/_client.py b/src/onebusaway/_client.py index de1458c..4d0abe9 100644 --- a/src/onebusaway/_client.py +++ b/src/onebusaway/_client.py @@ -55,6 +55,7 @@ class OnebusawaySDK(SyncAPIClient): stops_for_route: resources.StopsForRouteResource stop: resources.StopResource stop_ids_for_agency: resources.StopIDsForAgencyResource + schedule_for_stop: resources.ScheduleForStopResource route: resources.RouteResource arrival_and_departure: resources.ArrivalAndDepartureResource trip: resources.TripResource @@ -127,6 +128,7 @@ def __init__( self.stops_for_route = resources.StopsForRouteResource(self) self.stop = resources.StopResource(self) self.stop_ids_for_agency = resources.StopIDsForAgencyResource(self) + self.schedule_for_stop = resources.ScheduleForStopResource(self) self.route = resources.RouteResource(self) self.arrival_and_departure = resources.ArrivalAndDepartureResource(self) self.trip = resources.TripResource(self) @@ -259,6 +261,7 @@ class AsyncOnebusawaySDK(AsyncAPIClient): stops_for_route: resources.AsyncStopsForRouteResource stop: resources.AsyncStopResource stop_ids_for_agency: resources.AsyncStopIDsForAgencyResource + schedule_for_stop: resources.AsyncScheduleForStopResource route: resources.AsyncRouteResource arrival_and_departure: resources.AsyncArrivalAndDepartureResource trip: resources.AsyncTripResource @@ -331,6 +334,7 @@ def __init__( self.stops_for_route = resources.AsyncStopsForRouteResource(self) self.stop = resources.AsyncStopResource(self) self.stop_ids_for_agency = resources.AsyncStopIDsForAgencyResource(self) + self.schedule_for_stop = resources.AsyncScheduleForStopResource(self) self.route = resources.AsyncRouteResource(self) self.arrival_and_departure = resources.AsyncArrivalAndDepartureResource(self) self.trip = resources.AsyncTripResource(self) @@ -466,6 +470,7 @@ def __init__(self, client: OnebusawaySDK) -> None: self.stops_for_route = resources.StopsForRouteResourceWithRawResponse(client.stops_for_route) self.stop = resources.StopResourceWithRawResponse(client.stop) self.stop_ids_for_agency = resources.StopIDsForAgencyResourceWithRawResponse(client.stop_ids_for_agency) + self.schedule_for_stop = resources.ScheduleForStopResourceWithRawResponse(client.schedule_for_stop) self.route = resources.RouteResourceWithRawResponse(client.route) self.arrival_and_departure = resources.ArrivalAndDepartureResourceWithRawResponse(client.arrival_and_departure) self.trip = resources.TripResourceWithRawResponse(client.trip) @@ -487,6 +492,7 @@ def __init__(self, client: AsyncOnebusawaySDK) -> None: self.stops_for_route = resources.AsyncStopsForRouteResourceWithRawResponse(client.stops_for_route) self.stop = resources.AsyncStopResourceWithRawResponse(client.stop) self.stop_ids_for_agency = resources.AsyncStopIDsForAgencyResourceWithRawResponse(client.stop_ids_for_agency) + self.schedule_for_stop = resources.AsyncScheduleForStopResourceWithRawResponse(client.schedule_for_stop) self.route = resources.AsyncRouteResourceWithRawResponse(client.route) self.arrival_and_departure = resources.AsyncArrivalAndDepartureResourceWithRawResponse( client.arrival_and_departure @@ -510,6 +516,7 @@ def __init__(self, client: OnebusawaySDK) -> None: self.stops_for_route = resources.StopsForRouteResourceWithStreamingResponse(client.stops_for_route) self.stop = resources.StopResourceWithStreamingResponse(client.stop) self.stop_ids_for_agency = resources.StopIDsForAgencyResourceWithStreamingResponse(client.stop_ids_for_agency) + self.schedule_for_stop = resources.ScheduleForStopResourceWithStreamingResponse(client.schedule_for_stop) self.route = resources.RouteResourceWithStreamingResponse(client.route) self.arrival_and_departure = resources.ArrivalAndDepartureResourceWithStreamingResponse( client.arrival_and_departure @@ -539,6 +546,7 @@ def __init__(self, client: AsyncOnebusawaySDK) -> None: self.stop_ids_for_agency = resources.AsyncStopIDsForAgencyResourceWithStreamingResponse( client.stop_ids_for_agency ) + self.schedule_for_stop = resources.AsyncScheduleForStopResourceWithStreamingResponse(client.schedule_for_stop) self.route = resources.AsyncRouteResourceWithStreamingResponse(client.route) self.arrival_and_departure = resources.AsyncArrivalAndDepartureResourceWithStreamingResponse( client.arrival_and_departure diff --git a/src/onebusaway/_version.py b/src/onebusaway/_version.py index faf8c10..dbfddcc 100644 --- a/src/onebusaway/_version.py +++ b/src/onebusaway/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "onebusaway" -__version__ = "0.1.0-alpha.7" # x-release-please-version +__version__ = "0.1.0-alpha.8" # x-release-please-version diff --git a/src/onebusaway/resources/__init__.py b/src/onebusaway/resources/__init__.py index 041cf0a..48fb9f8 100644 --- a/src/onebusaway/resources/__init__.py +++ b/src/onebusaway/resources/__init__.py @@ -72,6 +72,14 @@ TripForVehicleResourceWithStreamingResponse, AsyncTripForVehicleResourceWithStreamingResponse, ) +from .schedule_for_stop import ( + ScheduleForStopResource, + AsyncScheduleForStopResource, + ScheduleForStopResourceWithRawResponse, + AsyncScheduleForStopResourceWithRawResponse, + ScheduleForStopResourceWithStreamingResponse, + AsyncScheduleForStopResourceWithStreamingResponse, +) from .stops_for_location import ( StopsForLocationResource, AsyncStopsForLocationResource, @@ -176,6 +184,12 @@ "AsyncStopIDsForAgencyResourceWithRawResponse", "StopIDsForAgencyResourceWithStreamingResponse", "AsyncStopIDsForAgencyResourceWithStreamingResponse", + "ScheduleForStopResource", + "AsyncScheduleForStopResource", + "ScheduleForStopResourceWithRawResponse", + "AsyncScheduleForStopResourceWithRawResponse", + "ScheduleForStopResourceWithStreamingResponse", + "AsyncScheduleForStopResourceWithStreamingResponse", "RouteResource", "AsyncRouteResource", "RouteResourceWithRawResponse", diff --git a/src/onebusaway/resources/schedule_for_stop.py b/src/onebusaway/resources/schedule_for_stop.py new file mode 100644 index 0000000..9b44909 --- /dev/null +++ b/src/onebusaway/resources/schedule_for_stop.py @@ -0,0 +1,167 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union +from datetime import date + +import httpx + +from ..types import schedule_for_stop_retrieve_params +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._utils import ( + maybe_transform, + async_maybe_transform, +) +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .._base_client import make_request_options +from ..types.schedule_for_stop_retrieve_response import ScheduleForStopRetrieveResponse + +__all__ = ["ScheduleForStopResource", "AsyncScheduleForStopResource"] + + +class ScheduleForStopResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ScheduleForStopResourceWithRawResponse: + return ScheduleForStopResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ScheduleForStopResourceWithStreamingResponse: + return ScheduleForStopResourceWithStreamingResponse(self) + + def retrieve( + self, + stop_id: str, + *, + date: Union[str, date] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ScheduleForStopRetrieveResponse: + """ + Get schedule for a specific stop + + Args: + date: The date for which you want to request a schedule in the format YYYY-MM-DD + (optional, defaults to the current date) + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not stop_id: + raise ValueError(f"Expected a non-empty value for `stop_id` but received {stop_id!r}") + return self._get( + f"/api/where/schedule-for-stop/{stop_id}.json", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"date": date}, schedule_for_stop_retrieve_params.ScheduleForStopRetrieveParams), + ), + cast_to=ScheduleForStopRetrieveResponse, + ) + + +class AsyncScheduleForStopResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncScheduleForStopResourceWithRawResponse: + return AsyncScheduleForStopResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncScheduleForStopResourceWithStreamingResponse: + return AsyncScheduleForStopResourceWithStreamingResponse(self) + + async def retrieve( + self, + stop_id: str, + *, + date: Union[str, date] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> ScheduleForStopRetrieveResponse: + """ + Get schedule for a specific stop + + Args: + date: The date for which you want to request a schedule in the format YYYY-MM-DD + (optional, defaults to the current date) + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not stop_id: + raise ValueError(f"Expected a non-empty value for `stop_id` but received {stop_id!r}") + return await self._get( + f"/api/where/schedule-for-stop/{stop_id}.json", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + {"date": date}, schedule_for_stop_retrieve_params.ScheduleForStopRetrieveParams + ), + ), + cast_to=ScheduleForStopRetrieveResponse, + ) + + +class ScheduleForStopResourceWithRawResponse: + def __init__(self, schedule_for_stop: ScheduleForStopResource) -> None: + self._schedule_for_stop = schedule_for_stop + + self.retrieve = to_raw_response_wrapper( + schedule_for_stop.retrieve, + ) + + +class AsyncScheduleForStopResourceWithRawResponse: + def __init__(self, schedule_for_stop: AsyncScheduleForStopResource) -> None: + self._schedule_for_stop = schedule_for_stop + + self.retrieve = async_to_raw_response_wrapper( + schedule_for_stop.retrieve, + ) + + +class ScheduleForStopResourceWithStreamingResponse: + def __init__(self, schedule_for_stop: ScheduleForStopResource) -> None: + self._schedule_for_stop = schedule_for_stop + + self.retrieve = to_streamed_response_wrapper( + schedule_for_stop.retrieve, + ) + + +class AsyncScheduleForStopResourceWithStreamingResponse: + def __init__(self, schedule_for_stop: AsyncScheduleForStopResource) -> None: + self._schedule_for_stop = schedule_for_stop + + self.retrieve = async_to_streamed_response_wrapper( + schedule_for_stop.retrieve, + ) diff --git a/src/onebusaway/types/__init__.py b/src/onebusaway/types/__init__.py index e9da12e..87b7d0c 100644 --- a/src/onebusaway/types/__init__.py +++ b/src/onebusaway/types/__init__.py @@ -16,12 +16,14 @@ from .vehicles_for_agency_list_params import VehiclesForAgencyListParams as VehiclesForAgencyListParams from .trip_for_vehicle_retrieve_params import TripForVehicleRetrieveParams as TripForVehicleRetrieveParams from .arrival_and_departure_list_params import ArrivalAndDepartureListParams as ArrivalAndDepartureListParams +from .schedule_for_stop_retrieve_params import ScheduleForStopRetrieveParams as ScheduleForStopRetrieveParams from .stop_ids_for_agency_list_response import StopIDsForAgencyListResponse as StopIDsForAgencyListResponse from .vehicles_for_agency_list_response import VehiclesForAgencyListResponse as VehiclesForAgencyListResponse from .stops_for_location_retrieve_params import StopsForLocationRetrieveParams as StopsForLocationRetrieveParams from .trip_for_vehicle_retrieve_response import TripForVehicleRetrieveResponse as TripForVehicleRetrieveResponse from .trips_for_location_retrieve_params import TripsForLocationRetrieveParams as TripsForLocationRetrieveParams from .arrival_and_departure_list_response import ArrivalAndDepartureListResponse as ArrivalAndDepartureListResponse +from .schedule_for_stop_retrieve_response import ScheduleForStopRetrieveResponse as ScheduleForStopRetrieveResponse from .stops_for_location_retrieve_response import StopsForLocationRetrieveResponse as StopsForLocationRetrieveResponse from .trips_for_location_retrieve_response import TripsForLocationRetrieveResponse as TripsForLocationRetrieveResponse from .arrival_and_departure_retrieve_params import ( diff --git a/src/onebusaway/types/schedule_for_stop_retrieve_params.py b/src/onebusaway/types/schedule_for_stop_retrieve_params.py new file mode 100644 index 0000000..99b89f7 --- /dev/null +++ b/src/onebusaway/types/schedule_for_stop_retrieve_params.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import datetime +from typing import Union +from typing_extensions import Annotated, TypedDict + +from .._utils import PropertyInfo + +__all__ = ["ScheduleForStopRetrieveParams"] + + +class ScheduleForStopRetrieveParams(TypedDict, total=False): + date: Annotated[Union[str, datetime.date], PropertyInfo(format="iso8601")] + """ + The date for which you want to request a schedule in the format YYYY-MM-DD + (optional, defaults to the current date) + """ diff --git a/src/onebusaway/types/schedule_for_stop_retrieve_response.py b/src/onebusaway/types/schedule_for_stop_retrieve_response.py new file mode 100644 index 0000000..5170464 --- /dev/null +++ b/src/onebusaway/types/schedule_for_stop_retrieve_response.py @@ -0,0 +1,89 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional + +from pydantic import Field as FieldInfo + +from .._models import BaseModel +from .shared.references import References +from .shared.response_wrapper import ResponseWrapper + +__all__ = [ + "ScheduleForStopRetrieveResponse", + "ScheduleForStopRetrieveResponseData", + "ScheduleForStopRetrieveResponseDataEntry", + "ScheduleForStopRetrieveResponseDataEntryStopRouteSchedule", + "ScheduleForStopRetrieveResponseDataEntryStopRouteScheduleStopRouteDirectionSchedule", + "ScheduleForStopRetrieveResponseDataEntryStopRouteScheduleStopRouteDirectionScheduleScheduleStopTime", + "ScheduleForStopRetrieveResponseDataEntryStopRouteScheduleStopRouteDirectionScheduleScheduleFrequency", +] + + +class ScheduleForStopRetrieveResponseDataEntryStopRouteScheduleStopRouteDirectionScheduleScheduleStopTime(BaseModel): + arrival_enabled: bool = FieldInfo(alias="arrivalEnabled") + + arrival_time: int = FieldInfo(alias="arrivalTime") + + departure_enabled: bool = FieldInfo(alias="departureEnabled") + + departure_time: int = FieldInfo(alias="departureTime") + + service_id: str = FieldInfo(alias="serviceId") + + trip_id: str = FieldInfo(alias="tripId") + + stop_headsign: Optional[str] = FieldInfo(alias="stopHeadsign", default=None) + + +class ScheduleForStopRetrieveResponseDataEntryStopRouteScheduleStopRouteDirectionScheduleScheduleFrequency(BaseModel): + end_time: int = FieldInfo(alias="endTime") + + headway: int + + service_date: int = FieldInfo(alias="serviceDate") + + service_id: str = FieldInfo(alias="serviceId") + + start_time: int = FieldInfo(alias="startTime") + + trip_id: str = FieldInfo(alias="tripId") + + +class ScheduleForStopRetrieveResponseDataEntryStopRouteScheduleStopRouteDirectionSchedule(BaseModel): + schedule_stop_times: List[ + ScheduleForStopRetrieveResponseDataEntryStopRouteScheduleStopRouteDirectionScheduleScheduleStopTime + ] = FieldInfo(alias="scheduleStopTimes") + + trip_headsign: str = FieldInfo(alias="tripHeadsign") + + schedule_frequencies: Optional[ + List[ScheduleForStopRetrieveResponseDataEntryStopRouteScheduleStopRouteDirectionScheduleScheduleFrequency] + ] = FieldInfo(alias="scheduleFrequencies", default=None) + + +class ScheduleForStopRetrieveResponseDataEntryStopRouteSchedule(BaseModel): + route_id: str = FieldInfo(alias="routeId") + + stop_route_direction_schedules: List[ + ScheduleForStopRetrieveResponseDataEntryStopRouteScheduleStopRouteDirectionSchedule + ] = FieldInfo(alias="stopRouteDirectionSchedules") + + +class ScheduleForStopRetrieveResponseDataEntry(BaseModel): + date: int + + stop_id: str = FieldInfo(alias="stopId") + + stop_route_schedules: List[ScheduleForStopRetrieveResponseDataEntryStopRouteSchedule] = FieldInfo( + alias="stopRouteSchedules" + ) + + +class ScheduleForStopRetrieveResponseData(BaseModel): + entry: ScheduleForStopRetrieveResponseDataEntry + + references: References + + +class ScheduleForStopRetrieveResponse(ResponseWrapper): + data: Optional[ScheduleForStopRetrieveResponseData] = None diff --git a/tests/api_resources/test_schedule_for_stop.py b/tests/api_resources/test_schedule_for_stop.py new file mode 100644 index 0000000..0154e44 --- /dev/null +++ b/tests/api_resources/test_schedule_for_stop.py @@ -0,0 +1,115 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from onebusaway import OnebusawaySDK, AsyncOnebusawaySDK +from tests.utils import assert_matches_type +from onebusaway.types import ScheduleForStopRetrieveResponse +from onebusaway._utils import parse_date + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestScheduleForStop: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_retrieve(self, client: OnebusawaySDK) -> None: + schedule_for_stop = client.schedule_for_stop.retrieve( + stop_id="stopID", + ) + assert_matches_type(ScheduleForStopRetrieveResponse, schedule_for_stop, path=["response"]) + + @parametrize + def test_method_retrieve_with_all_params(self, client: OnebusawaySDK) -> None: + schedule_for_stop = client.schedule_for_stop.retrieve( + stop_id="stopID", + date=parse_date("2019-12-27"), + ) + assert_matches_type(ScheduleForStopRetrieveResponse, schedule_for_stop, path=["response"]) + + @parametrize + def test_raw_response_retrieve(self, client: OnebusawaySDK) -> None: + response = client.schedule_for_stop.with_raw_response.retrieve( + stop_id="stopID", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schedule_for_stop = response.parse() + assert_matches_type(ScheduleForStopRetrieveResponse, schedule_for_stop, path=["response"]) + + @parametrize + def test_streaming_response_retrieve(self, client: OnebusawaySDK) -> None: + with client.schedule_for_stop.with_streaming_response.retrieve( + stop_id="stopID", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schedule_for_stop = response.parse() + assert_matches_type(ScheduleForStopRetrieveResponse, schedule_for_stop, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_retrieve(self, client: OnebusawaySDK) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `stop_id` but received ''"): + client.schedule_for_stop.with_raw_response.retrieve( + stop_id="", + ) + + +class TestAsyncScheduleForStop: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_retrieve(self, async_client: AsyncOnebusawaySDK) -> None: + schedule_for_stop = await async_client.schedule_for_stop.retrieve( + stop_id="stopID", + ) + assert_matches_type(ScheduleForStopRetrieveResponse, schedule_for_stop, path=["response"]) + + @parametrize + async def test_method_retrieve_with_all_params(self, async_client: AsyncOnebusawaySDK) -> None: + schedule_for_stop = await async_client.schedule_for_stop.retrieve( + stop_id="stopID", + date=parse_date("2019-12-27"), + ) + assert_matches_type(ScheduleForStopRetrieveResponse, schedule_for_stop, path=["response"]) + + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncOnebusawaySDK) -> None: + response = await async_client.schedule_for_stop.with_raw_response.retrieve( + stop_id="stopID", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + schedule_for_stop = await response.parse() + assert_matches_type(ScheduleForStopRetrieveResponse, schedule_for_stop, path=["response"]) + + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncOnebusawaySDK) -> None: + async with async_client.schedule_for_stop.with_streaming_response.retrieve( + stop_id="stopID", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + schedule_for_stop = await response.parse() + assert_matches_type(ScheduleForStopRetrieveResponse, schedule_for_stop, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncOnebusawaySDK) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `stop_id` but received ''"): + await async_client.schedule_for_stop.with_raw_response.retrieve( + stop_id="", + )