|
| 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +from typing_extensions import Literal |
| 6 | + |
| 7 | +import httpx |
| 8 | + |
| 9 | +from ..types import report_problem_with_trip_retrieve_params |
| 10 | +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 11 | +from .._utils import ( |
| 12 | + maybe_transform, |
| 13 | + async_maybe_transform, |
| 14 | +) |
| 15 | +from .._compat import cached_property |
| 16 | +from .._resource import SyncAPIResource, AsyncAPIResource |
| 17 | +from .._response import ( |
| 18 | + to_raw_response_wrapper, |
| 19 | + to_streamed_response_wrapper, |
| 20 | + async_to_raw_response_wrapper, |
| 21 | + async_to_streamed_response_wrapper, |
| 22 | +) |
| 23 | +from .._base_client import make_request_options |
| 24 | +from ..types.shared.response_wrapper import ResponseWrapper |
| 25 | + |
| 26 | +__all__ = ["ReportProblemWithTripResource", "AsyncReportProblemWithTripResource"] |
| 27 | + |
| 28 | + |
| 29 | +class ReportProblemWithTripResource(SyncAPIResource): |
| 30 | + @cached_property |
| 31 | + def with_raw_response(self) -> ReportProblemWithTripResourceWithRawResponse: |
| 32 | + return ReportProblemWithTripResourceWithRawResponse(self) |
| 33 | + |
| 34 | + @cached_property |
| 35 | + def with_streaming_response(self) -> ReportProblemWithTripResourceWithStreamingResponse: |
| 36 | + return ReportProblemWithTripResourceWithStreamingResponse(self) |
| 37 | + |
| 38 | + def retrieve( |
| 39 | + self, |
| 40 | + trip_id: str, |
| 41 | + *, |
| 42 | + code: Literal[ |
| 43 | + "vehicle_never_came", |
| 44 | + "vehicle_came_early", |
| 45 | + "vehicle_came_late", |
| 46 | + "wrong_headsign", |
| 47 | + "vehicle_does_not_stop_here", |
| 48 | + "other", |
| 49 | + ] |
| 50 | + | NotGiven = NOT_GIVEN, |
| 51 | + service_date: int | NotGiven = NOT_GIVEN, |
| 52 | + stop_id: str | NotGiven = NOT_GIVEN, |
| 53 | + user_comment: str | NotGiven = NOT_GIVEN, |
| 54 | + user_lat: float | NotGiven = NOT_GIVEN, |
| 55 | + user_location_accuracy: float | NotGiven = NOT_GIVEN, |
| 56 | + user_lon: float | NotGiven = NOT_GIVEN, |
| 57 | + user_on_vehicle: bool | NotGiven = NOT_GIVEN, |
| 58 | + user_vehicle_number: str | NotGiven = NOT_GIVEN, |
| 59 | + vehicle_id: str | NotGiven = NOT_GIVEN, |
| 60 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 61 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 62 | + extra_headers: Headers | None = None, |
| 63 | + extra_query: Query | None = None, |
| 64 | + extra_body: Body | None = None, |
| 65 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 66 | + ) -> ResponseWrapper: |
| 67 | + """ |
| 68 | + Submit a user-generated problem report for a particular trip. |
| 69 | +
|
| 70 | + Args: |
| 71 | + code: A string code identifying the nature of the problem |
| 72 | +
|
| 73 | + service_date: The service date of the trip |
| 74 | +
|
| 75 | + stop_id: A stop ID indicating where the user is experiencing the problem |
| 76 | +
|
| 77 | + user_comment: Additional comment text supplied by the user describing the problem |
| 78 | +
|
| 79 | + user_lat: The reporting user’s current latitude |
| 80 | +
|
| 81 | + user_location_accuracy: The reporting user’s location accuracy, in meters |
| 82 | +
|
| 83 | + user_lon: The reporting user’s current longitude |
| 84 | +
|
| 85 | + user_on_vehicle: Indicator if the user is on the transit vehicle experiencing the problem |
| 86 | +
|
| 87 | + user_vehicle_number: The vehicle number, as reported by the user |
| 88 | +
|
| 89 | + vehicle_id: The vehicle actively serving the trip |
| 90 | +
|
| 91 | + extra_headers: Send extra headers |
| 92 | +
|
| 93 | + extra_query: Add additional query parameters to the request |
| 94 | +
|
| 95 | + extra_body: Add additional JSON properties to the request |
| 96 | +
|
| 97 | + timeout: Override the client-level default timeout for this request, in seconds |
| 98 | + """ |
| 99 | + if not trip_id: |
| 100 | + raise ValueError(f"Expected a non-empty value for `trip_id` but received {trip_id!r}") |
| 101 | + return self._get( |
| 102 | + f"/api/where/report-problem-with-trip/{trip_id}.json", |
| 103 | + options=make_request_options( |
| 104 | + extra_headers=extra_headers, |
| 105 | + extra_query=extra_query, |
| 106 | + extra_body=extra_body, |
| 107 | + timeout=timeout, |
| 108 | + query=maybe_transform( |
| 109 | + { |
| 110 | + "code": code, |
| 111 | + "service_date": service_date, |
| 112 | + "stop_id": stop_id, |
| 113 | + "user_comment": user_comment, |
| 114 | + "user_lat": user_lat, |
| 115 | + "user_location_accuracy": user_location_accuracy, |
| 116 | + "user_lon": user_lon, |
| 117 | + "user_on_vehicle": user_on_vehicle, |
| 118 | + "user_vehicle_number": user_vehicle_number, |
| 119 | + "vehicle_id": vehicle_id, |
| 120 | + }, |
| 121 | + report_problem_with_trip_retrieve_params.ReportProblemWithTripRetrieveParams, |
| 122 | + ), |
| 123 | + ), |
| 124 | + cast_to=ResponseWrapper, |
| 125 | + ) |
| 126 | + |
| 127 | + |
| 128 | +class AsyncReportProblemWithTripResource(AsyncAPIResource): |
| 129 | + @cached_property |
| 130 | + def with_raw_response(self) -> AsyncReportProblemWithTripResourceWithRawResponse: |
| 131 | + return AsyncReportProblemWithTripResourceWithRawResponse(self) |
| 132 | + |
| 133 | + @cached_property |
| 134 | + def with_streaming_response(self) -> AsyncReportProblemWithTripResourceWithStreamingResponse: |
| 135 | + return AsyncReportProblemWithTripResourceWithStreamingResponse(self) |
| 136 | + |
| 137 | + async def retrieve( |
| 138 | + self, |
| 139 | + trip_id: str, |
| 140 | + *, |
| 141 | + code: Literal[ |
| 142 | + "vehicle_never_came", |
| 143 | + "vehicle_came_early", |
| 144 | + "vehicle_came_late", |
| 145 | + "wrong_headsign", |
| 146 | + "vehicle_does_not_stop_here", |
| 147 | + "other", |
| 148 | + ] |
| 149 | + | NotGiven = NOT_GIVEN, |
| 150 | + service_date: int | NotGiven = NOT_GIVEN, |
| 151 | + stop_id: str | NotGiven = NOT_GIVEN, |
| 152 | + user_comment: str | NotGiven = NOT_GIVEN, |
| 153 | + user_lat: float | NotGiven = NOT_GIVEN, |
| 154 | + user_location_accuracy: float | NotGiven = NOT_GIVEN, |
| 155 | + user_lon: float | NotGiven = NOT_GIVEN, |
| 156 | + user_on_vehicle: bool | NotGiven = NOT_GIVEN, |
| 157 | + user_vehicle_number: str | NotGiven = NOT_GIVEN, |
| 158 | + vehicle_id: str | NotGiven = NOT_GIVEN, |
| 159 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 160 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 161 | + extra_headers: Headers | None = None, |
| 162 | + extra_query: Query | None = None, |
| 163 | + extra_body: Body | None = None, |
| 164 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 165 | + ) -> ResponseWrapper: |
| 166 | + """ |
| 167 | + Submit a user-generated problem report for a particular trip. |
| 168 | +
|
| 169 | + Args: |
| 170 | + code: A string code identifying the nature of the problem |
| 171 | +
|
| 172 | + service_date: The service date of the trip |
| 173 | +
|
| 174 | + stop_id: A stop ID indicating where the user is experiencing the problem |
| 175 | +
|
| 176 | + user_comment: Additional comment text supplied by the user describing the problem |
| 177 | +
|
| 178 | + user_lat: The reporting user’s current latitude |
| 179 | +
|
| 180 | + user_location_accuracy: The reporting user’s location accuracy, in meters |
| 181 | +
|
| 182 | + user_lon: The reporting user’s current longitude |
| 183 | +
|
| 184 | + user_on_vehicle: Indicator if the user is on the transit vehicle experiencing the problem |
| 185 | +
|
| 186 | + user_vehicle_number: The vehicle number, as reported by the user |
| 187 | +
|
| 188 | + vehicle_id: The vehicle actively serving the trip |
| 189 | +
|
| 190 | + extra_headers: Send extra headers |
| 191 | +
|
| 192 | + extra_query: Add additional query parameters to the request |
| 193 | +
|
| 194 | + extra_body: Add additional JSON properties to the request |
| 195 | +
|
| 196 | + timeout: Override the client-level default timeout for this request, in seconds |
| 197 | + """ |
| 198 | + if not trip_id: |
| 199 | + raise ValueError(f"Expected a non-empty value for `trip_id` but received {trip_id!r}") |
| 200 | + return await self._get( |
| 201 | + f"/api/where/report-problem-with-trip/{trip_id}.json", |
| 202 | + options=make_request_options( |
| 203 | + extra_headers=extra_headers, |
| 204 | + extra_query=extra_query, |
| 205 | + extra_body=extra_body, |
| 206 | + timeout=timeout, |
| 207 | + query=await async_maybe_transform( |
| 208 | + { |
| 209 | + "code": code, |
| 210 | + "service_date": service_date, |
| 211 | + "stop_id": stop_id, |
| 212 | + "user_comment": user_comment, |
| 213 | + "user_lat": user_lat, |
| 214 | + "user_location_accuracy": user_location_accuracy, |
| 215 | + "user_lon": user_lon, |
| 216 | + "user_on_vehicle": user_on_vehicle, |
| 217 | + "user_vehicle_number": user_vehicle_number, |
| 218 | + "vehicle_id": vehicle_id, |
| 219 | + }, |
| 220 | + report_problem_with_trip_retrieve_params.ReportProblemWithTripRetrieveParams, |
| 221 | + ), |
| 222 | + ), |
| 223 | + cast_to=ResponseWrapper, |
| 224 | + ) |
| 225 | + |
| 226 | + |
| 227 | +class ReportProblemWithTripResourceWithRawResponse: |
| 228 | + def __init__(self, report_problem_with_trip: ReportProblemWithTripResource) -> None: |
| 229 | + self._report_problem_with_trip = report_problem_with_trip |
| 230 | + |
| 231 | + self.retrieve = to_raw_response_wrapper( |
| 232 | + report_problem_with_trip.retrieve, |
| 233 | + ) |
| 234 | + |
| 235 | + |
| 236 | +class AsyncReportProblemWithTripResourceWithRawResponse: |
| 237 | + def __init__(self, report_problem_with_trip: AsyncReportProblemWithTripResource) -> None: |
| 238 | + self._report_problem_with_trip = report_problem_with_trip |
| 239 | + |
| 240 | + self.retrieve = async_to_raw_response_wrapper( |
| 241 | + report_problem_with_trip.retrieve, |
| 242 | + ) |
| 243 | + |
| 244 | + |
| 245 | +class ReportProblemWithTripResourceWithStreamingResponse: |
| 246 | + def __init__(self, report_problem_with_trip: ReportProblemWithTripResource) -> None: |
| 247 | + self._report_problem_with_trip = report_problem_with_trip |
| 248 | + |
| 249 | + self.retrieve = to_streamed_response_wrapper( |
| 250 | + report_problem_with_trip.retrieve, |
| 251 | + ) |
| 252 | + |
| 253 | + |
| 254 | +class AsyncReportProblemWithTripResourceWithStreamingResponse: |
| 255 | + def __init__(self, report_problem_with_trip: AsyncReportProblemWithTripResource) -> None: |
| 256 | + self._report_problem_with_trip = report_problem_with_trip |
| 257 | + |
| 258 | + self.retrieve = async_to_streamed_response_wrapper( |
| 259 | + report_problem_with_trip.retrieve, |
| 260 | + ) |
0 commit comments