motor-python-sdk 0.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- motor_python_sdk-0.0.2.dist-info/METADATA +230 -0
- motor_python_sdk-0.0.2.dist-info/RECORD +60 -0
- motor_python_sdk-0.0.2.dist-info/WHEEL +4 -0
- yasminaai/__init__.py +113 -0
- yasminaai/_default_clients.py +32 -0
- yasminaai/client.py +255 -0
- yasminaai/core/__init__.py +127 -0
- yasminaai/core/api_error.py +23 -0
- yasminaai/core/client_wrapper.py +119 -0
- yasminaai/core/datetime_utils.py +70 -0
- yasminaai/core/file.py +67 -0
- yasminaai/core/force_multipart.py +18 -0
- yasminaai/core/http_client.py +839 -0
- yasminaai/core/http_response.py +59 -0
- yasminaai/core/http_sse/__init__.py +42 -0
- yasminaai/core/http_sse/_api.py +170 -0
- yasminaai/core/http_sse/_decoders.py +61 -0
- yasminaai/core/http_sse/_exceptions.py +7 -0
- yasminaai/core/http_sse/_models.py +17 -0
- yasminaai/core/jsonable_encoder.py +120 -0
- yasminaai/core/logging.py +107 -0
- yasminaai/core/parse_error.py +36 -0
- yasminaai/core/pydantic_utilities.py +508 -0
- yasminaai/core/query_encoder.py +58 -0
- yasminaai/core/remove_none_from_dict.py +11 -0
- yasminaai/core/request_options.py +35 -0
- yasminaai/core/serialization.py +347 -0
- yasminaai/environment.py +7 -0
- yasminaai/errors/__init__.py +42 -0
- yasminaai/errors/bad_request_error.py +10 -0
- yasminaai/errors/not_found_error.py +10 -0
- yasminaai/errors/unauthorized_error.py +10 -0
- yasminaai/errors/unprocessable_entity_error.py +10 -0
- yasminaai/ot_ps/__init__.py +4 -0
- yasminaai/ot_ps/client.py +278 -0
- yasminaai/ot_ps/raw_client.py +355 -0
- yasminaai/policies/__init__.py +4 -0
- yasminaai/policies/client.py +393 -0
- yasminaai/policies/raw_client.py +493 -0
- yasminaai/py.typed +0 -0
- yasminaai/quotes/__init__.py +49 -0
- yasminaai/quotes/client.py +438 -0
- yasminaai/quotes/raw_client.py +548 -0
- yasminaai/quotes/types/__init__.py +47 -0
- yasminaai/quotes/types/delete_quote_requests_id_response.py +19 -0
- yasminaai/quotes/types/get_quote_requests_response.py +37 -0
- yasminaai/quotes/types/get_quote_requests_response_links_item.py +21 -0
- yasminaai/quotes/types/post_quote_requests_request_drivers_item.py +33 -0
- yasminaai/types/__init__.py +65 -0
- yasminaai/types/bad_request_error_body.py +20 -0
- yasminaai/types/benefit.py +24 -0
- yasminaai/types/company_quote.py +23 -0
- yasminaai/types/error.py +20 -0
- yasminaai/types/policy.py +33 -0
- yasminaai/types/quote_price.py +24 -0
- yasminaai/types/quote_response.py +90 -0
- yasminaai/types/quote_response_drivers_item.py +33 -0
- yasminaai/types/quote_response_quotes_item.py +30 -0
- yasminaai/types/unauthorized_error_body.py +20 -0
- yasminaai/version.py +3 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
6
|
+
from ..core.request_options import RequestOptions
|
|
7
|
+
from .raw_client import AsyncRawOtPsClient, RawOtPsClient
|
|
8
|
+
|
|
9
|
+
# this is used as the default value for optional parameters
|
|
10
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class OtPsClient:
|
|
14
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
15
|
+
self._raw_client = RawOtPsClient(client_wrapper=client_wrapper)
|
|
16
|
+
|
|
17
|
+
@property
|
|
18
|
+
def with_raw_response(self) -> RawOtPsClient:
|
|
19
|
+
"""
|
|
20
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
21
|
+
|
|
22
|
+
Returns
|
|
23
|
+
-------
|
|
24
|
+
RawOtPsClient
|
|
25
|
+
"""
|
|
26
|
+
return self._raw_client
|
|
27
|
+
|
|
28
|
+
def request_otp_for_quote_verification(
|
|
29
|
+
self, *, email: str, phone: str, owner_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
30
|
+
) -> None:
|
|
31
|
+
"""
|
|
32
|
+
This endpoint sends a one-time password (OTP) to the provided email and phone number for quote verification. It should be called before creating a quote request.
|
|
33
|
+
|
|
34
|
+
Parameters
|
|
35
|
+
----------
|
|
36
|
+
email : str
|
|
37
|
+
Email address of the car owner
|
|
38
|
+
|
|
39
|
+
phone : str
|
|
40
|
+
Phone number starting with 05 and containing 10 digits
|
|
41
|
+
|
|
42
|
+
owner_id : str
|
|
43
|
+
National ID or Iqama ID of the car owner (10 digits)
|
|
44
|
+
|
|
45
|
+
request_options : typing.Optional[RequestOptions]
|
|
46
|
+
Request-specific configuration.
|
|
47
|
+
|
|
48
|
+
Returns
|
|
49
|
+
-------
|
|
50
|
+
None
|
|
51
|
+
|
|
52
|
+
Examples
|
|
53
|
+
--------
|
|
54
|
+
from yasminaai import YasminaaiApi
|
|
55
|
+
|
|
56
|
+
client = YasminaaiApi(
|
|
57
|
+
token="YOUR_TOKEN",
|
|
58
|
+
)
|
|
59
|
+
client.ot_ps.request_otp_for_quote_verification(
|
|
60
|
+
email="someone@example.com",
|
|
61
|
+
phone="0501234567",
|
|
62
|
+
owner_id="1012345678",
|
|
63
|
+
)
|
|
64
|
+
"""
|
|
65
|
+
_response = self._raw_client.request_otp_for_quote_verification(
|
|
66
|
+
email=email, phone=phone, owner_id=owner_id, request_options=request_options
|
|
67
|
+
)
|
|
68
|
+
return _response.data
|
|
69
|
+
|
|
70
|
+
def request_otp_for_issuing_policy(
|
|
71
|
+
self,
|
|
72
|
+
*,
|
|
73
|
+
email: str,
|
|
74
|
+
phone: str,
|
|
75
|
+
owner_id: str,
|
|
76
|
+
quote_request_id: int,
|
|
77
|
+
quote_reference_id: str,
|
|
78
|
+
quote_price_id: str,
|
|
79
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
80
|
+
) -> None:
|
|
81
|
+
"""
|
|
82
|
+
This endpoint sends a one-time password (OTP). It should be called before issuing a policy.
|
|
83
|
+
|
|
84
|
+
Parameters
|
|
85
|
+
----------
|
|
86
|
+
email : str
|
|
87
|
+
Email address of the car owner
|
|
88
|
+
|
|
89
|
+
phone : str
|
|
90
|
+
Phone number starting with 05 and containing 10 digits
|
|
91
|
+
|
|
92
|
+
owner_id : str
|
|
93
|
+
National ID or Iqama ID of the car owner (10 digits)
|
|
94
|
+
|
|
95
|
+
quote_request_id : int
|
|
96
|
+
ID of the car quote request
|
|
97
|
+
|
|
98
|
+
quote_reference_id : str
|
|
99
|
+
Unique identifier for the quote reference ID (coming from POST /quote-requests)
|
|
100
|
+
|
|
101
|
+
quote_price_id : str
|
|
102
|
+
Unique identifier for the quote price ID that exists inside a quote item (coming from POST /quote-requests)
|
|
103
|
+
|
|
104
|
+
request_options : typing.Optional[RequestOptions]
|
|
105
|
+
Request-specific configuration.
|
|
106
|
+
|
|
107
|
+
Returns
|
|
108
|
+
-------
|
|
109
|
+
None
|
|
110
|
+
|
|
111
|
+
Examples
|
|
112
|
+
--------
|
|
113
|
+
from yasminaai import YasminaaiApi
|
|
114
|
+
|
|
115
|
+
client = YasminaaiApi(
|
|
116
|
+
token="YOUR_TOKEN",
|
|
117
|
+
)
|
|
118
|
+
client.ot_ps.request_otp_for_issuing_policy(
|
|
119
|
+
email="someone@example.com",
|
|
120
|
+
phone="0501234567",
|
|
121
|
+
owner_id="1012345678",
|
|
122
|
+
quote_request_id=123,
|
|
123
|
+
quote_reference_id="550e8400-e29b-41d4-a716-446655440000",
|
|
124
|
+
quote_price_id="550e8400-e29b-41d4-a716-446655440001",
|
|
125
|
+
)
|
|
126
|
+
"""
|
|
127
|
+
_response = self._raw_client.request_otp_for_issuing_policy(
|
|
128
|
+
email=email,
|
|
129
|
+
phone=phone,
|
|
130
|
+
owner_id=owner_id,
|
|
131
|
+
quote_request_id=quote_request_id,
|
|
132
|
+
quote_reference_id=quote_reference_id,
|
|
133
|
+
quote_price_id=quote_price_id,
|
|
134
|
+
request_options=request_options,
|
|
135
|
+
)
|
|
136
|
+
return _response.data
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class AsyncOtPsClient:
|
|
140
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
141
|
+
self._raw_client = AsyncRawOtPsClient(client_wrapper=client_wrapper)
|
|
142
|
+
|
|
143
|
+
@property
|
|
144
|
+
def with_raw_response(self) -> AsyncRawOtPsClient:
|
|
145
|
+
"""
|
|
146
|
+
Retrieves a raw implementation of this client that returns raw responses.
|
|
147
|
+
|
|
148
|
+
Returns
|
|
149
|
+
-------
|
|
150
|
+
AsyncRawOtPsClient
|
|
151
|
+
"""
|
|
152
|
+
return self._raw_client
|
|
153
|
+
|
|
154
|
+
async def request_otp_for_quote_verification(
|
|
155
|
+
self, *, email: str, phone: str, owner_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
156
|
+
) -> None:
|
|
157
|
+
"""
|
|
158
|
+
This endpoint sends a one-time password (OTP) to the provided email and phone number for quote verification. It should be called before creating a quote request.
|
|
159
|
+
|
|
160
|
+
Parameters
|
|
161
|
+
----------
|
|
162
|
+
email : str
|
|
163
|
+
Email address of the car owner
|
|
164
|
+
|
|
165
|
+
phone : str
|
|
166
|
+
Phone number starting with 05 and containing 10 digits
|
|
167
|
+
|
|
168
|
+
owner_id : str
|
|
169
|
+
National ID or Iqama ID of the car owner (10 digits)
|
|
170
|
+
|
|
171
|
+
request_options : typing.Optional[RequestOptions]
|
|
172
|
+
Request-specific configuration.
|
|
173
|
+
|
|
174
|
+
Returns
|
|
175
|
+
-------
|
|
176
|
+
None
|
|
177
|
+
|
|
178
|
+
Examples
|
|
179
|
+
--------
|
|
180
|
+
import asyncio
|
|
181
|
+
|
|
182
|
+
from yasminaai import AsyncYasminaaiApi
|
|
183
|
+
|
|
184
|
+
client = AsyncYasminaaiApi(
|
|
185
|
+
token="YOUR_TOKEN",
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
async def main() -> None:
|
|
190
|
+
await client.ot_ps.request_otp_for_quote_verification(
|
|
191
|
+
email="someone@example.com",
|
|
192
|
+
phone="0501234567",
|
|
193
|
+
owner_id="1012345678",
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
asyncio.run(main())
|
|
198
|
+
"""
|
|
199
|
+
_response = await self._raw_client.request_otp_for_quote_verification(
|
|
200
|
+
email=email, phone=phone, owner_id=owner_id, request_options=request_options
|
|
201
|
+
)
|
|
202
|
+
return _response.data
|
|
203
|
+
|
|
204
|
+
async def request_otp_for_issuing_policy(
|
|
205
|
+
self,
|
|
206
|
+
*,
|
|
207
|
+
email: str,
|
|
208
|
+
phone: str,
|
|
209
|
+
owner_id: str,
|
|
210
|
+
quote_request_id: int,
|
|
211
|
+
quote_reference_id: str,
|
|
212
|
+
quote_price_id: str,
|
|
213
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
214
|
+
) -> None:
|
|
215
|
+
"""
|
|
216
|
+
This endpoint sends a one-time password (OTP). It should be called before issuing a policy.
|
|
217
|
+
|
|
218
|
+
Parameters
|
|
219
|
+
----------
|
|
220
|
+
email : str
|
|
221
|
+
Email address of the car owner
|
|
222
|
+
|
|
223
|
+
phone : str
|
|
224
|
+
Phone number starting with 05 and containing 10 digits
|
|
225
|
+
|
|
226
|
+
owner_id : str
|
|
227
|
+
National ID or Iqama ID of the car owner (10 digits)
|
|
228
|
+
|
|
229
|
+
quote_request_id : int
|
|
230
|
+
ID of the car quote request
|
|
231
|
+
|
|
232
|
+
quote_reference_id : str
|
|
233
|
+
Unique identifier for the quote reference ID (coming from POST /quote-requests)
|
|
234
|
+
|
|
235
|
+
quote_price_id : str
|
|
236
|
+
Unique identifier for the quote price ID that exists inside a quote item (coming from POST /quote-requests)
|
|
237
|
+
|
|
238
|
+
request_options : typing.Optional[RequestOptions]
|
|
239
|
+
Request-specific configuration.
|
|
240
|
+
|
|
241
|
+
Returns
|
|
242
|
+
-------
|
|
243
|
+
None
|
|
244
|
+
|
|
245
|
+
Examples
|
|
246
|
+
--------
|
|
247
|
+
import asyncio
|
|
248
|
+
|
|
249
|
+
from yasminaai import AsyncYasminaaiApi
|
|
250
|
+
|
|
251
|
+
client = AsyncYasminaaiApi(
|
|
252
|
+
token="YOUR_TOKEN",
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
async def main() -> None:
|
|
257
|
+
await client.ot_ps.request_otp_for_issuing_policy(
|
|
258
|
+
email="someone@example.com",
|
|
259
|
+
phone="0501234567",
|
|
260
|
+
owner_id="1012345678",
|
|
261
|
+
quote_request_id=123,
|
|
262
|
+
quote_reference_id="550e8400-e29b-41d4-a716-446655440000",
|
|
263
|
+
quote_price_id="550e8400-e29b-41d4-a716-446655440001",
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
asyncio.run(main())
|
|
268
|
+
"""
|
|
269
|
+
_response = await self._raw_client.request_otp_for_issuing_policy(
|
|
270
|
+
email=email,
|
|
271
|
+
phone=phone,
|
|
272
|
+
owner_id=owner_id,
|
|
273
|
+
quote_request_id=quote_request_id,
|
|
274
|
+
quote_reference_id=quote_reference_id,
|
|
275
|
+
quote_price_id=quote_price_id,
|
|
276
|
+
request_options=request_options,
|
|
277
|
+
)
|
|
278
|
+
return _response.data
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from json.decoder import JSONDecodeError
|
|
5
|
+
|
|
6
|
+
from ..core.api_error import ApiError
|
|
7
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
9
|
+
from ..core.parse_error import ParsingError
|
|
10
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
11
|
+
from ..core.request_options import RequestOptions
|
|
12
|
+
from ..errors.bad_request_error import BadRequestError
|
|
13
|
+
from ..errors.unauthorized_error import UnauthorizedError
|
|
14
|
+
from pydantic import ValidationError
|
|
15
|
+
|
|
16
|
+
# this is used as the default value for optional parameters
|
|
17
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class RawOtPsClient:
|
|
21
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
22
|
+
self._client_wrapper = client_wrapper
|
|
23
|
+
|
|
24
|
+
def request_otp_for_quote_verification(
|
|
25
|
+
self, *, email: str, phone: str, owner_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
26
|
+
) -> HttpResponse[None]:
|
|
27
|
+
"""
|
|
28
|
+
This endpoint sends a one-time password (OTP) to the provided email and phone number for quote verification. It should be called before creating a quote request.
|
|
29
|
+
|
|
30
|
+
Parameters
|
|
31
|
+
----------
|
|
32
|
+
email : str
|
|
33
|
+
Email address of the car owner
|
|
34
|
+
|
|
35
|
+
phone : str
|
|
36
|
+
Phone number starting with 05 and containing 10 digits
|
|
37
|
+
|
|
38
|
+
owner_id : str
|
|
39
|
+
National ID or Iqama ID of the car owner (10 digits)
|
|
40
|
+
|
|
41
|
+
request_options : typing.Optional[RequestOptions]
|
|
42
|
+
Request-specific configuration.
|
|
43
|
+
|
|
44
|
+
Returns
|
|
45
|
+
-------
|
|
46
|
+
HttpResponse[None]
|
|
47
|
+
"""
|
|
48
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
49
|
+
"quote-otp",
|
|
50
|
+
method="POST",
|
|
51
|
+
json={
|
|
52
|
+
"email": email,
|
|
53
|
+
"phone": phone,
|
|
54
|
+
"owner_id": owner_id,
|
|
55
|
+
},
|
|
56
|
+
headers={
|
|
57
|
+
"content-type": "application/json",
|
|
58
|
+
},
|
|
59
|
+
request_options=request_options,
|
|
60
|
+
omit=OMIT,
|
|
61
|
+
)
|
|
62
|
+
try:
|
|
63
|
+
if 200 <= _response.status_code < 300:
|
|
64
|
+
return HttpResponse(response=_response, data=None)
|
|
65
|
+
if _response.status_code == 400:
|
|
66
|
+
raise BadRequestError(
|
|
67
|
+
headers=dict(_response.headers),
|
|
68
|
+
body=typing.cast(
|
|
69
|
+
typing.Any,
|
|
70
|
+
parse_obj_as(
|
|
71
|
+
type_=typing.Any, # type: ignore
|
|
72
|
+
object_=_response.json(),
|
|
73
|
+
),
|
|
74
|
+
),
|
|
75
|
+
)
|
|
76
|
+
if _response.status_code == 401:
|
|
77
|
+
raise UnauthorizedError(
|
|
78
|
+
headers=dict(_response.headers),
|
|
79
|
+
body=typing.cast(
|
|
80
|
+
typing.Any,
|
|
81
|
+
parse_obj_as(
|
|
82
|
+
type_=typing.Any, # type: ignore
|
|
83
|
+
object_=_response.json(),
|
|
84
|
+
),
|
|
85
|
+
),
|
|
86
|
+
)
|
|
87
|
+
_response_json = _response.json()
|
|
88
|
+
except JSONDecodeError:
|
|
89
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
90
|
+
except ValidationError as e:
|
|
91
|
+
raise ParsingError(
|
|
92
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
93
|
+
)
|
|
94
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
95
|
+
|
|
96
|
+
def request_otp_for_issuing_policy(
|
|
97
|
+
self,
|
|
98
|
+
*,
|
|
99
|
+
email: str,
|
|
100
|
+
phone: str,
|
|
101
|
+
owner_id: str,
|
|
102
|
+
quote_request_id: int,
|
|
103
|
+
quote_reference_id: str,
|
|
104
|
+
quote_price_id: str,
|
|
105
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
106
|
+
) -> HttpResponse[None]:
|
|
107
|
+
"""
|
|
108
|
+
This endpoint sends a one-time password (OTP). It should be called before issuing a policy.
|
|
109
|
+
|
|
110
|
+
Parameters
|
|
111
|
+
----------
|
|
112
|
+
email : str
|
|
113
|
+
Email address of the car owner
|
|
114
|
+
|
|
115
|
+
phone : str
|
|
116
|
+
Phone number starting with 05 and containing 10 digits
|
|
117
|
+
|
|
118
|
+
owner_id : str
|
|
119
|
+
National ID or Iqama ID of the car owner (10 digits)
|
|
120
|
+
|
|
121
|
+
quote_request_id : int
|
|
122
|
+
ID of the car quote request
|
|
123
|
+
|
|
124
|
+
quote_reference_id : str
|
|
125
|
+
Unique identifier for the quote reference ID (coming from POST /quote-requests)
|
|
126
|
+
|
|
127
|
+
quote_price_id : str
|
|
128
|
+
Unique identifier for the quote price ID that exists inside a quote item (coming from POST /quote-requests)
|
|
129
|
+
|
|
130
|
+
request_options : typing.Optional[RequestOptions]
|
|
131
|
+
Request-specific configuration.
|
|
132
|
+
|
|
133
|
+
Returns
|
|
134
|
+
-------
|
|
135
|
+
HttpResponse[None]
|
|
136
|
+
"""
|
|
137
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
138
|
+
"issue-otp",
|
|
139
|
+
method="POST",
|
|
140
|
+
json={
|
|
141
|
+
"email": email,
|
|
142
|
+
"phone": phone,
|
|
143
|
+
"owner_id": owner_id,
|
|
144
|
+
"quote_request_id": quote_request_id,
|
|
145
|
+
"quote_reference_id": quote_reference_id,
|
|
146
|
+
"quote_price_id": quote_price_id,
|
|
147
|
+
},
|
|
148
|
+
headers={
|
|
149
|
+
"content-type": "application/json",
|
|
150
|
+
},
|
|
151
|
+
request_options=request_options,
|
|
152
|
+
omit=OMIT,
|
|
153
|
+
)
|
|
154
|
+
try:
|
|
155
|
+
if 200 <= _response.status_code < 300:
|
|
156
|
+
return HttpResponse(response=_response, data=None)
|
|
157
|
+
if _response.status_code == 400:
|
|
158
|
+
raise BadRequestError(
|
|
159
|
+
headers=dict(_response.headers),
|
|
160
|
+
body=typing.cast(
|
|
161
|
+
typing.Any,
|
|
162
|
+
parse_obj_as(
|
|
163
|
+
type_=typing.Any, # type: ignore
|
|
164
|
+
object_=_response.json(),
|
|
165
|
+
),
|
|
166
|
+
),
|
|
167
|
+
)
|
|
168
|
+
if _response.status_code == 401:
|
|
169
|
+
raise UnauthorizedError(
|
|
170
|
+
headers=dict(_response.headers),
|
|
171
|
+
body=typing.cast(
|
|
172
|
+
typing.Any,
|
|
173
|
+
parse_obj_as(
|
|
174
|
+
type_=typing.Any, # type: ignore
|
|
175
|
+
object_=_response.json(),
|
|
176
|
+
),
|
|
177
|
+
),
|
|
178
|
+
)
|
|
179
|
+
_response_json = _response.json()
|
|
180
|
+
except JSONDecodeError:
|
|
181
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
182
|
+
except ValidationError as e:
|
|
183
|
+
raise ParsingError(
|
|
184
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
185
|
+
)
|
|
186
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
class AsyncRawOtPsClient:
|
|
190
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
191
|
+
self._client_wrapper = client_wrapper
|
|
192
|
+
|
|
193
|
+
async def request_otp_for_quote_verification(
|
|
194
|
+
self, *, email: str, phone: str, owner_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
195
|
+
) -> AsyncHttpResponse[None]:
|
|
196
|
+
"""
|
|
197
|
+
This endpoint sends a one-time password (OTP) to the provided email and phone number for quote verification. It should be called before creating a quote request.
|
|
198
|
+
|
|
199
|
+
Parameters
|
|
200
|
+
----------
|
|
201
|
+
email : str
|
|
202
|
+
Email address of the car owner
|
|
203
|
+
|
|
204
|
+
phone : str
|
|
205
|
+
Phone number starting with 05 and containing 10 digits
|
|
206
|
+
|
|
207
|
+
owner_id : str
|
|
208
|
+
National ID or Iqama ID of the car owner (10 digits)
|
|
209
|
+
|
|
210
|
+
request_options : typing.Optional[RequestOptions]
|
|
211
|
+
Request-specific configuration.
|
|
212
|
+
|
|
213
|
+
Returns
|
|
214
|
+
-------
|
|
215
|
+
AsyncHttpResponse[None]
|
|
216
|
+
"""
|
|
217
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
218
|
+
"quote-otp",
|
|
219
|
+
method="POST",
|
|
220
|
+
json={
|
|
221
|
+
"email": email,
|
|
222
|
+
"phone": phone,
|
|
223
|
+
"owner_id": owner_id,
|
|
224
|
+
},
|
|
225
|
+
headers={
|
|
226
|
+
"content-type": "application/json",
|
|
227
|
+
},
|
|
228
|
+
request_options=request_options,
|
|
229
|
+
omit=OMIT,
|
|
230
|
+
)
|
|
231
|
+
try:
|
|
232
|
+
if 200 <= _response.status_code < 300:
|
|
233
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
234
|
+
if _response.status_code == 400:
|
|
235
|
+
raise BadRequestError(
|
|
236
|
+
headers=dict(_response.headers),
|
|
237
|
+
body=typing.cast(
|
|
238
|
+
typing.Any,
|
|
239
|
+
parse_obj_as(
|
|
240
|
+
type_=typing.Any, # type: ignore
|
|
241
|
+
object_=_response.json(),
|
|
242
|
+
),
|
|
243
|
+
),
|
|
244
|
+
)
|
|
245
|
+
if _response.status_code == 401:
|
|
246
|
+
raise UnauthorizedError(
|
|
247
|
+
headers=dict(_response.headers),
|
|
248
|
+
body=typing.cast(
|
|
249
|
+
typing.Any,
|
|
250
|
+
parse_obj_as(
|
|
251
|
+
type_=typing.Any, # type: ignore
|
|
252
|
+
object_=_response.json(),
|
|
253
|
+
),
|
|
254
|
+
),
|
|
255
|
+
)
|
|
256
|
+
_response_json = _response.json()
|
|
257
|
+
except JSONDecodeError:
|
|
258
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
259
|
+
except ValidationError as e:
|
|
260
|
+
raise ParsingError(
|
|
261
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
262
|
+
)
|
|
263
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
264
|
+
|
|
265
|
+
async def request_otp_for_issuing_policy(
|
|
266
|
+
self,
|
|
267
|
+
*,
|
|
268
|
+
email: str,
|
|
269
|
+
phone: str,
|
|
270
|
+
owner_id: str,
|
|
271
|
+
quote_request_id: int,
|
|
272
|
+
quote_reference_id: str,
|
|
273
|
+
quote_price_id: str,
|
|
274
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
275
|
+
) -> AsyncHttpResponse[None]:
|
|
276
|
+
"""
|
|
277
|
+
This endpoint sends a one-time password (OTP). It should be called before issuing a policy.
|
|
278
|
+
|
|
279
|
+
Parameters
|
|
280
|
+
----------
|
|
281
|
+
email : str
|
|
282
|
+
Email address of the car owner
|
|
283
|
+
|
|
284
|
+
phone : str
|
|
285
|
+
Phone number starting with 05 and containing 10 digits
|
|
286
|
+
|
|
287
|
+
owner_id : str
|
|
288
|
+
National ID or Iqama ID of the car owner (10 digits)
|
|
289
|
+
|
|
290
|
+
quote_request_id : int
|
|
291
|
+
ID of the car quote request
|
|
292
|
+
|
|
293
|
+
quote_reference_id : str
|
|
294
|
+
Unique identifier for the quote reference ID (coming from POST /quote-requests)
|
|
295
|
+
|
|
296
|
+
quote_price_id : str
|
|
297
|
+
Unique identifier for the quote price ID that exists inside a quote item (coming from POST /quote-requests)
|
|
298
|
+
|
|
299
|
+
request_options : typing.Optional[RequestOptions]
|
|
300
|
+
Request-specific configuration.
|
|
301
|
+
|
|
302
|
+
Returns
|
|
303
|
+
-------
|
|
304
|
+
AsyncHttpResponse[None]
|
|
305
|
+
"""
|
|
306
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
307
|
+
"issue-otp",
|
|
308
|
+
method="POST",
|
|
309
|
+
json={
|
|
310
|
+
"email": email,
|
|
311
|
+
"phone": phone,
|
|
312
|
+
"owner_id": owner_id,
|
|
313
|
+
"quote_request_id": quote_request_id,
|
|
314
|
+
"quote_reference_id": quote_reference_id,
|
|
315
|
+
"quote_price_id": quote_price_id,
|
|
316
|
+
},
|
|
317
|
+
headers={
|
|
318
|
+
"content-type": "application/json",
|
|
319
|
+
},
|
|
320
|
+
request_options=request_options,
|
|
321
|
+
omit=OMIT,
|
|
322
|
+
)
|
|
323
|
+
try:
|
|
324
|
+
if 200 <= _response.status_code < 300:
|
|
325
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
326
|
+
if _response.status_code == 400:
|
|
327
|
+
raise BadRequestError(
|
|
328
|
+
headers=dict(_response.headers),
|
|
329
|
+
body=typing.cast(
|
|
330
|
+
typing.Any,
|
|
331
|
+
parse_obj_as(
|
|
332
|
+
type_=typing.Any, # type: ignore
|
|
333
|
+
object_=_response.json(),
|
|
334
|
+
),
|
|
335
|
+
),
|
|
336
|
+
)
|
|
337
|
+
if _response.status_code == 401:
|
|
338
|
+
raise UnauthorizedError(
|
|
339
|
+
headers=dict(_response.headers),
|
|
340
|
+
body=typing.cast(
|
|
341
|
+
typing.Any,
|
|
342
|
+
parse_obj_as(
|
|
343
|
+
type_=typing.Any, # type: ignore
|
|
344
|
+
object_=_response.json(),
|
|
345
|
+
),
|
|
346
|
+
),
|
|
347
|
+
)
|
|
348
|
+
_response_json = _response.json()
|
|
349
|
+
except JSONDecodeError:
|
|
350
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
351
|
+
except ValidationError as e:
|
|
352
|
+
raise ParsingError(
|
|
353
|
+
status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e
|
|
354
|
+
)
|
|
355
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|