|
| 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +import httpx |
| 6 | + |
| 7 | +from ..types import trip_for_vehicle_retrieve_params |
| 8 | +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 9 | +from .._utils import ( |
| 10 | + maybe_transform, |
| 11 | + async_maybe_transform, |
| 12 | +) |
| 13 | +from .._compat import cached_property |
| 14 | +from .._resource import SyncAPIResource, AsyncAPIResource |
| 15 | +from .._response import ( |
| 16 | + to_raw_response_wrapper, |
| 17 | + to_streamed_response_wrapper, |
| 18 | + async_to_raw_response_wrapper, |
| 19 | + async_to_streamed_response_wrapper, |
| 20 | +) |
| 21 | +from .._base_client import make_request_options |
| 22 | +from ..types.trip_for_vehicle_retrieve_response import TripForVehicleRetrieveResponse |
| 23 | + |
| 24 | +__all__ = ["TripForVehicleResource", "AsyncTripForVehicleResource"] |
| 25 | + |
| 26 | + |
| 27 | +class TripForVehicleResource(SyncAPIResource): |
| 28 | + @cached_property |
| 29 | + def with_raw_response(self) -> TripForVehicleResourceWithRawResponse: |
| 30 | + return TripForVehicleResourceWithRawResponse(self) |
| 31 | + |
| 32 | + @cached_property |
| 33 | + def with_streaming_response(self) -> TripForVehicleResourceWithStreamingResponse: |
| 34 | + return TripForVehicleResourceWithStreamingResponse(self) |
| 35 | + |
| 36 | + def retrieve( |
| 37 | + self, |
| 38 | + vehicle_id: str, |
| 39 | + *, |
| 40 | + include_schedule: bool | NotGiven = NOT_GIVEN, |
| 41 | + include_status: bool | NotGiven = NOT_GIVEN, |
| 42 | + include_trip: bool | NotGiven = NOT_GIVEN, |
| 43 | + time: int | 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 | + ) -> TripForVehicleRetrieveResponse: |
| 51 | + """ |
| 52 | + Retrieve trip for a specific vehicle |
| 53 | +
|
| 54 | + Args: |
| 55 | + include_schedule: Determines whether full <schedule/> element is included in the <tripDetails/> |
| 56 | + section. Defaults to false. |
| 57 | +
|
| 58 | + include_status: Determines whether the full <status/> element is included in the <tripDetails/> |
| 59 | + section. Defaults to true. |
| 60 | +
|
| 61 | + include_trip: Determines whether full <trip/> element is included in the <references/> |
| 62 | + section. Defaults to false. |
| 63 | +
|
| 64 | + time: Time parameter to query the system at a specific time (optional). |
| 65 | +
|
| 66 | + extra_headers: Send extra headers |
| 67 | +
|
| 68 | + extra_query: Add additional query parameters to the request |
| 69 | +
|
| 70 | + extra_body: Add additional JSON properties to the request |
| 71 | +
|
| 72 | + timeout: Override the client-level default timeout for this request, in seconds |
| 73 | + """ |
| 74 | + if not vehicle_id: |
| 75 | + raise ValueError(f"Expected a non-empty value for `vehicle_id` but received {vehicle_id!r}") |
| 76 | + return self._get( |
| 77 | + f"/api/where/trip-for-vehicle/vehicleID.json", |
| 78 | + options=make_request_options( |
| 79 | + extra_headers=extra_headers, |
| 80 | + extra_query=extra_query, |
| 81 | + extra_body=extra_body, |
| 82 | + timeout=timeout, |
| 83 | + query=maybe_transform( |
| 84 | + { |
| 85 | + "include_schedule": include_schedule, |
| 86 | + "include_status": include_status, |
| 87 | + "include_trip": include_trip, |
| 88 | + "time": time, |
| 89 | + }, |
| 90 | + trip_for_vehicle_retrieve_params.TripForVehicleRetrieveParams, |
| 91 | + ), |
| 92 | + ), |
| 93 | + cast_to=TripForVehicleRetrieveResponse, |
| 94 | + ) |
| 95 | + |
| 96 | + |
| 97 | +class AsyncTripForVehicleResource(AsyncAPIResource): |
| 98 | + @cached_property |
| 99 | + def with_raw_response(self) -> AsyncTripForVehicleResourceWithRawResponse: |
| 100 | + return AsyncTripForVehicleResourceWithRawResponse(self) |
| 101 | + |
| 102 | + @cached_property |
| 103 | + def with_streaming_response(self) -> AsyncTripForVehicleResourceWithStreamingResponse: |
| 104 | + return AsyncTripForVehicleResourceWithStreamingResponse(self) |
| 105 | + |
| 106 | + async def retrieve( |
| 107 | + self, |
| 108 | + vehicle_id: str, |
| 109 | + *, |
| 110 | + include_schedule: bool | NotGiven = NOT_GIVEN, |
| 111 | + include_status: bool | NotGiven = NOT_GIVEN, |
| 112 | + include_trip: bool | NotGiven = NOT_GIVEN, |
| 113 | + time: int | NotGiven = NOT_GIVEN, |
| 114 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 115 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 116 | + extra_headers: Headers | None = None, |
| 117 | + extra_query: Query | None = None, |
| 118 | + extra_body: Body | None = None, |
| 119 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 120 | + ) -> TripForVehicleRetrieveResponse: |
| 121 | + """ |
| 122 | + Retrieve trip for a specific vehicle |
| 123 | +
|
| 124 | + Args: |
| 125 | + include_schedule: Determines whether full <schedule/> element is included in the <tripDetails/> |
| 126 | + section. Defaults to false. |
| 127 | +
|
| 128 | + include_status: Determines whether the full <status/> element is included in the <tripDetails/> |
| 129 | + section. Defaults to true. |
| 130 | +
|
| 131 | + include_trip: Determines whether full <trip/> element is included in the <references/> |
| 132 | + section. Defaults to false. |
| 133 | +
|
| 134 | + time: Time parameter to query the system at a specific time (optional). |
| 135 | +
|
| 136 | + extra_headers: Send extra headers |
| 137 | +
|
| 138 | + extra_query: Add additional query parameters to the request |
| 139 | +
|
| 140 | + extra_body: Add additional JSON properties to the request |
| 141 | +
|
| 142 | + timeout: Override the client-level default timeout for this request, in seconds |
| 143 | + """ |
| 144 | + if not vehicle_id: |
| 145 | + raise ValueError(f"Expected a non-empty value for `vehicle_id` but received {vehicle_id!r}") |
| 146 | + return await self._get( |
| 147 | + f"/api/where/trip-for-vehicle/vehicleID.json", |
| 148 | + options=make_request_options( |
| 149 | + extra_headers=extra_headers, |
| 150 | + extra_query=extra_query, |
| 151 | + extra_body=extra_body, |
| 152 | + timeout=timeout, |
| 153 | + query=await async_maybe_transform( |
| 154 | + { |
| 155 | + "include_schedule": include_schedule, |
| 156 | + "include_status": include_status, |
| 157 | + "include_trip": include_trip, |
| 158 | + "time": time, |
| 159 | + }, |
| 160 | + trip_for_vehicle_retrieve_params.TripForVehicleRetrieveParams, |
| 161 | + ), |
| 162 | + ), |
| 163 | + cast_to=TripForVehicleRetrieveResponse, |
| 164 | + ) |
| 165 | + |
| 166 | + |
| 167 | +class TripForVehicleResourceWithRawResponse: |
| 168 | + def __init__(self, trip_for_vehicle: TripForVehicleResource) -> None: |
| 169 | + self._trip_for_vehicle = trip_for_vehicle |
| 170 | + |
| 171 | + self.retrieve = to_raw_response_wrapper( |
| 172 | + trip_for_vehicle.retrieve, |
| 173 | + ) |
| 174 | + |
| 175 | + |
| 176 | +class AsyncTripForVehicleResourceWithRawResponse: |
| 177 | + def __init__(self, trip_for_vehicle: AsyncTripForVehicleResource) -> None: |
| 178 | + self._trip_for_vehicle = trip_for_vehicle |
| 179 | + |
| 180 | + self.retrieve = async_to_raw_response_wrapper( |
| 181 | + trip_for_vehicle.retrieve, |
| 182 | + ) |
| 183 | + |
| 184 | + |
| 185 | +class TripForVehicleResourceWithStreamingResponse: |
| 186 | + def __init__(self, trip_for_vehicle: TripForVehicleResource) -> None: |
| 187 | + self._trip_for_vehicle = trip_for_vehicle |
| 188 | + |
| 189 | + self.retrieve = to_streamed_response_wrapper( |
| 190 | + trip_for_vehicle.retrieve, |
| 191 | + ) |
| 192 | + |
| 193 | + |
| 194 | +class AsyncTripForVehicleResourceWithStreamingResponse: |
| 195 | + def __init__(self, trip_for_vehicle: AsyncTripForVehicleResource) -> None: |
| 196 | + self._trip_for_vehicle = trip_for_vehicle |
| 197 | + |
| 198 | + self.retrieve = async_to_streamed_response_wrapper( |
| 199 | + trip_for_vehicle.retrieve, |
| 200 | + ) |
0 commit comments