1#![allow(unused_imports)]
12
13use reqwest;
14
15use super::{configuration, Error};
16use crate::apis::ResponseContent;
17use crate::models::{self, *};
18
19#[derive(Debug, Clone, Serialize, Deserialize)]
21#[serde(untagged)]
22pub enum DeleteWebhookError {
23 Status401(models::UnauthenticatedResponse),
24 Status404(models::NotFoundResponse),
25 Status400(models::BadRequestResponse),
26 Status500(models::InternalExceptionResponse),
27 UnknownValue(serde_json::Value),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum DeleteWebhookMessageError {
34 Status401(models::UnauthenticatedResponse),
35 Status404(models::NotFoundResponse),
36 Status400(models::BadRequestResponse),
37 Status500(models::InternalExceptionResponse),
38 UnknownValue(serde_json::Value),
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize)]
43#[serde(untagged)]
44pub enum DeleteWebhookMessageAttemptError {
45 Status401(models::UnauthenticatedResponse),
46 Status404(models::NotFoundResponse),
47 Status400(models::BadRequestResponse),
48 Status500(models::InternalExceptionResponse),
49 UnknownValue(serde_json::Value),
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
54#[serde(untagged)]
55pub enum GetSingleWebhookMessageError {
56 Status401(models::UnauthenticatedResponse),
57 Status404(models::NotFoundResponse),
58 Status400(models::BadRequestResponse),
59 Status500(models::InternalExceptionResponse),
60 UnknownValue(serde_json::Value),
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize)]
65#[serde(untagged)]
66pub enum GetSingleWebhookMessageAttemptError {
67 Status401(models::UnauthenticatedResponse),
68 Status404(models::NotFoundResponse),
69 Status400(models::BadRequestResponse),
70 Status500(models::InternalExceptionResponse),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum GetWebhookError {
78 Status401(models::UnauthenticatedResponse),
79 Status404(models::NotFoundResponse),
80 Status400(models::BadRequestResponse),
81 Status500(models::InternalExceptionResponse),
82 UnknownValue(serde_json::Value),
83}
84
85#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(untagged)]
88pub enum GetWebhookMessageAttemptsError {
89 Status401(models::UnauthenticatedResponse),
90 Status404(models::NotFoundResponse),
91 Status400(models::BadRequestResponse),
92 Status500(models::InternalExceptionResponse),
93 UnknownValue(serde_json::Value),
94}
95
96#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(untagged)]
99pub enum GetWebhookMessagesError {
100 Status401(models::UnauthenticatedResponse),
101 Status404(models::NotFoundResponse),
102 Status400(models::BadRequestResponse),
103 Status500(models::InternalExceptionResponse),
104 UnknownValue(serde_json::Value),
105}
106
107#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(untagged)]
110pub enum ListWebhookError {
111 Status401(models::UnauthenticatedResponse),
112 Status404(models::NotFoundResponse),
113 Status400(models::BadRequestResponse),
114 Status500(models::InternalExceptionResponse),
115 UnknownValue(serde_json::Value),
116}
117
118#[derive(Debug, Clone, Serialize, Deserialize)]
120#[serde(untagged)]
121pub enum StoreWebhookError {
122 Status422(models::ValidationErrorResponse),
123 Status401(models::UnauthenticatedResponse),
124 Status404(models::NotFoundResponse),
125 Status400(models::BadRequestResponse),
126 Status500(models::InternalExceptionResponse),
127 UnknownValue(serde_json::Value),
128}
129
130#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum SubmitWebhookError {
134 Status400(models::BadRequestResponse),
135 Status404(models::NotFoundResponse),
136 Status500(models::InternalExceptionResponse),
137 UnknownValue(serde_json::Value),
138}
139
140#[derive(Debug, Clone, Serialize, Deserialize)]
142#[serde(untagged)]
143pub enum TriggerTransactionWebhookError {
144 Status400(models::BadRequestResponse),
145 Status404(models::NotFoundResponse),
146 Status500(models::InternalExceptionResponse),
147 UnknownValue(serde_json::Value),
148}
149
150#[derive(Debug, Clone, Serialize, Deserialize)]
152#[serde(untagged)]
153pub enum UpdateWebhookError {
154 Status422(models::ValidationErrorResponse),
155 Status401(models::UnauthenticatedResponse),
156 Status404(models::NotFoundResponse),
157 Status400(models::BadRequestResponse),
158 Status500(models::InternalExceptionResponse),
159 UnknownValue(serde_json::Value),
160}
161
162pub async fn delete_webhook(
164 configuration: &configuration::Configuration,
165 id: &str,
166 x_trace_id: Option<&str>,
167) -> Result<(), Error<DeleteWebhookError>> {
168 let local_var_configuration = configuration;
169
170 let local_var_client = &local_var_configuration.client;
171
172 let local_var_uri_str = format!(
173 "{}/v1/webhooks/{id}",
174 local_var_configuration.base_path,
175 id = crate::apis::urlencode(id)
176 );
177 let mut local_var_req_builder =
178 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
179
180 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
181 local_var_req_builder =
182 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
183 }
184 if let Some(local_var_param_value) = x_trace_id {
185 local_var_req_builder =
186 local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
187 }
188 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
189 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
190 };
191 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
192 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
193 };
194
195 let local_var_req = local_var_req_builder.build()?;
196 let local_var_resp = local_var_client.execute(local_var_req).await?;
197
198 let local_var_status = local_var_resp.status();
199 let local_var_content = local_var_resp.text().await?;
200
201 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
202 Ok(())
203 } else {
204 let local_var_entity: Option<DeleteWebhookError> =
205 serde_json::from_str(&local_var_content).ok();
206 let local_var_error = ResponseContent {
207 status: local_var_status,
208 content: local_var_content,
209 entity: local_var_entity,
210 };
211 Err(Error::ResponseError(local_var_error))
212 }
213}
214
215pub async fn delete_webhook_message(
217 configuration: &configuration::Configuration,
218 id: &str,
219 message_id: i32,
220 x_trace_id: Option<&str>,
221) -> Result<(), Error<DeleteWebhookMessageError>> {
222 let local_var_configuration = configuration;
223
224 let local_var_client = &local_var_configuration.client;
225
226 let local_var_uri_str = format!(
227 "{}/v1/webhooks/{id}/messages/{messageId}",
228 local_var_configuration.base_path,
229 id = crate::apis::urlencode(id),
230 messageId = message_id
231 );
232 let mut local_var_req_builder =
233 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
234
235 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
236 local_var_req_builder =
237 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
238 }
239 if let Some(local_var_param_value) = x_trace_id {
240 local_var_req_builder =
241 local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
242 }
243 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
244 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
245 };
246 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
247 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
248 };
249
250 let local_var_req = local_var_req_builder.build()?;
251 let local_var_resp = local_var_client.execute(local_var_req).await?;
252
253 let local_var_status = local_var_resp.status();
254 let local_var_content = local_var_resp.text().await?;
255
256 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
257 Ok(())
258 } else {
259 let local_var_entity: Option<DeleteWebhookMessageError> =
260 serde_json::from_str(&local_var_content).ok();
261 let local_var_error = ResponseContent {
262 status: local_var_status,
263 content: local_var_content,
264 entity: local_var_entity,
265 };
266 Err(Error::ResponseError(local_var_error))
267 }
268}
269
270pub async fn delete_webhook_message_attempt(
272 configuration: &configuration::Configuration,
273 id: &str,
274 message_id: i32,
275 attempt_id: i32,
276 x_trace_id: Option<&str>,
277) -> Result<(), Error<DeleteWebhookMessageAttemptError>> {
278 let local_var_configuration = configuration;
279
280 let local_var_client = &local_var_configuration.client;
281
282 let local_var_uri_str = format!(
283 "{}/v1/webhooks/{id}/messages/{messageId}/attempts/{attemptId}",
284 local_var_configuration.base_path,
285 id = crate::apis::urlencode(id),
286 messageId = message_id,
287 attemptId = attempt_id
288 );
289 let mut local_var_req_builder =
290 local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
291
292 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
293 local_var_req_builder =
294 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
295 }
296 if let Some(local_var_param_value) = x_trace_id {
297 local_var_req_builder =
298 local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
299 }
300 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
301 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
302 };
303 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
304 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
305 };
306
307 let local_var_req = local_var_req_builder.build()?;
308 let local_var_resp = local_var_client.execute(local_var_req).await?;
309
310 let local_var_status = local_var_resp.status();
311 let local_var_content = local_var_resp.text().await?;
312
313 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
314 Ok(())
315 } else {
316 let local_var_entity: Option<DeleteWebhookMessageAttemptError> =
317 serde_json::from_str(&local_var_content).ok();
318 let local_var_error = ResponseContent {
319 status: local_var_status,
320 content: local_var_content,
321 entity: local_var_entity,
322 };
323 Err(Error::ResponseError(local_var_error))
324 }
325}
326
327pub async fn get_single_webhook_message(
329 configuration: &configuration::Configuration,
330 id: &str,
331 message_id: i32,
332 x_trace_id: Option<&str>,
333) -> Result<models::WebhookMessageSingle, Error<GetSingleWebhookMessageError>> {
334 let local_var_configuration = configuration;
335
336 let local_var_client = &local_var_configuration.client;
337
338 let local_var_uri_str = format!(
339 "{}/v1/webhooks/{id}/messages/{messageId}",
340 local_var_configuration.base_path,
341 id = crate::apis::urlencode(id),
342 messageId = message_id
343 );
344 let mut local_var_req_builder =
345 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
346
347 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
348 local_var_req_builder =
349 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
350 }
351 if let Some(local_var_param_value) = x_trace_id {
352 local_var_req_builder =
353 local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
354 }
355 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
356 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
357 };
358 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
359 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
360 };
361
362 let local_var_req = local_var_req_builder.build()?;
363 let local_var_resp = local_var_client.execute(local_var_req).await?;
364
365 let local_var_status = local_var_resp.status();
366 let local_var_content = local_var_resp.text().await?;
367
368 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
369 serde_json::from_str(&local_var_content).map_err(Error::from)
370 } else {
371 let local_var_entity: Option<GetSingleWebhookMessageError> =
372 serde_json::from_str(&local_var_content).ok();
373 let local_var_error = ResponseContent {
374 status: local_var_status,
375 content: local_var_content,
376 entity: local_var_entity,
377 };
378 Err(Error::ResponseError(local_var_error))
379 }
380}
381
382pub async fn get_single_webhook_message_attempt(
384 configuration: &configuration::Configuration,
385 id: &str,
386 message_id: i32,
387 attempt_id: i32,
388 x_trace_id: Option<&str>,
389) -> Result<models::WebhookAttemptSingle, Error<GetSingleWebhookMessageAttemptError>> {
390 let local_var_configuration = configuration;
391
392 let local_var_client = &local_var_configuration.client;
393
394 let local_var_uri_str = format!(
395 "{}/v1/webhooks/{id}/messages/{messageId}/attempts/{attemptId}",
396 local_var_configuration.base_path,
397 id = crate::apis::urlencode(id),
398 messageId = message_id,
399 attemptId = attempt_id
400 );
401 let mut local_var_req_builder =
402 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
403
404 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
405 local_var_req_builder =
406 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
407 }
408 if let Some(local_var_param_value) = x_trace_id {
409 local_var_req_builder =
410 local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
411 }
412 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
413 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
414 };
415 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
416 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
417 };
418
419 let local_var_req = local_var_req_builder.build()?;
420 let local_var_resp = local_var_client.execute(local_var_req).await?;
421
422 let local_var_status = local_var_resp.status();
423 let local_var_content = local_var_resp.text().await?;
424
425 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
426 serde_json::from_str(&local_var_content).map_err(Error::from)
427 } else {
428 let local_var_entity: Option<GetSingleWebhookMessageAttemptError> =
429 serde_json::from_str(&local_var_content).ok();
430 let local_var_error = ResponseContent {
431 status: local_var_status,
432 content: local_var_content,
433 entity: local_var_entity,
434 };
435 Err(Error::ResponseError(local_var_error))
436 }
437}
438
439pub async fn get_webhook(
441 configuration: &configuration::Configuration,
442 id: &str,
443 x_trace_id: Option<&str>,
444) -> Result<models::WebhookSingle, Error<GetWebhookError>> {
445 let local_var_configuration = configuration;
446
447 let local_var_client = &local_var_configuration.client;
448
449 let local_var_uri_str = format!(
450 "{}/v1/webhooks/{id}",
451 local_var_configuration.base_path,
452 id = crate::apis::urlencode(id)
453 );
454 let mut local_var_req_builder =
455 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
456
457 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
458 local_var_req_builder =
459 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
460 }
461 if let Some(local_var_param_value) = x_trace_id {
462 local_var_req_builder =
463 local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
464 }
465 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
466 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
467 };
468 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
469 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
470 };
471
472 let local_var_req = local_var_req_builder.build()?;
473 let local_var_resp = local_var_client.execute(local_var_req).await?;
474
475 let local_var_status = local_var_resp.status();
476 let local_var_content = local_var_resp.text().await?;
477
478 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
479 serde_json::from_str(&local_var_content).map_err(Error::from)
480 } else {
481 let local_var_entity: Option<GetWebhookError> =
482 serde_json::from_str(&local_var_content).ok();
483 let local_var_error = ResponseContent {
484 status: local_var_status,
485 content: local_var_content,
486 entity: local_var_entity,
487 };
488 Err(Error::ResponseError(local_var_error))
489 }
490}
491
492pub async fn get_webhook_message_attempts(
494 configuration: &configuration::Configuration,
495 id: &str,
496 message_id: i32,
497 x_trace_id: Option<&str>,
498 limit: Option<i32>,
499 page: Option<i32>,
500) -> Result<models::WebhookAttemptArray, Error<GetWebhookMessageAttemptsError>> {
501 let local_var_configuration = configuration;
502
503 let local_var_client = &local_var_configuration.client;
504
505 let local_var_uri_str = format!(
506 "{}/v1/webhooks/{id}/messages/{messageId}/attempts",
507 local_var_configuration.base_path,
508 id = crate::apis::urlencode(id),
509 messageId = message_id
510 );
511 let mut local_var_req_builder =
512 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
513
514 if let Some(ref local_var_str) = limit {
515 local_var_req_builder =
516 local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
517 }
518 if let Some(ref local_var_str) = page {
519 local_var_req_builder =
520 local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
521 }
522 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
523 local_var_req_builder =
524 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
525 }
526 if let Some(local_var_param_value) = x_trace_id {
527 local_var_req_builder =
528 local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
529 }
530 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
531 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
532 };
533 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
534 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
535 };
536
537 let local_var_req = local_var_req_builder.build()?;
538 let local_var_resp = local_var_client.execute(local_var_req).await?;
539
540 let local_var_status = local_var_resp.status();
541 let local_var_content = local_var_resp.text().await?;
542
543 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
544 serde_json::from_str(&local_var_content).map_err(Error::from)
545 } else {
546 let local_var_entity: Option<GetWebhookMessageAttemptsError> =
547 serde_json::from_str(&local_var_content).ok();
548 let local_var_error = ResponseContent {
549 status: local_var_status,
550 content: local_var_content,
551 entity: local_var_entity,
552 };
553 Err(Error::ResponseError(local_var_error))
554 }
555}
556
557pub async fn get_webhook_messages(
559 configuration: &configuration::Configuration,
560 id: &str,
561 x_trace_id: Option<&str>,
562) -> Result<models::WebhookMessageArray, Error<GetWebhookMessagesError>> {
563 let local_var_configuration = configuration;
564
565 let local_var_client = &local_var_configuration.client;
566
567 let local_var_uri_str = format!(
568 "{}/v1/webhooks/{id}/messages",
569 local_var_configuration.base_path,
570 id = crate::apis::urlencode(id)
571 );
572 let mut local_var_req_builder =
573 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
574
575 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
576 local_var_req_builder =
577 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
578 }
579 if let Some(local_var_param_value) = x_trace_id {
580 local_var_req_builder =
581 local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
582 }
583 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
584 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
585 };
586 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
587 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
588 };
589
590 let local_var_req = local_var_req_builder.build()?;
591 let local_var_resp = local_var_client.execute(local_var_req).await?;
592
593 let local_var_status = local_var_resp.status();
594 let local_var_content = local_var_resp.text().await?;
595
596 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
597 serde_json::from_str(&local_var_content).map_err(Error::from)
598 } else {
599 let local_var_entity: Option<GetWebhookMessagesError> =
600 serde_json::from_str(&local_var_content).ok();
601 let local_var_error = ResponseContent {
602 status: local_var_status,
603 content: local_var_content,
604 entity: local_var_entity,
605 };
606 Err(Error::ResponseError(local_var_error))
607 }
608}
609
610pub async fn list_webhook(
612 configuration: &configuration::Configuration,
613 x_trace_id: Option<&str>,
614 limit: Option<i32>,
615 page: Option<i32>,
616) -> Result<models::WebhookArray, Error<ListWebhookError>> {
617 let local_var_configuration = configuration;
618
619 let local_var_client = &local_var_configuration.client;
620
621 let local_var_uri_str = format!("{}/v1/webhooks", local_var_configuration.base_path);
622 let mut local_var_req_builder =
623 local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
624
625 if let Some(ref local_var_str) = limit {
626 local_var_req_builder =
627 local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
628 }
629 if let Some(ref local_var_str) = page {
630 local_var_req_builder =
631 local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
632 }
633 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
634 local_var_req_builder =
635 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
636 }
637 if let Some(local_var_param_value) = x_trace_id {
638 local_var_req_builder =
639 local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
640 }
641 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
642 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
643 };
644 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
645 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
646 };
647
648 let local_var_req = local_var_req_builder.build()?;
649 let local_var_resp = local_var_client.execute(local_var_req).await?;
650
651 let local_var_status = local_var_resp.status();
652 let local_var_content = local_var_resp.text().await?;
653
654 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
655 serde_json::from_str(&local_var_content).map_err(Error::from)
656 } else {
657 let local_var_entity: Option<ListWebhookError> =
658 serde_json::from_str(&local_var_content).ok();
659 let local_var_error = ResponseContent {
660 status: local_var_status,
661 content: local_var_content,
662 entity: local_var_entity,
663 };
664 Err(Error::ResponseError(local_var_error))
665 }
666}
667
668pub async fn store_webhook(
670 configuration: &configuration::Configuration,
671 webhook_store: WebhookStore,
672 x_trace_id: Option<&str>,
673) -> Result<models::WebhookSingle, Error<StoreWebhookError>> {
674 let local_var_configuration = configuration;
675
676 let local_var_client = &local_var_configuration.client;
677
678 let local_var_uri_str = format!("{}/v1/webhooks", local_var_configuration.base_path);
679 let mut local_var_req_builder =
680 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
681
682 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
683 local_var_req_builder =
684 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
685 }
686 if let Some(local_var_param_value) = x_trace_id {
687 local_var_req_builder =
688 local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
689 }
690 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
691 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
692 };
693 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
694 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
695 };
696 local_var_req_builder = local_var_req_builder.json(&webhook_store);
697
698 let local_var_req = local_var_req_builder.build()?;
699 let local_var_resp = local_var_client.execute(local_var_req).await?;
700
701 let local_var_status = local_var_resp.status();
702 let local_var_content = local_var_resp.text().await?;
703
704 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
705 serde_json::from_str(&local_var_content).map_err(Error::from)
706 } else {
707 let local_var_entity: Option<StoreWebhookError> =
708 serde_json::from_str(&local_var_content).ok();
709 let local_var_error = ResponseContent {
710 status: local_var_status,
711 content: local_var_content,
712 entity: local_var_entity,
713 };
714 Err(Error::ResponseError(local_var_error))
715 }
716}
717
718pub async fn submit_webhook(
720 configuration: &configuration::Configuration,
721 id: &str,
722 x_trace_id: Option<&str>,
723) -> Result<(), Error<SubmitWebhookError>> {
724 let local_var_configuration = configuration;
725
726 let local_var_client = &local_var_configuration.client;
727
728 let local_var_uri_str = format!(
729 "{}/v1/webhooks/{id}/submit",
730 local_var_configuration.base_path,
731 id = crate::apis::urlencode(id)
732 );
733 let mut local_var_req_builder =
734 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
735
736 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
737 local_var_req_builder =
738 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
739 }
740 if let Some(local_var_param_value) = x_trace_id {
741 local_var_req_builder =
742 local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
743 }
744 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
745 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
746 };
747 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
748 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
749 };
750
751 let local_var_req = local_var_req_builder.build()?;
752 let local_var_resp = local_var_client.execute(local_var_req).await?;
753
754 let local_var_status = local_var_resp.status();
755 let local_var_content = local_var_resp.text().await?;
756
757 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
758 Ok(())
759 } else {
760 let local_var_entity: Option<SubmitWebhookError> =
761 serde_json::from_str(&local_var_content).ok();
762 let local_var_error = ResponseContent {
763 status: local_var_status,
764 content: local_var_content,
765 entity: local_var_entity,
766 };
767 Err(Error::ResponseError(local_var_error))
768 }
769}
770
771pub async fn trigger_transaction_webhook(
773 configuration: &configuration::Configuration,
774 id: &str,
775 transaction_id: &str,
776 x_trace_id: Option<&str>,
777) -> Result<(), Error<TriggerTransactionWebhookError>> {
778 let local_var_configuration = configuration;
779
780 let local_var_client = &local_var_configuration.client;
781
782 let local_var_uri_str = format!(
783 "{}/v1/webhooks/{id}/trigger-transaction/{transactionId}",
784 local_var_configuration.base_path,
785 id = crate::apis::urlencode(id),
786 transactionId = crate::apis::urlencode(transaction_id)
787 );
788 let mut local_var_req_builder =
789 local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
790
791 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
792 local_var_req_builder =
793 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
794 }
795 if let Some(local_var_param_value) = x_trace_id {
796 local_var_req_builder =
797 local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
798 }
799 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
800 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
801 };
802 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
803 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
804 };
805
806 let local_var_req = local_var_req_builder.build()?;
807 let local_var_resp = local_var_client.execute(local_var_req).await?;
808
809 let local_var_status = local_var_resp.status();
810 let local_var_content = local_var_resp.text().await?;
811
812 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
813 Ok(())
814 } else {
815 let local_var_entity: Option<TriggerTransactionWebhookError> =
816 serde_json::from_str(&local_var_content).ok();
817 let local_var_error = ResponseContent {
818 status: local_var_status,
819 content: local_var_content,
820 entity: local_var_entity,
821 };
822 Err(Error::ResponseError(local_var_error))
823 }
824}
825
826pub async fn update_webhook(
828 configuration: &configuration::Configuration,
829 id: &str,
830 webhook_update: WebhookUpdate,
831 x_trace_id: Option<&str>,
832) -> Result<models::WebhookSingle, Error<UpdateWebhookError>> {
833 let local_var_configuration = configuration;
834
835 let local_var_client = &local_var_configuration.client;
836
837 let local_var_uri_str = format!(
838 "{}/v1/webhooks/{id}",
839 local_var_configuration.base_path,
840 id = crate::apis::urlencode(id)
841 );
842 let mut local_var_req_builder =
843 local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
844
845 if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
846 local_var_req_builder =
847 local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
848 }
849 if let Some(local_var_param_value) = x_trace_id {
850 local_var_req_builder =
851 local_var_req_builder.header("X-Trace-Id", local_var_param_value.to_string());
852 }
853 if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
854 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
855 };
856 if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
857 local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
858 };
859 local_var_req_builder = local_var_req_builder.json(&webhook_update);
860
861 let local_var_req = local_var_req_builder.build()?;
862 let local_var_resp = local_var_client.execute(local_var_req).await?;
863
864 let local_var_status = local_var_resp.status();
865 let local_var_content = local_var_resp.text().await?;
866
867 if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
868 serde_json::from_str(&local_var_content).map_err(Error::from)
869 } else {
870 let local_var_entity: Option<UpdateWebhookError> =
871 serde_json::from_str(&local_var_content).ok();
872 let local_var_error = ResponseContent {
873 status: local_var_status,
874 content: local_var_content,
875 entity: local_var_entity,
876 };
877 Err(Error::ResponseError(local_var_error))
878 }
879}