|
| 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +from typing import Union |
| 6 | +from datetime import date |
| 7 | + |
| 8 | +import httpx |
| 9 | + |
| 10 | +from ..types import schedule_for_stop_retrieve_params |
| 11 | +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 12 | +from .._utils import ( |
| 13 | + maybe_transform, |
| 14 | + async_maybe_transform, |
| 15 | +) |
| 16 | +from .._compat import cached_property |
| 17 | +from .._resource import SyncAPIResource, AsyncAPIResource |
| 18 | +from .._response import ( |
| 19 | + to_raw_response_wrapper, |
| 20 | + to_streamed_response_wrapper, |
| 21 | + async_to_raw_response_wrapper, |
| 22 | + async_to_streamed_response_wrapper, |
| 23 | +) |
| 24 | +from .._base_client import make_request_options |
| 25 | +from ..types.schedule_for_stop_retrieve_response import ScheduleForStopRetrieveResponse |
| 26 | + |
| 27 | +__all__ = ["ScheduleForStopResource", "AsyncScheduleForStopResource"] |
| 28 | + |
| 29 | + |
| 30 | +class ScheduleForStopResource(SyncAPIResource): |
| 31 | + @cached_property |
| 32 | + def with_raw_response(self) -> ScheduleForStopResourceWithRawResponse: |
| 33 | + return ScheduleForStopResourceWithRawResponse(self) |
| 34 | + |
| 35 | + @cached_property |
| 36 | + def with_streaming_response(self) -> ScheduleForStopResourceWithStreamingResponse: |
| 37 | + return ScheduleForStopResourceWithStreamingResponse(self) |
| 38 | + |
| 39 | + def retrieve( |
| 40 | + self, |
| 41 | + stop_id: str, |
| 42 | + *, |
| 43 | + date: Union[str, date] | NotGiven = NOT_GIVEN, |
| 44 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 45 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 46 | + extra_headers: Headers | None = None, |
| 47 | + extra_query: Query | None = None, |
| 48 | + extra_body: Body | None = None, |
| 49 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 50 | + ) -> ScheduleForStopRetrieveResponse: |
| 51 | + """ |
| 52 | + Get schedule for a specific stop |
| 53 | +
|
| 54 | + Args: |
| 55 | + date: The date for which you want to request a schedule in the format YYYY-MM-DD |
| 56 | + (optional, defaults to the current date) |
| 57 | +
|
| 58 | + extra_headers: Send extra headers |
| 59 | +
|
| 60 | + extra_query: Add additional query parameters to the request |
| 61 | +
|
| 62 | + extra_body: Add additional JSON properties to the request |
| 63 | +
|
| 64 | + timeout: Override the client-level default timeout for this request, in seconds |
| 65 | + """ |
| 66 | + if not stop_id: |
| 67 | + raise ValueError(f"Expected a non-empty value for `stop_id` but received {stop_id!r}") |
| 68 | + return self._get( |
| 69 | + f"/api/where/schedule-for-stop/{stop_id}.json", |
| 70 | + options=make_request_options( |
| 71 | + extra_headers=extra_headers, |
| 72 | + extra_query=extra_query, |
| 73 | + extra_body=extra_body, |
| 74 | + timeout=timeout, |
| 75 | + query=maybe_transform({"date": date}, schedule_for_stop_retrieve_params.ScheduleForStopRetrieveParams), |
| 76 | + ), |
| 77 | + cast_to=ScheduleForStopRetrieveResponse, |
| 78 | + ) |
| 79 | + |
| 80 | + |
| 81 | +class AsyncScheduleForStopResource(AsyncAPIResource): |
| 82 | + @cached_property |
| 83 | + def with_raw_response(self) -> AsyncScheduleForStopResourceWithRawResponse: |
| 84 | + return AsyncScheduleForStopResourceWithRawResponse(self) |
| 85 | + |
| 86 | + @cached_property |
| 87 | + def with_streaming_response(self) -> AsyncScheduleForStopResourceWithStreamingResponse: |
| 88 | + return AsyncScheduleForStopResourceWithStreamingResponse(self) |
| 89 | + |
| 90 | + async def retrieve( |
| 91 | + self, |
| 92 | + stop_id: str, |
| 93 | + *, |
| 94 | + date: Union[str, date] | NotGiven = NOT_GIVEN, |
| 95 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 96 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 97 | + extra_headers: Headers | None = None, |
| 98 | + extra_query: Query | None = None, |
| 99 | + extra_body: Body | None = None, |
| 100 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 101 | + ) -> ScheduleForStopRetrieveResponse: |
| 102 | + """ |
| 103 | + Get schedule for a specific stop |
| 104 | +
|
| 105 | + Args: |
| 106 | + date: The date for which you want to request a schedule in the format YYYY-MM-DD |
| 107 | + (optional, defaults to the current date) |
| 108 | +
|
| 109 | + extra_headers: Send extra headers |
| 110 | +
|
| 111 | + extra_query: Add additional query parameters to the request |
| 112 | +
|
| 113 | + extra_body: Add additional JSON properties to the request |
| 114 | +
|
| 115 | + timeout: Override the client-level default timeout for this request, in seconds |
| 116 | + """ |
| 117 | + if not stop_id: |
| 118 | + raise ValueError(f"Expected a non-empty value for `stop_id` but received {stop_id!r}") |
| 119 | + return await self._get( |
| 120 | + f"/api/where/schedule-for-stop/{stop_id}.json", |
| 121 | + options=make_request_options( |
| 122 | + extra_headers=extra_headers, |
| 123 | + extra_query=extra_query, |
| 124 | + extra_body=extra_body, |
| 125 | + timeout=timeout, |
| 126 | + query=await async_maybe_transform( |
| 127 | + {"date": date}, schedule_for_stop_retrieve_params.ScheduleForStopRetrieveParams |
| 128 | + ), |
| 129 | + ), |
| 130 | + cast_to=ScheduleForStopRetrieveResponse, |
| 131 | + ) |
| 132 | + |
| 133 | + |
| 134 | +class ScheduleForStopResourceWithRawResponse: |
| 135 | + def __init__(self, schedule_for_stop: ScheduleForStopResource) -> None: |
| 136 | + self._schedule_for_stop = schedule_for_stop |
| 137 | + |
| 138 | + self.retrieve = to_raw_response_wrapper( |
| 139 | + schedule_for_stop.retrieve, |
| 140 | + ) |
| 141 | + |
| 142 | + |
| 143 | +class AsyncScheduleForStopResourceWithRawResponse: |
| 144 | + def __init__(self, schedule_for_stop: AsyncScheduleForStopResource) -> None: |
| 145 | + self._schedule_for_stop = schedule_for_stop |
| 146 | + |
| 147 | + self.retrieve = async_to_raw_response_wrapper( |
| 148 | + schedule_for_stop.retrieve, |
| 149 | + ) |
| 150 | + |
| 151 | + |
| 152 | +class ScheduleForStopResourceWithStreamingResponse: |
| 153 | + def __init__(self, schedule_for_stop: ScheduleForStopResource) -> None: |
| 154 | + self._schedule_for_stop = schedule_for_stop |
| 155 | + |
| 156 | + self.retrieve = to_streamed_response_wrapper( |
| 157 | + schedule_for_stop.retrieve, |
| 158 | + ) |
| 159 | + |
| 160 | + |
| 161 | +class AsyncScheduleForStopResourceWithStreamingResponse: |
| 162 | + def __init__(self, schedule_for_stop: AsyncScheduleForStopResource) -> None: |
| 163 | + self._schedule_for_stop = schedule_for_stop |
| 164 | + |
| 165 | + self.retrieve = async_to_streamed_response_wrapper( |
| 166 | + schedule_for_stop.retrieve, |
| 167 | + ) |
0 commit comments