|
| 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_stop_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__ = ["ReportProblemWithStopResource", "AsyncReportProblemWithStopResource"] |
| 27 | + |
| 28 | + |
| 29 | +class ReportProblemWithStopResource(SyncAPIResource): |
| 30 | + @cached_property |
| 31 | + def with_raw_response(self) -> ReportProblemWithStopResourceWithRawResponse: |
| 32 | + return ReportProblemWithStopResourceWithRawResponse(self) |
| 33 | + |
| 34 | + @cached_property |
| 35 | + def with_streaming_response(self) -> ReportProblemWithStopResourceWithStreamingResponse: |
| 36 | + return ReportProblemWithStopResourceWithStreamingResponse(self) |
| 37 | + |
| 38 | + def retrieve( |
| 39 | + self, |
| 40 | + stop_id: str, |
| 41 | + *, |
| 42 | + code: Literal["stop_name_wrong", "stop_number_wrong", "stop_location_wrong", "route_or_trip_missing", "other"] |
| 43 | + | NotGiven = NOT_GIVEN, |
| 44 | + user_comment: str | NotGiven = NOT_GIVEN, |
| 45 | + user_lat: float | NotGiven = NOT_GIVEN, |
| 46 | + user_location_accuracy: float | NotGiven = NOT_GIVEN, |
| 47 | + user_lon: float | NotGiven = NOT_GIVEN, |
| 48 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 49 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 50 | + extra_headers: Headers | None = None, |
| 51 | + extra_query: Query | None = None, |
| 52 | + extra_body: Body | None = None, |
| 53 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 54 | + ) -> ResponseWrapper: |
| 55 | + """ |
| 56 | + Submit a user-generated problem report for a stop |
| 57 | +
|
| 58 | + Args: |
| 59 | + code: A string code identifying the nature of the problem |
| 60 | +
|
| 61 | + user_comment: Additional comment text supplied by the user describing the problem |
| 62 | +
|
| 63 | + user_lat: The reporting user’s current latitude |
| 64 | +
|
| 65 | + user_location_accuracy: The reporting user’s location accuracy, in meters |
| 66 | +
|
| 67 | + user_lon: The reporting user’s current longitude |
| 68 | +
|
| 69 | + extra_headers: Send extra headers |
| 70 | +
|
| 71 | + extra_query: Add additional query parameters to the request |
| 72 | +
|
| 73 | + extra_body: Add additional JSON properties to the request |
| 74 | +
|
| 75 | + timeout: Override the client-level default timeout for this request, in seconds |
| 76 | + """ |
| 77 | + if not stop_id: |
| 78 | + raise ValueError(f"Expected a non-empty value for `stop_id` but received {stop_id!r}") |
| 79 | + return self._get( |
| 80 | + f"/api/where/report-problem-with-stop/{stop_id}.json", |
| 81 | + options=make_request_options( |
| 82 | + extra_headers=extra_headers, |
| 83 | + extra_query=extra_query, |
| 84 | + extra_body=extra_body, |
| 85 | + timeout=timeout, |
| 86 | + query=maybe_transform( |
| 87 | + { |
| 88 | + "code": code, |
| 89 | + "user_comment": user_comment, |
| 90 | + "user_lat": user_lat, |
| 91 | + "user_location_accuracy": user_location_accuracy, |
| 92 | + "user_lon": user_lon, |
| 93 | + }, |
| 94 | + report_problem_with_stop_retrieve_params.ReportProblemWithStopRetrieveParams, |
| 95 | + ), |
| 96 | + ), |
| 97 | + cast_to=ResponseWrapper, |
| 98 | + ) |
| 99 | + |
| 100 | + |
| 101 | +class AsyncReportProblemWithStopResource(AsyncAPIResource): |
| 102 | + @cached_property |
| 103 | + def with_raw_response(self) -> AsyncReportProblemWithStopResourceWithRawResponse: |
| 104 | + return AsyncReportProblemWithStopResourceWithRawResponse(self) |
| 105 | + |
| 106 | + @cached_property |
| 107 | + def with_streaming_response(self) -> AsyncReportProblemWithStopResourceWithStreamingResponse: |
| 108 | + return AsyncReportProblemWithStopResourceWithStreamingResponse(self) |
| 109 | + |
| 110 | + async def retrieve( |
| 111 | + self, |
| 112 | + stop_id: str, |
| 113 | + *, |
| 114 | + code: Literal["stop_name_wrong", "stop_number_wrong", "stop_location_wrong", "route_or_trip_missing", "other"] |
| 115 | + | NotGiven = NOT_GIVEN, |
| 116 | + user_comment: str | NotGiven = NOT_GIVEN, |
| 117 | + user_lat: float | NotGiven = NOT_GIVEN, |
| 118 | + user_location_accuracy: float | NotGiven = NOT_GIVEN, |
| 119 | + user_lon: float | NotGiven = NOT_GIVEN, |
| 120 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 121 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 122 | + extra_headers: Headers | None = None, |
| 123 | + extra_query: Query | None = None, |
| 124 | + extra_body: Body | None = None, |
| 125 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 126 | + ) -> ResponseWrapper: |
| 127 | + """ |
| 128 | + Submit a user-generated problem report for a stop |
| 129 | +
|
| 130 | + Args: |
| 131 | + code: A string code identifying the nature of the problem |
| 132 | +
|
| 133 | + user_comment: Additional comment text supplied by the user describing the problem |
| 134 | +
|
| 135 | + user_lat: The reporting user’s current latitude |
| 136 | +
|
| 137 | + user_location_accuracy: The reporting user’s location accuracy, in meters |
| 138 | +
|
| 139 | + user_lon: The reporting user’s current longitude |
| 140 | +
|
| 141 | + extra_headers: Send extra headers |
| 142 | +
|
| 143 | + extra_query: Add additional query parameters to the request |
| 144 | +
|
| 145 | + extra_body: Add additional JSON properties to the request |
| 146 | +
|
| 147 | + timeout: Override the client-level default timeout for this request, in seconds |
| 148 | + """ |
| 149 | + if not stop_id: |
| 150 | + raise ValueError(f"Expected a non-empty value for `stop_id` but received {stop_id!r}") |
| 151 | + return await self._get( |
| 152 | + f"/api/where/report-problem-with-stop/{stop_id}.json", |
| 153 | + options=make_request_options( |
| 154 | + extra_headers=extra_headers, |
| 155 | + extra_query=extra_query, |
| 156 | + extra_body=extra_body, |
| 157 | + timeout=timeout, |
| 158 | + query=await async_maybe_transform( |
| 159 | + { |
| 160 | + "code": code, |
| 161 | + "user_comment": user_comment, |
| 162 | + "user_lat": user_lat, |
| 163 | + "user_location_accuracy": user_location_accuracy, |
| 164 | + "user_lon": user_lon, |
| 165 | + }, |
| 166 | + report_problem_with_stop_retrieve_params.ReportProblemWithStopRetrieveParams, |
| 167 | + ), |
| 168 | + ), |
| 169 | + cast_to=ResponseWrapper, |
| 170 | + ) |
| 171 | + |
| 172 | + |
| 173 | +class ReportProblemWithStopResourceWithRawResponse: |
| 174 | + def __init__(self, report_problem_with_stop: ReportProblemWithStopResource) -> None: |
| 175 | + self._report_problem_with_stop = report_problem_with_stop |
| 176 | + |
| 177 | + self.retrieve = to_raw_response_wrapper( |
| 178 | + report_problem_with_stop.retrieve, |
| 179 | + ) |
| 180 | + |
| 181 | + |
| 182 | +class AsyncReportProblemWithStopResourceWithRawResponse: |
| 183 | + def __init__(self, report_problem_with_stop: AsyncReportProblemWithStopResource) -> None: |
| 184 | + self._report_problem_with_stop = report_problem_with_stop |
| 185 | + |
| 186 | + self.retrieve = async_to_raw_response_wrapper( |
| 187 | + report_problem_with_stop.retrieve, |
| 188 | + ) |
| 189 | + |
| 190 | + |
| 191 | +class ReportProblemWithStopResourceWithStreamingResponse: |
| 192 | + def __init__(self, report_problem_with_stop: ReportProblemWithStopResource) -> None: |
| 193 | + self._report_problem_with_stop = report_problem_with_stop |
| 194 | + |
| 195 | + self.retrieve = to_streamed_response_wrapper( |
| 196 | + report_problem_with_stop.retrieve, |
| 197 | + ) |
| 198 | + |
| 199 | + |
| 200 | +class AsyncReportProblemWithStopResourceWithStreamingResponse: |
| 201 | + def __init__(self, report_problem_with_stop: AsyncReportProblemWithStopResource) -> None: |
| 202 | + self._report_problem_with_stop = report_problem_with_stop |
| 203 | + |
| 204 | + self.retrieve = async_to_streamed_response_wrapper( |
| 205 | + report_problem_with_stop.retrieve, |
| 206 | + ) |
0 commit comments