1use anyhow::Result;
2
3use crate::{client::SpapiClient, models};
4
5impl SpapiClient {
6 pub async fn add_appointment_for_service_job_by_service_job_id(
8 &self,
9 service_job_id: &str,
10 body: models::services::AddAppointmentRequest,
11 ) -> Result<models::services::SetAppointmentResponse> {
12 let configuration = self.create_configuration().await?;
13 let guard = self
14 .limiter()
15 .wait("service_v1/add_appointment_for_service_job_by_service_job_id", 5.0, 20)
16 .await?;
17 let res = crate::apis::service_v1::add_appointment_for_service_job_by_service_job_id(
18 &configuration,
19 service_job_id,
20 body,
21 )
22 .await?;
23 guard.mark_response().await;
24 Ok(res)
25 }
26
27 pub async fn assign_appointment_resources(
29 &self,
30 service_job_id: &str,
31 appointment_id: &str,
32 body: models::services::AssignAppointmentResourcesRequest,
33 ) -> Result<models::services::AssignAppointmentResourcesResponse> {
34 let configuration = self.create_configuration().await?;
35 let guard = self
36 .limiter()
37 .wait("service_v1/assign_appointment_resources", 1.0, 2)
38 .await?;
39 let res = crate::apis::service_v1::assign_appointment_resources(
40 &configuration,
41 service_job_id,
42 appointment_id,
43 body,
44 )
45 .await?;
46 guard.mark_response().await;
47 Ok(res)
48 }
49
50 pub async fn cancel_reservation(
52 &self,
53 reservation_id: &str,
54 marketplace_ids: Vec<String>,
55 ) -> Result<models::services::CancelReservationResponse> {
56 let configuration = self.create_configuration().await?;
57 let guard = self
58 .limiter()
59 .wait("service_v1/cancel_reservation", 5.0, 20)
60 .await?;
61 let res = crate::apis::service_v1::cancel_reservation(
62 &configuration,
63 reservation_id,
64 marketplace_ids,
65 )
66 .await?;
67 guard.mark_response().await;
68 Ok(res)
69 }
70
71 pub async fn cancel_service_job_by_service_job_id(
73 &self,
74 service_job_id: &str,
75 cancellation_reason_code: &str,
76 ) -> Result<models::services::CancelServiceJobByServiceJobIdResponse> {
77 let configuration = self.create_configuration().await?;
78 let guard = self
79 .limiter()
80 .wait("service_v1/cancel_service_job_by_service_job_id", 5.0, 20)
81 .await?;
82 let res = crate::apis::service_v1::cancel_service_job_by_service_job_id(
83 &configuration,
84 service_job_id,
85 cancellation_reason_code,
86 )
87 .await?;
88 guard.mark_response().await;
89 Ok(res)
90 }
91
92 pub async fn complete_service_job_by_service_job_id(
94 &self,
95 service_job_id: &str,
96 ) -> Result<models::services::CompleteServiceJobByServiceJobIdResponse> {
97 let configuration = self.create_configuration().await?;
98 let guard = self
99 .limiter()
100 .wait("service_v1/complete_service_job_by_service_job_id", 5.0, 20)
101 .await?;
102 let res = crate::apis::service_v1::complete_service_job_by_service_job_id(
103 &configuration,
104 service_job_id,
105 )
106 .await?;
107 guard.mark_response().await;
108 Ok(res)
109 }
110
111 pub async fn create_reservation(
113 &self,
114 marketplace_ids: Vec<String>,
115 body: models::services::CreateReservationRequest,
116 ) -> Result<models::services::CreateReservationResponse> {
117 let configuration = self.create_configuration().await?;
118 let guard = self
119 .limiter()
120 .wait("service_v1/create_reservation", 5.0, 20)
121 .await?;
122 let res = crate::apis::service_v1::create_reservation(
123 &configuration,
124 marketplace_ids,
125 body,
126 )
127 .await?;
128 guard.mark_response().await;
129 Ok(res)
130 }
131
132 pub async fn create_service_document_upload_destination(
134 &self,
135 body: models::services::ServiceUploadDocument,
136 ) -> Result<models::services::CreateServiceDocumentUploadDestination> {
137 let configuration = self.create_configuration().await?;
138 let guard = self
139 .limiter()
140 .wait("service_v1/create_service_document_upload_destination", 5.0, 20)
141 .await?;
142 let res = crate::apis::service_v1::create_service_document_upload_destination(
143 &configuration,
144 body,
145 )
146 .await?;
147 guard.mark_response().await;
148 Ok(res)
149 }
150
151 pub async fn get_appointment_slots(
153 &self,
154 asin: &str,
155 store_id: &str,
156 marketplace_ids: Vec<String>,
157 start_time: Option<&str>,
158 end_time: Option<&str>,
159 ) -> Result<models::services::GetAppointmentSlotsResponse> {
160 let configuration = self.create_configuration().await?;
161 let guard = self
162 .limiter()
163 .wait("service_v1/get_appointment_slots", 20.0, 40)
164 .await?;
165 let res = crate::apis::service_v1::get_appointment_slots(
166 &configuration,
167 asin,
168 store_id,
169 marketplace_ids,
170 start_time,
171 end_time,
172 )
173 .await?;
174 guard.mark_response().await;
175 Ok(res)
176 }
177
178 pub async fn get_appointmment_slots_by_job_id(
180 &self,
181 service_job_id: &str,
182 marketplace_ids: Vec<String>,
183 start_time: Option<&str>,
184 end_time: Option<&str>,
185 ) -> Result<models::services::GetAppointmentSlotsResponse> {
186 let configuration = self.create_configuration().await?;
187 let guard = self
188 .limiter()
189 .wait("service_v1/get_appointmment_slots_by_job_id", 5.0, 20)
190 .await?;
191 let res = crate::apis::service_v1::get_appointmment_slots_by_job_id(
192 &configuration,
193 service_job_id,
194 marketplace_ids,
195 start_time,
196 end_time,
197 )
198 .await?;
199 guard.mark_response().await;
200 Ok(res)
201 }
202
203 pub async fn get_fixed_slot_capacity(
205 &self,
206 resource_id: &str,
207 marketplace_ids: Vec<String>,
208 body: models::services::FixedSlotCapacityQuery,
209 next_page_token: Option<&str>,
210 ) -> Result<models::services::FixedSlotCapacity> {
211 let configuration = self.create_configuration().await?;
212 let guard = self
213 .limiter()
214 .wait("service_v1/get_fixed_slot_capacity", 5.0, 20)
215 .await?;
216 let res = crate::apis::service_v1::get_fixed_slot_capacity(
217 &configuration,
218 resource_id,
219 marketplace_ids,
220 body,
221 next_page_token,
222 )
223 .await?;
224 guard.mark_response().await;
225 Ok(res)
226 }
227
228 pub async fn get_range_slot_capacity(
230 &self,
231 resource_id: &str,
232 marketplace_ids: Vec<String>,
233 body: models::services::RangeSlotCapacityQuery,
234 next_page_token: Option<&str>,
235 ) -> Result<models::services::RangeSlotCapacity> {
236 let configuration = self.create_configuration().await?;
237 let guard = self
238 .limiter()
239 .wait("service_v1/get_range_slot_capacity", 5.0, 20)
240 .await?;
241 let res = crate::apis::service_v1::get_range_slot_capacity(
242 &configuration,
243 resource_id,
244 marketplace_ids,
245 body,
246 next_page_token,
247 )
248 .await?;
249 guard.mark_response().await;
250 Ok(res)
251 }
252
253 pub async fn get_service_job_by_service_job_id(
255 &self,
256 service_job_id: &str,
257 ) -> Result<models::services::GetServiceJobByServiceJobIdResponse> {
258 let configuration = self.create_configuration().await?;
259 let guard = self
260 .limiter()
261 .wait("service_v1/get_service_job_by_service_job_id", 20.0, 40)
262 .await?;
263 let res = crate::apis::service_v1::get_service_job_by_service_job_id(
264 &configuration,
265 service_job_id,
266 )
267 .await?;
268 guard.mark_response().await;
269 Ok(res)
270 }
271
272 pub async fn get_service_jobs(
274 &self,
275 marketplace_ids: Vec<String>,
276 service_order_ids: Option<Vec<String>>,
277 service_job_status: Option<Vec<String>>,
278 page_token: Option<&str>,
279 page_size: Option<i32>,
280 sort_field: Option<&str>,
281 sort_order: Option<&str>,
282 created_after: Option<&str>,
283 created_before: Option<&str>,
284 last_updated_after: Option<&str>,
285 last_updated_before: Option<&str>,
286 schedule_start_date: Option<&str>,
287 schedule_end_date: Option<&str>,
288 asins: Option<Vec<String>>,
289 required_skills: Option<Vec<String>>,
290 store_ids: Option<Vec<String>>,
291 ) -> Result<models::services::GetServiceJobsResponse> {
292 let configuration = self.create_configuration().await?;
293 let guard = self
294 .limiter()
295 .wait("service_v1/get_service_jobs", 10.0, 40)
296 .await?;
297 let res = crate::apis::service_v1::get_service_jobs(
298 &configuration,
299 marketplace_ids,
300 service_order_ids,
301 service_job_status,
302 page_token,
303 page_size,
304 sort_field,
305 sort_order,
306 created_after,
307 created_before,
308 last_updated_after,
309 last_updated_before,
310 schedule_start_date,
311 schedule_end_date,
312 asins,
313 required_skills,
314 store_ids,
315 )
316 .await?;
317 guard.mark_response().await;
318 Ok(res)
319 }
320
321 pub async fn reschedule_appointment_for_service_job_by_service_job_id(
323 &self,
324 service_job_id: &str,
325 appointment_id: &str,
326 body: models::services::RescheduleAppointmentRequest,
327 ) -> Result<models::services::SetAppointmentResponse> {
328 let configuration = self.create_configuration().await?;
329 let guard = self
330 .limiter()
331 .wait("service_v1/reschedule_appointment_for_service_job_by_service_job_id", 5.0, 20)
332 .await?;
333 let res = crate::apis::service_v1::reschedule_appointment_for_service_job_by_service_job_id(
334 &configuration,
335 service_job_id,
336 appointment_id,
337 body,
338 )
339 .await?;
340 guard.mark_response().await;
341 Ok(res)
342 }
343
344 pub async fn set_appointment_fulfillment_data(
346 &self,
347 service_job_id: &str,
348 appointment_id: &str,
349 body: models::services::SetAppointmentFulfillmentDataRequest,
350 ) -> Result<String> {
351 let configuration = self.create_configuration().await?;
352 let guard = self
353 .limiter()
354 .wait("service_v1/set_appointment_fulfillment_data", 5.0, 20)
355 .await?;
356 let res = crate::apis::service_v1::set_appointment_fulfillment_data(
357 &configuration,
358 service_job_id,
359 appointment_id,
360 body,
361 )
362 .await?;
363 guard.mark_response().await;
364 Ok(res)
365 }
366
367 pub async fn update_reservation(
369 &self,
370 reservation_id: &str,
371 marketplace_ids: Vec<String>,
372 body: models::services::UpdateReservationRequest,
373 ) -> Result<models::services::UpdateReservationResponse> {
374 let configuration = self.create_configuration().await?;
375 let guard = self
376 .limiter()
377 .wait("service_v1/update_reservation", 5.0, 20)
378 .await?;
379 let res = crate::apis::service_v1::update_reservation(
380 &configuration,
381 reservation_id,
382 marketplace_ids,
383 body,
384 )
385 .await?;
386 guard.mark_response().await;
387 Ok(res)
388 }
389
390 pub async fn update_schedule(
392 &self,
393 resource_id: &str,
394 marketplace_ids: Vec<String>,
395 body: models::services::UpdateScheduleRequest,
396 ) -> Result<models::services::UpdateScheduleResponse> {
397 let configuration = self.create_configuration().await?;
398 let guard = self
399 .limiter()
400 .wait("service_v1/update_schedule", 5.0, 20)
401 .await?;
402 let res = crate::apis::service_v1::update_schedule(
403 &configuration,
404 resource_id,
405 marketplace_ids,
406 body,
407 )
408 .await?;
409 guard.mark_response().await;
410 Ok(res)
411 }
412}