Skip to main content

wellfriend/generated/
resources.rs

1// Generated by scripts/sdk/generate-rust.mjs. Do not edit.
2//! Typed resources: one handle per API namespace, one method per operation.
3
4#![allow(clippy::too_many_arguments)]
5
6use reqwest::Method;
7
8use crate::client::{json_body, Request, RequestOptions, Wellfriend};
9use crate::error::Result;
10#[allow(unused_imports)]
11use crate::generated::models::*;
12#[allow(unused_imports)]
13use crate::models::*;
14#[allow(unused_imports)]
15use crate::webhooks::Webhooks;
16#[allow(unused_imports)]
17use crate::{Download, FileInput, Object, Page, PageStream};
18
19/// The `platform` endpoints. Get it with [`Wellfriend::platform`].
20#[derive(Clone, Debug)]
21pub struct Platform {
22    pub(crate) client: Wellfriend,
23    pub(crate) options: RequestOptions,
24}
25
26impl Platform {
27    /// The same handle with these options for every call made through it.
28    pub fn with_options(mut self, options: RequestOptions) -> Self {
29        self.options = options;
30        self
31    }
32
33    /// List available capabilities
34    ///
35    /// `GET /api/v2/capabilities`
36    pub async fn capabilities_list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
37        let request = Request::new(Method::GET, ["capabilities".to_owned()])
38            .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
39            .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
40        self.client.json(&self.options, request).await
41    }
42
43    /// Every item of [`capabilities_list`](Self::capabilities_list), fetching further pages as the stream is read.
44    pub fn capabilities_stream(&self, params: Option<ListParams>) -> PageStream<Object> {
45        let this = self.clone();
46        let params = params.unwrap_or_default();
47        crate::pagination::paginate(move |cursor| {
48            let this = this.clone();
49            let mut params = params.clone();
50            if cursor.is_some() {
51                params.cursor = cursor;
52            }
53            Box::pin(async move { this.capabilities_list(Some(params)).await })
54        })
55    }
56}
57
58/// The `pricing` endpoints. Get it with [`Wellfriend::pricing`].
59#[derive(Clone, Debug)]
60pub struct Pricing {
61    pub(crate) client: Wellfriend,
62    pub(crate) options: RequestOptions,
63}
64
65impl Pricing {
66    /// The same handle with these options for every call made through it.
67    pub fn with_options(mut self, options: RequestOptions) -> Self {
68        self.options = options;
69        self
70    }
71
72    /// Quote what a tool or a chain costs
73    ///
74    /// `POST /api/v2/quote`
75    pub async fn quote(&self, body: Option<PricingQuoteRequest>) -> Result<Quote> {
76        let request = Request::new(Method::POST, ["quote".to_owned()])
77            .json(json_body(&body.unwrap_or_default(), None)?);
78        self.client
79            .json_field(&self.options, request, "quote")
80            .await
81    }
82}
83
84/// The `workflows` endpoints. Get it with [`Wellfriend::workflows`].
85#[derive(Clone, Debug)]
86pub struct Workflows {
87    pub(crate) client: Wellfriend,
88    pub(crate) options: RequestOptions,
89}
90
91impl Workflows {
92    /// The same handle with these options for every call made through it.
93    pub fn with_options(mut self, options: RequestOptions) -> Self {
94        self.options = options;
95        self
96    }
97
98    /// Validate a workflow draft
99    ///
100    /// `POST /api/v2/workflows/validate`
101    pub async fn validate(&self, body: WorkflowsValidateRequest) -> Result<Object> {
102        let request = Request::new(
103            Method::POST,
104            ["workflows".to_owned(), "validate".to_owned()],
105        )
106        .json(json_body(&body, None)?);
107        self.client.json(&self.options, request).await
108    }
109
110    /// Create a workflow draft
111    ///
112    /// `POST /api/v2/workflows`
113    pub async fn create(&self, body: WorkflowsCreateRequest) -> Result<Workflow> {
114        let key = self.options.key();
115        let request = Request::new(Method::POST, ["workflows".to_owned()])
116            .json(json_body(&body, Some(&key))?)
117            .idempotency_key(key);
118        self.client
119            .json_field(&self.options, request, "workflow")
120            .await
121    }
122
123    /// List workflow definitions
124    ///
125    /// `GET /api/v2/workflows`
126    pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Workflow>> {
127        let request = Request::new(Method::GET, ["workflows".to_owned()])
128            .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
129            .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
130        self.client.json(&self.options, request).await
131    }
132
133    /// Every item of [`list`](Self::list), fetching further pages as the stream is read.
134    pub fn stream(&self, params: Option<ListParams>) -> PageStream<Workflow> {
135        let this = self.clone();
136        let params = params.unwrap_or_default();
137        crate::pagination::paginate(move |cursor| {
138            let this = this.clone();
139            let mut params = params.clone();
140            if cursor.is_some() {
141                params.cursor = cursor;
142            }
143            Box::pin(async move { this.list(Some(params)).await })
144        })
145    }
146
147    /// Get a workflow definition
148    ///
149    /// `GET /api/v2/workflows/{workflowId}`
150    pub async fn get(&self, workflow_id: &str) -> Result<Workflow> {
151        let request = Request::new(
152            Method::GET,
153            ["workflows".to_owned(), workflow_id.to_owned()],
154        );
155        self.client
156            .json_field(&self.options, request, "workflow")
157            .await
158    }
159
160    /// Replace a workflow draft
161    ///
162    /// `PATCH /api/v2/workflows/{workflowId}`
163    pub async fn update(
164        &self,
165        workflow_id: &str,
166        body: WorkflowsUpdateRequest,
167    ) -> Result<Workflow> {
168        let request = Request::new(
169            Method::PATCH,
170            ["workflows".to_owned(), workflow_id.to_owned()],
171        )
172        .json(json_body(&body, None)?);
173        self.client
174            .json_field(&self.options, request, "workflow")
175            .await
176    }
177
178    /// Publish an immutable workflow version
179    ///
180    /// `POST /api/v2/workflows/{workflowId}/publish`
181    pub async fn publish(
182        &self,
183        workflow_id: &str,
184        body: WorkflowsPublishRequest,
185    ) -> Result<Workflow> {
186        let request = Request::new(
187            Method::POST,
188            [
189                "workflows".to_owned(),
190                workflow_id.to_owned(),
191                "publish".to_owned(),
192            ],
193        )
194        .json(json_body(&body, None)?);
195        self.client
196            .json_field(&self.options, request, "workflow")
197            .await
198    }
199}
200
201impl Webhooks {
202    /// Verify a Standard Webhooks signature
203    ///
204    /// `POST /api/v2/webhooks/verify`
205    pub async fn verify_remote(&self, body: Option<WebhooksVerifyRemoteRequest>) -> Result<Object> {
206        let request = Request::new(Method::POST, ["webhooks".to_owned(), "verify".to_owned()])
207            .json(json_body(&body.unwrap_or_default(), None)?);
208        self.client.json(&self.options, request).await
209    }
210
211    /// Create a signed webhook endpoint
212    ///
213    /// `POST /api/v2/webhook-endpoints`
214    pub async fn endpoints_create(&self, body: WebhooksEndpointsCreateRequest) -> Result<Object> {
215        let key = self.options.key();
216        let request = Request::new(Method::POST, ["webhook-endpoints".to_owned()])
217            .json(json_body(&body, Some(&key))?)
218            .idempotency_key(key);
219        self.client.json(&self.options, request).await
220    }
221
222    /// List signed webhook endpoints
223    ///
224    /// `GET /api/v2/webhook-endpoints`
225    pub async fn endpoints_list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
226        let request = Request::new(Method::GET, ["webhook-endpoints".to_owned()])
227            .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
228            .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
229        self.client.json(&self.options, request).await
230    }
231
232    /// Every item of [`endpoints_list`](Self::endpoints_list), fetching further pages as the stream is read.
233    pub fn endpoints_stream(&self, params: Option<ListParams>) -> PageStream<Object> {
234        let this = self.clone();
235        let params = params.unwrap_or_default();
236        crate::pagination::paginate(move |cursor| {
237            let this = this.clone();
238            let mut params = params.clone();
239            if cursor.is_some() {
240                params.cursor = cursor;
241            }
242            Box::pin(async move { this.endpoints_list(Some(params)).await })
243        })
244    }
245
246    /// Get a signed webhook endpoint
247    ///
248    /// `GET /api/v2/webhook-endpoints/{endpointId}`
249    pub async fn endpoints_get(&self, endpoint_id: &str) -> Result<WebhooksEndpointsGetResponse> {
250        let request = Request::new(
251            Method::GET,
252            ["webhook-endpoints".to_owned(), endpoint_id.to_owned()],
253        );
254        self.client.json(&self.options, request).await
255    }
256
257    /// Update a signed webhook endpoint
258    ///
259    /// `PATCH /api/v2/webhook-endpoints/{endpointId}`
260    pub async fn endpoints_update(
261        &self,
262        endpoint_id: &str,
263        body: Option<WebhooksEndpointsUpdateRequest>,
264    ) -> Result<WebhooksEndpointsGetResponse> {
265        let request = Request::new(
266            Method::PATCH,
267            ["webhook-endpoints".to_owned(), endpoint_id.to_owned()],
268        )
269        .json(json_body(&body.unwrap_or_default(), None)?);
270        self.client.json(&self.options, request).await
271    }
272
273    /// Delete a signed webhook endpoint
274    ///
275    /// `DELETE /api/v2/webhook-endpoints/{endpointId}`
276    pub async fn endpoints_delete(
277        &self,
278        endpoint_id: &str,
279        body: WebhooksEndpointsDeleteRequest,
280    ) -> Result<WebhooksEndpointsDeleteResponse> {
281        let request = Request::new(
282            Method::DELETE,
283            ["webhook-endpoints".to_owned(), endpoint_id.to_owned()],
284        )
285        .json(json_body(&body, None)?);
286        self.client.json(&self.options, request).await
287    }
288
289    /// Queue a webhook endpoint test
290    ///
291    /// `POST /api/v2/webhook-endpoints/{endpointId}/test`
292    pub async fn endpoints_test(
293        &self,
294        endpoint_id: &str,
295        body: WebhooksEndpointsTestRequest,
296    ) -> Result<Object> {
297        let request = Request::new(
298            Method::POST,
299            [
300                "webhook-endpoints".to_owned(),
301                endpoint_id.to_owned(),
302                "test".to_owned(),
303            ],
304        )
305        .json(json_body(&body, None)?);
306        self.client.json(&self.options, request).await
307    }
308
309    /// Inspect webhook deliveries
310    ///
311    /// `GET /api/v2/webhook-deliveries`
312    pub async fn deliveries_list(
313        &self,
314        params: Option<ListParams>,
315    ) -> Result<Page<WebhooksDeliveriesListItem>> {
316        let request = Request::new(Method::GET, ["webhook-deliveries".to_owned()])
317            .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
318            .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
319        self.client.json(&self.options, request).await
320    }
321
322    /// Every item of [`deliveries_list`](Self::deliveries_list), fetching further pages as the stream is read.
323    pub fn deliveries_stream(
324        &self,
325        params: Option<ListParams>,
326    ) -> PageStream<WebhooksDeliveriesListItem> {
327        let this = self.clone();
328        let params = params.unwrap_or_default();
329        crate::pagination::paginate(move |cursor| {
330            let this = this.clone();
331            let mut params = params.clone();
332            if cursor.is_some() {
333                params.cursor = cursor;
334            }
335            Box::pin(async move { this.deliveries_list(Some(params)).await })
336        })
337    }
338
339    /// Replay a webhook delivery
340    ///
341    /// `POST /api/v2/webhook-deliveries/{deliveryId}/replay`
342    pub async fn deliveries_replay(
343        &self,
344        delivery_id: &str,
345        body: Option<WebhooksDeliveriesReplayRequest>,
346    ) -> Result<Object> {
347        let request = Request::new(
348            Method::POST,
349            [
350                "webhook-deliveries".to_owned(),
351                delivery_id.to_owned(),
352                "replay".to_owned(),
353            ],
354        )
355        .json(json_body(&body.unwrap_or_default(), None)?);
356        self.client.json(&self.options, request).await
357    }
358
359    /// Rotate a webhook signing secret
360    ///
361    /// `POST /api/v2/webhook-endpoints/{endpointId}/rotate-secret`
362    pub async fn endpoints_rotate_secret(
363        &self,
364        endpoint_id: &str,
365        body: Option<WebhooksEndpointsRotateSecretRequest>,
366    ) -> Result<WebhooksEndpointsRotateSecretResponse> {
367        let request = Request::new(
368            Method::POST,
369            [
370                "webhook-endpoints".to_owned(),
371                endpoint_id.to_owned(),
372                "rotate-secret".to_owned(),
373            ],
374        )
375        .json(json_body(&body.unwrap_or_default(), None)?);
376        self.client.json(&self.options, request).await
377    }
378
379    /// Replay an endpoint's failed webhook deliveries
380    ///
381    /// `POST /api/v2/webhook-endpoints/{endpointId}/replay`
382    pub async fn endpoints_replay(
383        &self,
384        endpoint_id: &str,
385        body: WebhooksEndpointsReplayRequest,
386    ) -> Result<WebhooksEndpointsReplayResponse> {
387        let request = Request::new(
388            Method::POST,
389            [
390                "webhook-endpoints".to_owned(),
391                endpoint_id.to_owned(),
392                "replay".to_owned(),
393            ],
394        )
395        .json(json_body(&body, None)?);
396        self.client.json(&self.options, request).await
397    }
398
399    /// Inspect a webhook endpoint's health, signing keys and activity
400    ///
401    /// `GET /api/v2/webhook-endpoints/{endpointId}/insights`
402    pub async fn endpoints_insights(
403        &self,
404        endpoint_id: &str,
405    ) -> Result<WebhooksEndpointsInsightsResponse> {
406        let request = Request::new(
407            Method::GET,
408            [
409                "webhook-endpoints".to_owned(),
410                endpoint_id.to_owned(),
411                "insights".to_owned(),
412            ],
413        );
414        self.client.json(&self.options, request).await
415    }
416
417    /// Inspect one webhook delivery and its attempts
418    ///
419    /// `GET /api/v2/webhook-deliveries/{deliveryId}`
420    pub async fn deliveries_get(&self, delivery_id: &str) -> Result<WebhooksDeliveriesGetResponse> {
421        let request = Request::new(
422            Method::GET,
423            ["webhook-deliveries".to_owned(), delivery_id.to_owned()],
424        );
425        self.client.json(&self.options, request).await
426    }
427}
428
429/// The `documents` endpoints. Get it with [`Wellfriend::documents`].
430#[derive(Clone, Debug)]
431pub struct Documents {
432    pub(crate) client: Wellfriend,
433    pub(crate) options: RequestOptions,
434}
435
436impl Documents {
437    /// The same handle with these options for every call made through it.
438    pub fn with_options(mut self, options: RequestOptions) -> Self {
439        self.options = options;
440        self
441    }
442
443    /// Ingest a document
444    ///
445    /// `POST /api/v2/documents`
446    ///
447    /// Streams the file from disk (or memory); files above 100 MiB use the resumable upload.
448    pub async fn create(&self, input: impl Into<FileInput>) -> Result<Document> {
449        crate::uploads::upload_document(&self.client, &self.options, input.into()).await
450    }
451
452    /// List documents
453    ///
454    /// `GET /api/v2/documents`
455    pub async fn list(&self, params: Option<DocumentsListParams>) -> Result<Page<Document>> {
456        let request = Request::new(Method::GET, ["documents".to_owned()])
457            .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
458            .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()))
459            .query("q", params.as_ref().and_then(|p| p.q.as_ref()));
460        self.client.json(&self.options, request).await
461    }
462
463    /// Every item of [`list`](Self::list), fetching further pages as the stream is read.
464    pub fn stream(&self, params: Option<DocumentsListParams>) -> PageStream<Document> {
465        let this = self.clone();
466        let params = params.unwrap_or_default();
467        crate::pagination::paginate(move |cursor| {
468            let this = this.clone();
469            let mut params = params.clone();
470            if cursor.is_some() {
471                params.cursor = cursor;
472            }
473            Box::pin(async move { this.list(Some(params)).await })
474        })
475    }
476
477    /// Get a document and its current immutable version
478    ///
479    /// `GET /api/v2/documents/{documentId}`
480    pub async fn get(&self, document_id: &str) -> Result<Document> {
481        let request = Request::new(
482            Method::GET,
483            ["documents".to_owned(), document_id.to_owned()],
484        );
485        self.client
486            .json_field(&self.options, request, "document")
487            .await
488    }
489}
490
491/// The `uploads` endpoints. Get it with [`Wellfriend::uploads`].
492#[derive(Clone, Debug)]
493pub struct Uploads {
494    pub(crate) client: Wellfriend,
495    pub(crate) options: RequestOptions,
496}
497
498impl Uploads {
499    /// The same handle with these options for every call made through it.
500    pub fn with_options(mut self, options: RequestOptions) -> Self {
501        self.options = options;
502        self
503    }
504
505    /// Start a chunked document upload
506    ///
507    /// `POST /api/v2/uploads`
508    pub async fn create(&self, body: UploadsCreateRequest) -> Result<Upload> {
509        let key = self.options.key();
510        let request = Request::new(Method::POST, ["uploads".to_owned()])
511            .json(json_body(&body, None)?)
512            .idempotency_key(key);
513        self.client.json(&self.options, request).await
514    }
515
516    /// Get a chunked upload
517    ///
518    /// `GET /api/v2/uploads/{uploadId}`
519    pub async fn get(&self, upload_id: &str) -> Result<Upload> {
520        let request = Request::new(Method::GET, ["uploads".to_owned(), upload_id.to_owned()]);
521        self.client.json(&self.options, request).await
522    }
523
524    /// Abort a chunked upload
525    ///
526    /// `DELETE /api/v2/uploads/{uploadId}`
527    pub async fn abort(&self, upload_id: &str, body: UploadsAbortRequest) -> Result<Upload> {
528        let request = Request::new(Method::DELETE, ["uploads".to_owned(), upload_id.to_owned()])
529            .json(json_body(&body, None)?);
530        self.client.json(&self.options, request).await
531    }
532
533    /// Upload one part of a chunked upload
534    ///
535    /// `PUT /api/v2/uploads/{uploadId}/parts/{index}`
536    pub async fn parts_put(
537        &self,
538        upload_id: &str,
539        index: &str,
540        part: bytes::Bytes,
541    ) -> Result<UploadPart> {
542        let request = Request::new(
543            Method::PUT,
544            [
545                "uploads".to_owned(),
546                upload_id.to_owned(),
547                "parts".to_owned(),
548                index.to_owned(),
549            ],
550        )
551        .header(
552            "x-part-sha256",
553            &crate::util::hex(&<sha2::Sha256 as sha2::Digest>::digest(&part)),
554        )
555        .body(crate::client::RequestBody::Bytes {
556            data: part,
557            content_type: "application/octet-stream".into(),
558        })
559        .retry_always();
560        self.client.json(&self.options, request).await
561    }
562
563    /// Complete a chunked upload into a document
564    ///
565    /// `POST /api/v2/uploads/{uploadId}/complete`
566    pub async fn complete(
567        &self,
568        upload_id: &str,
569        body: Option<UploadsCompleteRequest>,
570    ) -> Result<UploadCompletion> {
571        let request = Request::new(
572            Method::POST,
573            [
574                "uploads".to_owned(),
575                upload_id.to_owned(),
576                "complete".to_owned(),
577            ],
578        )
579        .json(json_body(&body.unwrap_or_default(), None)?)
580        .retry_always();
581        self.client.json(&self.options, request).await
582    }
583}
584
585/// The `document-operations` endpoints. Get it with [`Wellfriend::document_operations`].
586#[derive(Clone, Debug)]
587pub struct DocumentOperations {
588    pub(crate) client: Wellfriend,
589    pub(crate) options: RequestOptions,
590}
591
592impl DocumentOperations {
593    /// The same handle with these options for every call made through it.
594    pub fn with_options(mut self, options: RequestOptions) -> Self {
595        self.options = options;
596        self
597    }
598
599    /// Run an operation against an immutable version
600    ///
601    /// `POST /api/v2/document-operations`
602    pub async fn create(&self, body: DocumentOperationsCreateRequest) -> Result<Operation> {
603        let key = self.options.key();
604        let request = Request::new(Method::POST, ["document-operations".to_owned()])
605            .json(json_body(&body, Some(&key))?)
606            .idempotency_key(key);
607        self.client
608            .json_field(&self.options, request, "operation")
609            .await
610    }
611
612    /// Inspect a document operation
613    ///
614    /// `GET /api/v2/document-operations/{operationId}`
615    pub async fn get(&self, operation_id: &str) -> Result<Operation> {
616        let request = Request::new(
617            Method::GET,
618            ["document-operations".to_owned(), operation_id.to_owned()],
619        );
620        self.client
621            .json_field(&self.options, request, "operation")
622            .await
623    }
624
625    /// List the parts of an operation's output
626    ///
627    /// `GET /api/v2/document-operations/{operationId}/outputs`
628    pub async fn outputs(&self, operation_id: &str) -> Result<OperationOutputs> {
629        let request = Request::new(
630            Method::GET,
631            [
632                "document-operations".to_owned(),
633                operation_id.to_owned(),
634                "outputs".to_owned(),
635            ],
636        );
637        self.client.json(&self.options, request).await
638    }
639}
640
641/// The `secure-links` endpoints. Get it with [`Wellfriend::secure_links`].
642#[derive(Clone, Debug)]
643pub struct SecureLinks {
644    pub(crate) client: Wellfriend,
645    pub(crate) options: RequestOptions,
646}
647
648impl SecureLinks {
649    /// The same handle with these options for every call made through it.
650    pub fn with_options(mut self, options: RequestOptions) -> Self {
651        self.options = options;
652        self
653    }
654
655    /// Create a version-bound secure link
656    ///
657    /// `POST /api/v2/secure-links`
658    pub async fn create(&self, body: SecureLinksCreateRequest) -> Result<Object> {
659        let key = self.options.key();
660        let request = Request::new(Method::POST, ["secure-links".to_owned()])
661            .json(json_body(&body, Some(&key))?)
662            .idempotency_key(key);
663        self.client.json(&self.options, request).await
664    }
665
666    /// List secure links
667    ///
668    /// `GET /api/v2/secure-links`
669    pub async fn list(&self) -> Result<Object> {
670        let request = Request::new(Method::GET, ["secure-links".to_owned()]);
671        self.client.json(&self.options, request).await
672    }
673
674    /// Inspect a secure link
675    ///
676    /// `GET /api/v2/secure-links/{linkId}`
677    pub async fn get(&self, link_id: &str) -> Result<Object> {
678        let request = Request::new(Method::GET, ["secure-links".to_owned(), link_id.to_owned()]);
679        self.client.json(&self.options, request).await
680    }
681
682    /// Change a secure link's expiry or view cap
683    ///
684    /// `PATCH /api/v2/secure-links/{linkId}`
685    pub async fn update(
686        &self,
687        link_id: &str,
688        body: Option<SecureLinksUpdateRequest>,
689    ) -> Result<Object> {
690        let request = Request::new(
691            Method::PATCH,
692            ["secure-links".to_owned(), link_id.to_owned()],
693        )
694        .json(json_body(&body.unwrap_or_default(), None)?);
695        self.client.json(&self.options, request).await
696    }
697
698    /// Revoke a secure link
699    ///
700    /// `POST /api/v2/secure-links/{linkId}/revoke`
701    pub async fn revoke(&self, link_id: &str, body: SecureLinksRevokeRequest) -> Result<Object> {
702        let request = Request::new(
703            Method::POST,
704            [
705                "secure-links".to_owned(),
706                link_id.to_owned(),
707                "revoke".to_owned(),
708            ],
709        )
710        .json(json_body(&body, None)?);
711        self.client.json(&self.options, request).await
712    }
713
714    /// Point a secure link at another version
715    ///
716    /// `POST /api/v2/secure-links/{linkId}/version`
717    pub async fn version(&self, link_id: &str, body: SecureLinksVersionRequest) -> Result<Object> {
718        let request = Request::new(
719            Method::POST,
720            [
721                "secure-links".to_owned(),
722                link_id.to_owned(),
723                "version".to_owned(),
724            ],
725        )
726        .json(json_body(&body, None)?);
727        self.client.json(&self.options, request).await
728    }
729
730    /// List a secure link's named recipients
731    ///
732    /// `GET /api/v2/secure-links/{linkId}/recipients`
733    pub async fn recipients_list(&self, link_id: &str) -> Result<Object> {
734        let request = Request::new(
735            Method::GET,
736            [
737                "secure-links".to_owned(),
738                link_id.to_owned(),
739                "recipients".to_owned(),
740            ],
741        );
742        self.client.json(&self.options, request).await
743    }
744
745    /// Add named recipients to a secure link
746    ///
747    /// `POST /api/v2/secure-links/{linkId}/recipients`
748    pub async fn recipients_add(
749        &self,
750        link_id: &str,
751        body: SecureLinksRecipientsAddRequest,
752    ) -> Result<Object> {
753        let request = Request::new(
754            Method::POST,
755            [
756                "secure-links".to_owned(),
757                link_id.to_owned(),
758                "recipients".to_owned(),
759            ],
760        )
761        .json(json_body(&body, None)?);
762        self.client.json(&self.options, request).await
763    }
764
765    /// Set or rotate a password link's password
766    ///
767    /// `POST /api/v2/secure-links/{linkId}/password`
768    pub async fn password(
769        &self,
770        link_id: &str,
771        body: SecureLinksPasswordRequest,
772    ) -> Result<Object> {
773        let request = Request::new(
774            Method::POST,
775            [
776                "secure-links".to_owned(),
777                link_id.to_owned(),
778                "password".to_owned(),
779            ],
780        )
781        .json(json_body(&body, None)?);
782        self.client.json(&self.options, request).await
783    }
784
785    /// List a secure link's viewer sessions
786    ///
787    /// `GET /api/v2/secure-links/{linkId}/sessions`
788    pub async fn sessions_list(&self, link_id: &str) -> Result<Object> {
789        let request = Request::new(
790            Method::GET,
791            [
792                "secure-links".to_owned(),
793                link_id.to_owned(),
794                "sessions".to_owned(),
795            ],
796        );
797        self.client.json(&self.options, request).await
798    }
799
800    /// Revoke one viewer session
801    ///
802    /// `POST /api/v2/secure-links/{linkId}/sessions/{sessionId}/revoke`
803    pub async fn sessions_revoke(
804        &self,
805        link_id: &str,
806        session_id: &str,
807        body: Option<SecureLinksSessionsRevokeRequest>,
808    ) -> Result<Object> {
809        let request = Request::new(
810            Method::POST,
811            [
812                "secure-links".to_owned(),
813                link_id.to_owned(),
814                "sessions".to_owned(),
815                session_id.to_owned(),
816                "revoke".to_owned(),
817            ],
818        )
819        .json(json_body(&body.unwrap_or_default(), None)?);
820        self.client.json(&self.options, request).await
821    }
822
823    /// Get engagement for one secure link
824    ///
825    /// `GET /api/v2/secure-links/{linkId}/analytics`
826    pub async fn analytics(&self, link_id: &str) -> Result<Object> {
827        let request = Request::new(
828            Method::GET,
829            [
830                "secure-links".to_owned(),
831                link_id.to_owned(),
832                "analytics".to_owned(),
833            ],
834        );
835        self.client.json(&self.options, request).await
836    }
837}
838
839/// The `workflow-runs` endpoints. Get it with [`Wellfriend::workflow_runs`].
840#[derive(Clone, Debug)]
841pub struct WorkflowRuns {
842    pub(crate) client: Wellfriend,
843    pub(crate) options: RequestOptions,
844}
845
846impl WorkflowRuns {
847    /// The same handle with these options for every call made through it.
848    pub fn with_options(mut self, options: RequestOptions) -> Self {
849        self.options = options;
850        self
851    }
852
853    /// Start a published workflow
854    ///
855    /// `POST /api/v2/workflows/{workflowId}/runs`
856    pub async fn create(
857        &self,
858        workflow_id: &str,
859        body: WorkflowRunsCreateRequest,
860    ) -> Result<WorkflowRun> {
861        let key = self.options.key();
862        let request = Request::new(
863            Method::POST,
864            [
865                "workflows".to_owned(),
866                workflow_id.to_owned(),
867                "runs".to_owned(),
868            ],
869        )
870        .json(json_body(&body, Some(&key))?)
871        .idempotency_key(key);
872        self.client.json_field(&self.options, request, "run").await
873    }
874
875    /// Inspect a workflow run
876    ///
877    /// `GET /api/v2/workflow-runs/{runId}`
878    pub async fn get(&self, run_id: &str) -> Result<WorkflowRun> {
879        let request = Request::new(Method::GET, ["workflow-runs".to_owned(), run_id.to_owned()]);
880        self.client.json_field(&self.options, request, "run").await
881    }
882
883    /// Cancel a workflow run
884    ///
885    /// `POST /api/v2/workflow-runs/{runId}/cancel`
886    pub async fn cancel(
887        &self,
888        run_id: &str,
889        body: WorkflowRunsCancelRequest,
890    ) -> Result<WorkflowRun> {
891        let request = Request::new(
892            Method::POST,
893            [
894                "workflow-runs".to_owned(),
895                run_id.to_owned(),
896                "cancel".to_owned(),
897            ],
898        )
899        .json(json_body(&body, None)?);
900        self.client.json_field(&self.options, request, "run").await
901    }
902
903    /// Safely replay a workflow run
904    ///
905    /// `POST /api/v2/workflow-runs/{runId}/replay`
906    pub async fn replay(
907        &self,
908        run_id: &str,
909        body: WorkflowRunsReplayRequest,
910    ) -> Result<WorkflowRun> {
911        let request = Request::new(
912            Method::POST,
913            [
914                "workflow-runs".to_owned(),
915                run_id.to_owned(),
916                "replay".to_owned(),
917            ],
918        )
919        .json(json_body(&body, None)?);
920        self.client.json_field(&self.options, request, "run").await
921    }
922}
923
924/// The `workflow-approvals` endpoints. Get it with [`Wellfriend::workflow_approvals`].
925#[derive(Clone, Debug)]
926pub struct WorkflowApprovals {
927    pub(crate) client: Wellfriend,
928    pub(crate) options: RequestOptions,
929}
930
931impl WorkflowApprovals {
932    /// The same handle with these options for every call made through it.
933    pub fn with_options(mut self, options: RequestOptions) -> Self {
934        self.options = options;
935        self
936    }
937
938    /// Decide a pending workflow approval
939    ///
940    /// `POST /api/v2/workflow-approvals/{approvalId}/decision`
941    pub async fn decide(
942        &self,
943        approval_id: &str,
944        body: WorkflowApprovalsDecideRequest,
945    ) -> Result<Object> {
946        let key = self.options.key();
947        let request = Request::new(
948            Method::POST,
949            [
950                "workflow-approvals".to_owned(),
951                approval_id.to_owned(),
952                "decision".to_owned(),
953            ],
954        )
955        .json(json_body(&body, Some(&key))?)
956        .idempotency_key(key);
957        self.client.json(&self.options, request).await
958    }
959}
960
961/// The `connectors` endpoints. Get it with [`Wellfriend::connectors`].
962#[derive(Clone, Debug)]
963pub struct Connectors {
964    pub(crate) client: Wellfriend,
965    pub(crate) options: RequestOptions,
966}
967
968impl Connectors {
969    /// The same handle with these options for every call made through it.
970    pub fn with_options(mut self, options: RequestOptions) -> Self {
971        self.options = options;
972        self
973    }
974
975    /// List connector accounts
976    ///
977    /// `GET /api/v2/connector-accounts`
978    pub async fn accounts_list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
979        let request = Request::new(Method::GET, ["connector-accounts".to_owned()])
980            .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
981            .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
982        self.client.json(&self.options, request).await
983    }
984
985    /// Every item of [`accounts_list`](Self::accounts_list), fetching further pages as the stream is read.
986    pub fn accounts_stream(&self, params: Option<ListParams>) -> PageStream<Object> {
987        let this = self.clone();
988        let params = params.unwrap_or_default();
989        crate::pagination::paginate(move |cursor| {
990            let this = this.clone();
991            let mut params = params.clone();
992            if cursor.is_some() {
993                params.cursor = cursor;
994            }
995            Box::pin(async move { this.accounts_list(Some(params)).await })
996        })
997    }
998
999    /// Test a connector connection
1000    ///
1001    /// `POST /api/v2/connector-accounts/{accountId}/test`
1002    pub async fn accounts_test(
1003        &self,
1004        account_id: &str,
1005        body: ConnectorsAccountsTestRequest,
1006    ) -> Result<Object> {
1007        let request = Request::new(
1008            Method::POST,
1009            [
1010                "connector-accounts".to_owned(),
1011                account_id.to_owned(),
1012                "test".to_owned(),
1013            ],
1014        )
1015        .json(json_body(&body, None)?);
1016        self.client.json(&self.options, request).await
1017    }
1018
1019    /// Disconnect a connector account
1020    ///
1021    /// `POST /api/v2/connector-accounts/{accountId}/disconnect`
1022    pub async fn accounts_disconnect(
1023        &self,
1024        account_id: &str,
1025        body: ConnectorsAccountsDisconnectRequest,
1026    ) -> Result<Object> {
1027        let request = Request::new(
1028            Method::POST,
1029            [
1030                "connector-accounts".to_owned(),
1031                account_id.to_owned(),
1032                "disconnect".to_owned(),
1033            ],
1034        )
1035        .json(json_body(&body, None)?);
1036        self.client.json(&self.options, request).await
1037    }
1038
1039    /// List importable provider items
1040    ///
1041    /// `GET /api/v2/connector-accounts/{accountId}/items`
1042    pub async fn items_list(
1043        &self,
1044        account_id: &str,
1045        params: Option<ListParams>,
1046    ) -> Result<Page<Object>> {
1047        let request = Request::new(
1048            Method::GET,
1049            [
1050                "connector-accounts".to_owned(),
1051                account_id.to_owned(),
1052                "items".to_owned(),
1053            ],
1054        )
1055        .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
1056        .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
1057        self.client.json(&self.options, request).await
1058    }
1059
1060    /// Every item of [`items_list`](Self::items_list), fetching further pages as the stream is read.
1061    pub fn items_stream(
1062        &self,
1063        account_id: impl Into<String>,
1064        params: Option<ListParams>,
1065    ) -> PageStream<Object> {
1066        let this = self.clone();
1067        let account_id: String = account_id.into();
1068        let params = params.unwrap_or_default();
1069        crate::pagination::paginate(move |cursor| {
1070            let this = this.clone();
1071            let account_id = account_id.clone();
1072            let mut params = params.clone();
1073            if cursor.is_some() {
1074                params.cursor = cursor;
1075            }
1076            Box::pin(async move { this.items_list(&account_id, Some(params)).await })
1077        })
1078    }
1079
1080    /// Inspect connector execution history
1081    ///
1082    /// `GET /api/v2/connector-operations`
1083    pub async fn operations_list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
1084        let request = Request::new(Method::GET, ["connector-operations".to_owned()])
1085            .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
1086            .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
1087        self.client.json(&self.options, request).await
1088    }
1089
1090    /// Every item of [`operations_list`](Self::operations_list), fetching further pages as the stream is read.
1091    pub fn operations_stream(&self, params: Option<ListParams>) -> PageStream<Object> {
1092        let this = self.clone();
1093        let params = params.unwrap_or_default();
1094        crate::pagination::paginate(move |cursor| {
1095            let this = this.clone();
1096            let mut params = params.clone();
1097            if cursor.is_some() {
1098                params.cursor = cursor;
1099            }
1100            Box::pin(async move { this.operations_list(Some(params)).await })
1101        })
1102    }
1103
1104    /// Import a provider attachment or file
1105    ///
1106    /// `POST /api/v2/connector-imports`
1107    pub async fn import(&self, body: Option<ConnectorsImportRequest>) -> Result<Object> {
1108        let request = Request::new(Method::POST, ["connector-imports".to_owned()])
1109            .json(json_body(&body.unwrap_or_default(), None)?);
1110        self.client.json(&self.options, request).await
1111    }
1112
1113    /// Send an exact secure link through a connector
1114    ///
1115    /// `POST /api/v2/connector-sends`
1116    pub async fn send(&self, body: Option<ConnectorsSendRequest>) -> Result<Object> {
1117        let request = Request::new(Method::POST, ["connector-sends".to_owned()])
1118            .json(json_body(&body.unwrap_or_default(), None)?);
1119        self.client.json(&self.options, request).await
1120    }
1121
1122    /// Export an exact immutable version to Google Drive
1123    ///
1124    /// `POST /api/v2/connector-exports`
1125    pub async fn export(&self, body: Option<ConnectorsExportRequest>) -> Result<Object> {
1126        let request = Request::new(Method::POST, ["connector-exports".to_owned()])
1127            .json(json_body(&body.unwrap_or_default(), None)?);
1128        self.client.json(&self.options, request).await
1129    }
1130
1131    /// Create a generic HTTP connection
1132    ///
1133    /// `POST /api/v2/generic-http-connections`
1134    pub async fn generic_create(&self, body: ConnectorsGenericCreateRequest) -> Result<Object> {
1135        let key = self.options.key();
1136        let request = Request::new(Method::POST, ["generic-http-connections".to_owned()])
1137            .json(json_body(&body, Some(&key))?)
1138            .idempotency_key(key);
1139        self.client.json(&self.options, request).await
1140    }
1141
1142    /// Receive an authenticated Generic HTTP trigger
1143    ///
1144    /// `POST /api/v2/generic-http-triggers/{accountId}`
1145    pub async fn generic_trigger(
1146        &self,
1147        account_id: &str,
1148        body: ConnectorsGenericTriggerRequest,
1149    ) -> Result<Object> {
1150        let request = Request::new(
1151            Method::POST,
1152            ["generic-http-triggers".to_owned(), account_id.to_owned()],
1153        )
1154        .json(json_body(&body, None)?);
1155        self.client.json(&self.options, request).await
1156    }
1157}
1158
1159/// The `templates` endpoints. Get it with [`Wellfriend::templates`].
1160#[derive(Clone, Debug)]
1161pub struct Templates {
1162    pub(crate) client: Wellfriend,
1163    pub(crate) options: RequestOptions,
1164}
1165
1166impl Templates {
1167    /// The same handle with these options for every call made through it.
1168    pub fn with_options(mut self, options: RequestOptions) -> Self {
1169        self.options = options;
1170        self
1171    }
1172
1173    /// List templates
1174    ///
1175    /// `GET /api/v2/templates`
1176    pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
1177        let request = Request::new(Method::GET, ["templates".to_owned()])
1178            .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
1179            .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
1180        self.client.json(&self.options, request).await
1181    }
1182
1183    /// Every item of [`list`](Self::list), fetching further pages as the stream is read.
1184    pub fn stream(&self, params: Option<ListParams>) -> PageStream<Object> {
1185        let this = self.clone();
1186        let params = params.unwrap_or_default();
1187        crate::pagination::paginate(move |cursor| {
1188            let this = this.clone();
1189            let mut params = params.clone();
1190            if cursor.is_some() {
1191                params.cursor = cursor;
1192            }
1193            Box::pin(async move { this.list(Some(params)).await })
1194        })
1195    }
1196
1197    /// Create templates
1198    ///
1199    /// `POST /api/v2/templates`
1200    pub async fn create(&self, body: TemplatesCreateRequest) -> Result<Object> {
1201        let key = self.options.key();
1202        let request = Request::new(Method::POST, ["templates".to_owned()])
1203            .json(json_body(&body, Some(&key))?)
1204            .idempotency_key(key);
1205        self.client.json(&self.options, request).await
1206    }
1207
1208    /// Get templates
1209    ///
1210    /// `GET /api/v2/templates/{resourceId}`
1211    pub async fn get(&self, resource_id: &str) -> Result<Object> {
1212        let request = Request::new(
1213            Method::GET,
1214            ["templates".to_owned(), resource_id.to_owned()],
1215        );
1216        self.client.json(&self.options, request).await
1217    }
1218
1219    /// Update templates
1220    ///
1221    /// `PATCH /api/v2/templates/{resourceId}`
1222    pub async fn update(&self, resource_id: &str, body: TemplatesUpdateRequest) -> Result<Object> {
1223        let request = Request::new(
1224            Method::PATCH,
1225            ["templates".to_owned(), resource_id.to_owned()],
1226        )
1227        .json(json_body(&body, None)?);
1228        self.client.json(&self.options, request).await
1229    }
1230
1231    /// Transition templates
1232    ///
1233    /// `POST /api/v2/templates/{resourceId}/actions`
1234    pub async fn transition(
1235        &self,
1236        resource_id: &str,
1237        body: TemplatesTransitionRequest,
1238    ) -> Result<Object> {
1239        let key = self.options.key();
1240        let request = Request::new(
1241            Method::POST,
1242            [
1243                "templates".to_owned(),
1244                resource_id.to_owned(),
1245                "actions".to_owned(),
1246            ],
1247        )
1248        .json(json_body(&body, Some(&key))?)
1249        .idempotency_key(key);
1250        self.client.json(&self.options, request).await
1251    }
1252}
1253
1254/// The `signature_requests` endpoints. Get it with [`Wellfriend::signature_requests`].
1255#[derive(Clone, Debug)]
1256pub struct SignatureRequests {
1257    pub(crate) client: Wellfriend,
1258    pub(crate) options: RequestOptions,
1259}
1260
1261impl SignatureRequests {
1262    /// The same handle with these options for every call made through it.
1263    pub fn with_options(mut self, options: RequestOptions) -> Self {
1264        self.options = options;
1265        self
1266    }
1267
1268    /// List signature requests
1269    ///
1270    /// `GET /api/v2/signature-requests`
1271    pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
1272        let request = Request::new(Method::GET, ["signature-requests".to_owned()])
1273            .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
1274            .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
1275        self.client.json(&self.options, request).await
1276    }
1277
1278    /// Every item of [`list`](Self::list), fetching further pages as the stream is read.
1279    pub fn stream(&self, params: Option<ListParams>) -> PageStream<Object> {
1280        let this = self.clone();
1281        let params = params.unwrap_or_default();
1282        crate::pagination::paginate(move |cursor| {
1283            let this = this.clone();
1284            let mut params = params.clone();
1285            if cursor.is_some() {
1286                params.cursor = cursor;
1287            }
1288            Box::pin(async move { this.list(Some(params)).await })
1289        })
1290    }
1291
1292    /// Create signature requests
1293    ///
1294    /// `POST /api/v2/signature-requests`
1295    pub async fn create(&self, body: SignatureRequestsCreateRequest) -> Result<Object> {
1296        let key = self.options.key();
1297        let request = Request::new(Method::POST, ["signature-requests".to_owned()])
1298            .json(json_body(&body, Some(&key))?)
1299            .idempotency_key(key);
1300        self.client.json(&self.options, request).await
1301    }
1302
1303    /// Get signature requests
1304    ///
1305    /// `GET /api/v2/signature-requests/{resourceId}`
1306    pub async fn get(&self, resource_id: &str) -> Result<Object> {
1307        let request = Request::new(
1308            Method::GET,
1309            ["signature-requests".to_owned(), resource_id.to_owned()],
1310        );
1311        self.client.json(&self.options, request).await
1312    }
1313
1314    /// Update signature requests
1315    ///
1316    /// `PATCH /api/v2/signature-requests/{resourceId}`
1317    pub async fn update(
1318        &self,
1319        resource_id: &str,
1320        body: SignatureRequestsUpdateRequest,
1321    ) -> Result<Object> {
1322        let request = Request::new(
1323            Method::PATCH,
1324            ["signature-requests".to_owned(), resource_id.to_owned()],
1325        )
1326        .json(json_body(&body, None)?);
1327        self.client.json(&self.options, request).await
1328    }
1329
1330    /// Transition signature requests
1331    ///
1332    /// `POST /api/v2/signature-requests/{resourceId}/actions`
1333    pub async fn transition(
1334        &self,
1335        resource_id: &str,
1336        body: SignatureRequestsTransitionRequest,
1337    ) -> Result<Object> {
1338        let key = self.options.key();
1339        let request = Request::new(
1340            Method::POST,
1341            [
1342                "signature-requests".to_owned(),
1343                resource_id.to_owned(),
1344                "actions".to_owned(),
1345            ],
1346        )
1347        .json(json_body(&body, Some(&key))?)
1348        .idempotency_key(key);
1349        self.client.json(&self.options, request).await
1350    }
1351}
1352
1353/// The `annotations` endpoints. Get it with [`Wellfriend::annotations`].
1354#[derive(Clone, Debug)]
1355pub struct Annotations {
1356    pub(crate) client: Wellfriend,
1357    pub(crate) options: RequestOptions,
1358}
1359
1360impl Annotations {
1361    /// The same handle with these options for every call made through it.
1362    pub fn with_options(mut self, options: RequestOptions) -> Self {
1363        self.options = options;
1364        self
1365    }
1366
1367    /// List annotations
1368    ///
1369    /// `GET /api/v2/annotations`
1370    pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
1371        let request = Request::new(Method::GET, ["annotations".to_owned()])
1372            .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
1373            .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
1374        self.client.json(&self.options, request).await
1375    }
1376
1377    /// Every item of [`list`](Self::list), fetching further pages as the stream is read.
1378    pub fn stream(&self, params: Option<ListParams>) -> PageStream<Object> {
1379        let this = self.clone();
1380        let params = params.unwrap_or_default();
1381        crate::pagination::paginate(move |cursor| {
1382            let this = this.clone();
1383            let mut params = params.clone();
1384            if cursor.is_some() {
1385                params.cursor = cursor;
1386            }
1387            Box::pin(async move { this.list(Some(params)).await })
1388        })
1389    }
1390
1391    /// Create annotations
1392    ///
1393    /// `POST /api/v2/annotations`
1394    pub async fn create(&self, body: AnnotationsCreateRequest) -> Result<Object> {
1395        let key = self.options.key();
1396        let request = Request::new(Method::POST, ["annotations".to_owned()])
1397            .json(json_body(&body, Some(&key))?)
1398            .idempotency_key(key);
1399        self.client.json(&self.options, request).await
1400    }
1401
1402    /// Get annotations
1403    ///
1404    /// `GET /api/v2/annotations/{resourceId}`
1405    pub async fn get(&self, resource_id: &str) -> Result<Object> {
1406        let request = Request::new(
1407            Method::GET,
1408            ["annotations".to_owned(), resource_id.to_owned()],
1409        );
1410        self.client.json(&self.options, request).await
1411    }
1412
1413    /// Update annotations
1414    ///
1415    /// `PATCH /api/v2/annotations/{resourceId}`
1416    pub async fn update(
1417        &self,
1418        resource_id: &str,
1419        body: AnnotationsUpdateRequest,
1420    ) -> Result<Object> {
1421        let request = Request::new(
1422            Method::PATCH,
1423            ["annotations".to_owned(), resource_id.to_owned()],
1424        )
1425        .json(json_body(&body, None)?);
1426        self.client.json(&self.options, request).await
1427    }
1428
1429    /// Transition annotations
1430    ///
1431    /// `POST /api/v2/annotations/{resourceId}/actions`
1432    pub async fn transition(
1433        &self,
1434        resource_id: &str,
1435        body: AnnotationsTransitionRequest,
1436    ) -> Result<Object> {
1437        let key = self.options.key();
1438        let request = Request::new(
1439            Method::POST,
1440            [
1441                "annotations".to_owned(),
1442                resource_id.to_owned(),
1443                "actions".to_owned(),
1444            ],
1445        )
1446        .json(json_body(&body, Some(&key))?)
1447        .idempotency_key(key);
1448        self.client.json(&self.options, request).await
1449    }
1450}
1451
1452/// The `forms` endpoints. Get it with [`Wellfriend::forms`].
1453#[derive(Clone, Debug)]
1454pub struct Forms {
1455    pub(crate) client: Wellfriend,
1456    pub(crate) options: RequestOptions,
1457}
1458
1459impl Forms {
1460    /// The same handle with these options for every call made through it.
1461    pub fn with_options(mut self, options: RequestOptions) -> Self {
1462        self.options = options;
1463        self
1464    }
1465
1466    /// List forms
1467    ///
1468    /// `GET /api/v2/forms`
1469    pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
1470        let request = Request::new(Method::GET, ["forms".to_owned()])
1471            .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
1472            .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
1473        self.client.json(&self.options, request).await
1474    }
1475
1476    /// Every item of [`list`](Self::list), fetching further pages as the stream is read.
1477    pub fn stream(&self, params: Option<ListParams>) -> PageStream<Object> {
1478        let this = self.clone();
1479        let params = params.unwrap_or_default();
1480        crate::pagination::paginate(move |cursor| {
1481            let this = this.clone();
1482            let mut params = params.clone();
1483            if cursor.is_some() {
1484                params.cursor = cursor;
1485            }
1486            Box::pin(async move { this.list(Some(params)).await })
1487        })
1488    }
1489
1490    /// Create forms
1491    ///
1492    /// `POST /api/v2/forms`
1493    pub async fn create(&self, body: FormsCreateRequest) -> Result<Object> {
1494        let key = self.options.key();
1495        let request = Request::new(Method::POST, ["forms".to_owned()])
1496            .json(json_body(&body, Some(&key))?)
1497            .idempotency_key(key);
1498        self.client.json(&self.options, request).await
1499    }
1500
1501    /// Get forms
1502    ///
1503    /// `GET /api/v2/forms/{resourceId}`
1504    pub async fn get(&self, resource_id: &str) -> Result<Object> {
1505        let request = Request::new(Method::GET, ["forms".to_owned(), resource_id.to_owned()]);
1506        self.client.json(&self.options, request).await
1507    }
1508
1509    /// Update forms
1510    ///
1511    /// `PATCH /api/v2/forms/{resourceId}`
1512    pub async fn update(&self, resource_id: &str, body: FormsUpdateRequest) -> Result<Object> {
1513        let request = Request::new(Method::PATCH, ["forms".to_owned(), resource_id.to_owned()])
1514            .json(json_body(&body, None)?);
1515        self.client.json(&self.options, request).await
1516    }
1517
1518    /// Transition forms
1519    ///
1520    /// `POST /api/v2/forms/{resourceId}/actions`
1521    pub async fn transition(
1522        &self,
1523        resource_id: &str,
1524        body: FormsTransitionRequest,
1525    ) -> Result<Object> {
1526        let key = self.options.key();
1527        let request = Request::new(
1528            Method::POST,
1529            [
1530                "forms".to_owned(),
1531                resource_id.to_owned(),
1532                "actions".to_owned(),
1533            ],
1534        )
1535        .json(json_body(&body, Some(&key))?)
1536        .idempotency_key(key);
1537        self.client.json(&self.options, request).await
1538    }
1539}
1540
1541/// The `deal_rooms` endpoints. Get it with [`Wellfriend::deal_rooms`].
1542#[derive(Clone, Debug)]
1543pub struct DealRooms {
1544    pub(crate) client: Wellfriend,
1545    pub(crate) options: RequestOptions,
1546}
1547
1548impl DealRooms {
1549    /// The same handle with these options for every call made through it.
1550    pub fn with_options(mut self, options: RequestOptions) -> Self {
1551        self.options = options;
1552        self
1553    }
1554
1555    /// List deal rooms
1556    ///
1557    /// `GET /api/v2/deal-rooms`
1558    pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
1559        let request = Request::new(Method::GET, ["deal-rooms".to_owned()])
1560            .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
1561            .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
1562        self.client.json(&self.options, request).await
1563    }
1564
1565    /// Every item of [`list`](Self::list), fetching further pages as the stream is read.
1566    pub fn stream(&self, params: Option<ListParams>) -> PageStream<Object> {
1567        let this = self.clone();
1568        let params = params.unwrap_or_default();
1569        crate::pagination::paginate(move |cursor| {
1570            let this = this.clone();
1571            let mut params = params.clone();
1572            if cursor.is_some() {
1573                params.cursor = cursor;
1574            }
1575            Box::pin(async move { this.list(Some(params)).await })
1576        })
1577    }
1578
1579    /// Create deal rooms
1580    ///
1581    /// `POST /api/v2/deal-rooms`
1582    pub async fn create(&self, body: DealRoomsCreateRequest) -> Result<Object> {
1583        let key = self.options.key();
1584        let request = Request::new(Method::POST, ["deal-rooms".to_owned()])
1585            .json(json_body(&body, Some(&key))?)
1586            .idempotency_key(key);
1587        self.client.json(&self.options, request).await
1588    }
1589
1590    /// Get deal rooms
1591    ///
1592    /// `GET /api/v2/deal-rooms/{resourceId}`
1593    pub async fn get(&self, resource_id: &str) -> Result<Object> {
1594        let request = Request::new(
1595            Method::GET,
1596            ["deal-rooms".to_owned(), resource_id.to_owned()],
1597        );
1598        self.client.json(&self.options, request).await
1599    }
1600
1601    /// Update deal rooms
1602    ///
1603    /// `PATCH /api/v2/deal-rooms/{resourceId}`
1604    pub async fn update(&self, resource_id: &str, body: DealRoomsUpdateRequest) -> Result<Object> {
1605        let request = Request::new(
1606            Method::PATCH,
1607            ["deal-rooms".to_owned(), resource_id.to_owned()],
1608        )
1609        .json(json_body(&body, None)?);
1610        self.client.json(&self.options, request).await
1611    }
1612
1613    /// Transition deal rooms
1614    ///
1615    /// `POST /api/v2/deal-rooms/{resourceId}/actions`
1616    pub async fn transition(
1617        &self,
1618        resource_id: &str,
1619        body: DealRoomsTransitionRequest,
1620    ) -> Result<Object> {
1621        let key = self.options.key();
1622        let request = Request::new(
1623            Method::POST,
1624            [
1625                "deal-rooms".to_owned(),
1626                resource_id.to_owned(),
1627                "actions".to_owned(),
1628            ],
1629        )
1630        .json(json_body(&body, Some(&key))?)
1631        .idempotency_key(key);
1632        self.client.json(&self.options, request).await
1633    }
1634}
1635
1636/// The `embeds` endpoints. Get it with [`Wellfriend::embeds`].
1637#[derive(Clone, Debug)]
1638pub struct Embeds {
1639    pub(crate) client: Wellfriend,
1640    pub(crate) options: RequestOptions,
1641}
1642
1643impl Embeds {
1644    /// The same handle with these options for every call made through it.
1645    pub fn with_options(mut self, options: RequestOptions) -> Self {
1646        self.options = options;
1647        self
1648    }
1649
1650    /// List embeds
1651    ///
1652    /// `GET /api/v2/embeds`
1653    pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
1654        let request = Request::new(Method::GET, ["embeds".to_owned()])
1655            .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
1656            .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
1657        self.client.json(&self.options, request).await
1658    }
1659
1660    /// Every item of [`list`](Self::list), fetching further pages as the stream is read.
1661    pub fn stream(&self, params: Option<ListParams>) -> PageStream<Object> {
1662        let this = self.clone();
1663        let params = params.unwrap_or_default();
1664        crate::pagination::paginate(move |cursor| {
1665            let this = this.clone();
1666            let mut params = params.clone();
1667            if cursor.is_some() {
1668                params.cursor = cursor;
1669            }
1670            Box::pin(async move { this.list(Some(params)).await })
1671        })
1672    }
1673
1674    /// Create embeds
1675    ///
1676    /// `POST /api/v2/embeds`
1677    pub async fn create(&self, body: EmbedsCreateRequest) -> Result<Object> {
1678        let key = self.options.key();
1679        let request = Request::new(Method::POST, ["embeds".to_owned()])
1680            .json(json_body(&body, Some(&key))?)
1681            .idempotency_key(key);
1682        self.client.json(&self.options, request).await
1683    }
1684
1685    /// Get embeds
1686    ///
1687    /// `GET /api/v2/embeds/{resourceId}`
1688    pub async fn get(&self, resource_id: &str) -> Result<Object> {
1689        let request = Request::new(Method::GET, ["embeds".to_owned(), resource_id.to_owned()]);
1690        self.client.json(&self.options, request).await
1691    }
1692
1693    /// Update embeds
1694    ///
1695    /// `PATCH /api/v2/embeds/{resourceId}`
1696    pub async fn update(&self, resource_id: &str, body: EmbedsUpdateRequest) -> Result<Object> {
1697        let request = Request::new(Method::PATCH, ["embeds".to_owned(), resource_id.to_owned()])
1698            .json(json_body(&body, None)?);
1699        self.client.json(&self.options, request).await
1700    }
1701
1702    /// Transition embeds
1703    ///
1704    /// `POST /api/v2/embeds/{resourceId}/actions`
1705    pub async fn transition(
1706        &self,
1707        resource_id: &str,
1708        body: EmbedsTransitionRequest,
1709    ) -> Result<Object> {
1710        let key = self.options.key();
1711        let request = Request::new(
1712            Method::POST,
1713            [
1714                "embeds".to_owned(),
1715                resource_id.to_owned(),
1716                "actions".to_owned(),
1717            ],
1718        )
1719        .json(json_body(&body, Some(&key))?)
1720        .idempotency_key(key);
1721        self.client.json(&self.options, request).await
1722    }
1723}
1724
1725/// The `document-versions` endpoints. Get it with [`Wellfriend::document_versions`].
1726#[derive(Clone, Debug)]
1727pub struct DocumentVersions {
1728    pub(crate) client: Wellfriend,
1729    pub(crate) options: RequestOptions,
1730}
1731
1732impl DocumentVersions {
1733    /// The same handle with these options for every call made through it.
1734    pub fn with_options(mut self, options: RequestOptions) -> Self {
1735        self.options = options;
1736        self
1737    }
1738
1739    /// List immutable document versions
1740    ///
1741    /// `GET /api/v2/documents/{documentId}/versions`
1742    pub async fn list(
1743        &self,
1744        document_id: &str,
1745        params: Option<ListParams>,
1746    ) -> Result<Page<DocumentVersion>> {
1747        let request = Request::new(
1748            Method::GET,
1749            [
1750                "documents".to_owned(),
1751                document_id.to_owned(),
1752                "versions".to_owned(),
1753            ],
1754        )
1755        .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
1756        .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
1757        self.client.json(&self.options, request).await
1758    }
1759
1760    /// Every item of [`list`](Self::list), fetching further pages as the stream is read.
1761    pub fn stream(
1762        &self,
1763        document_id: impl Into<String>,
1764        params: Option<ListParams>,
1765    ) -> PageStream<DocumentVersion> {
1766        let this = self.clone();
1767        let document_id: String = document_id.into();
1768        let params = params.unwrap_or_default();
1769        crate::pagination::paginate(move |cursor| {
1770            let this = this.clone();
1771            let document_id = document_id.clone();
1772            let mut params = params.clone();
1773            if cursor.is_some() {
1774                params.cursor = cursor;
1775            }
1776            Box::pin(async move { this.list(&document_id, Some(params)).await })
1777        })
1778    }
1779
1780    /// Get an immutable document version
1781    ///
1782    /// `GET /api/v2/documents/{documentId}/versions/{versionId}`
1783    pub async fn get(&self, document_id: &str, version_id: &str) -> Result<DocumentVersion> {
1784        let request = Request::new(
1785            Method::GET,
1786            [
1787                "documents".to_owned(),
1788                document_id.to_owned(),
1789                "versions".to_owned(),
1790                version_id.to_owned(),
1791            ],
1792        );
1793        self.client.json(&self.options, request).await
1794    }
1795
1796    /// Download exact immutable document bytes
1797    ///
1798    /// `GET /api/v2/documents/{documentId}/versions/{versionId}/content`
1799    pub async fn download(&self, document_id: &str, version_id: &str) -> Result<Download> {
1800        let request = Request::new(
1801            Method::GET,
1802            [
1803                "documents".to_owned(),
1804                document_id.to_owned(),
1805                "versions".to_owned(),
1806                version_id.to_owned(),
1807                "content".to_owned(),
1808            ],
1809        );
1810        Ok(Download::new(
1811            self.client.send(&self.options, request).await?,
1812        ))
1813    }
1814
1815    /// Render one page of a version as a PNG or WebP image
1816    ///
1817    /// `GET /api/v2/documents/{documentId}/versions/{versionId}/pages/{page}/render`
1818    pub async fn render_page(
1819        &self,
1820        document_id: &str,
1821        version_id: &str,
1822        page: &str,
1823    ) -> Result<Download> {
1824        let request = Request::new(
1825            Method::GET,
1826            [
1827                "documents".to_owned(),
1828                document_id.to_owned(),
1829                "versions".to_owned(),
1830                version_id.to_owned(),
1831                "pages".to_owned(),
1832                page.to_owned(),
1833                "render".to_owned(),
1834            ],
1835        );
1836        Ok(Download::new(
1837            self.client.send(&self.options, request).await?,
1838        ))
1839    }
1840}
1841
1842/// The `document-analytics` endpoints. Get it with [`Wellfriend::document_analytics`].
1843#[derive(Clone, Debug)]
1844pub struct DocumentAnalytics {
1845    pub(crate) client: Wellfriend,
1846    pub(crate) options: RequestOptions,
1847}
1848
1849impl DocumentAnalytics {
1850    /// The same handle with these options for every call made through it.
1851    pub fn with_options(mut self, options: RequestOptions) -> Self {
1852        self.options = options;
1853        self
1854    }
1855
1856    /// Get document engagement analytics
1857    ///
1858    /// `GET /api/v2/documents/{documentId}/analytics`
1859    pub async fn get(&self, document_id: &str) -> Result<Object> {
1860        let request = Request::new(
1861            Method::GET,
1862            [
1863                "documents".to_owned(),
1864                document_id.to_owned(),
1865                "analytics".to_owned(),
1866            ],
1867        );
1868        self.client.json(&self.options, request).await
1869    }
1870}
1871
1872/// The `keys` endpoints. Get it with [`Wellfriend::keys`].
1873#[derive(Clone, Debug)]
1874pub struct Keys {
1875    pub(crate) client: Wellfriend,
1876    pub(crate) options: RequestOptions,
1877}
1878
1879impl Keys {
1880    /// The same handle with these options for every call made through it.
1881    pub fn with_options(mut self, options: RequestOptions) -> Self {
1882        self.options = options;
1883        self
1884    }
1885
1886    /// List API keys
1887    ///
1888    /// `GET /api/v2/keys`
1889    pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
1890        let request = Request::new(Method::GET, ["keys".to_owned()])
1891            .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
1892            .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
1893        self.client.json(&self.options, request).await
1894    }
1895
1896    /// Every item of [`list`](Self::list), fetching further pages as the stream is read.
1897    pub fn stream(&self, params: Option<ListParams>) -> PageStream<Object> {
1898        let this = self.clone();
1899        let params = params.unwrap_or_default();
1900        crate::pagination::paginate(move |cursor| {
1901            let this = this.clone();
1902            let mut params = params.clone();
1903            if cursor.is_some() {
1904                params.cursor = cursor;
1905            }
1906            Box::pin(async move { this.list(Some(params)).await })
1907        })
1908    }
1909
1910    /// Create an API key
1911    ///
1912    /// `POST /api/v2/keys`
1913    pub async fn create(&self, body: KeysCreateRequest) -> Result<Object> {
1914        let request = Request::new(Method::POST, ["keys".to_owned()]).json(json_body(&body, None)?);
1915        self.client.json(&self.options, request).await
1916    }
1917
1918    /// Revoke an API key
1919    ///
1920    /// `POST /api/v2/keys/{keyId}/revoke`
1921    pub async fn revoke(&self, key_id: &str, body: KeysRevokeRequest) -> Result<Object> {
1922        let request = Request::new(
1923            Method::POST,
1924            ["keys".to_owned(), key_id.to_owned(), "revoke".to_owned()],
1925        )
1926        .json(json_body(&body, None)?);
1927        self.client.json(&self.options, request).await
1928    }
1929
1930    /// Rotate an API key
1931    ///
1932    /// `POST /api/v2/keys/{keyId}/rotate`
1933    pub async fn rotate(&self, key_id: &str, body: KeysRotateRequest) -> Result<Object> {
1934        let request = Request::new(
1935            Method::POST,
1936            ["keys".to_owned(), key_id.to_owned(), "rotate".to_owned()],
1937        )
1938        .json(json_body(&body, None)?);
1939        self.client.json(&self.options, request).await
1940    }
1941}
1942
1943/// The `usage` endpoints. Get it with [`Wellfriend::usage`].
1944#[derive(Clone, Debug)]
1945pub struct Usage {
1946    pub(crate) client: Wellfriend,
1947    pub(crate) options: RequestOptions,
1948}
1949
1950impl Usage {
1951    /// The same handle with these options for every call made through it.
1952    pub fn with_options(mut self, options: RequestOptions) -> Self {
1953        self.options = options;
1954        self
1955    }
1956
1957    /// Get metered API usage
1958    ///
1959    /// `GET /api/v2/usage`
1960    pub async fn get(&self) -> Result<Object> {
1961        let request = Request::new(Method::GET, ["usage".to_owned()]);
1962        self.client.json(&self.options, request).await
1963    }
1964}
1965
1966/// The `logs` endpoints. Get it with [`Wellfriend::logs`].
1967#[derive(Clone, Debug)]
1968pub struct Logs {
1969    pub(crate) client: Wellfriend,
1970    pub(crate) options: RequestOptions,
1971}
1972
1973impl Logs {
1974    /// The same handle with these options for every call made through it.
1975    pub fn with_options(mut self, options: RequestOptions) -> Self {
1976        self.options = options;
1977        self
1978    }
1979
1980    /// List execution logs
1981    ///
1982    /// `GET /api/v2/logs`
1983    pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
1984        let request = Request::new(Method::GET, ["logs".to_owned()])
1985            .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
1986            .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
1987        self.client.json(&self.options, request).await
1988    }
1989
1990    /// Every item of [`list`](Self::list), fetching further pages as the stream is read.
1991    pub fn stream(&self, params: Option<ListParams>) -> PageStream<Object> {
1992        let this = self.clone();
1993        let params = params.unwrap_or_default();
1994        crate::pagination::paginate(move |cursor| {
1995            let this = this.clone();
1996            let mut params = params.clone();
1997            if cursor.is_some() {
1998                params.cursor = cursor;
1999            }
2000            Box::pin(async move { this.list(Some(params)).await })
2001        })
2002    }
2003}
2004
2005/// The `rooms` endpoints. Get it with [`Wellfriend::rooms`].
2006#[derive(Clone, Debug)]
2007pub struct Rooms {
2008    pub(crate) client: Wellfriend,
2009    pub(crate) options: RequestOptions,
2010}
2011
2012impl Rooms {
2013    /// The same handle with these options for every call made through it.
2014    pub fn with_options(mut self, options: RequestOptions) -> Self {
2015        self.options = options;
2016        self
2017    }
2018
2019    /// List rooms
2020    ///
2021    /// `GET /api/v2/rooms`
2022    pub async fn list(&self) -> Result<Object> {
2023        let request = Request::new(Method::GET, ["rooms".to_owned()]);
2024        self.client.json(&self.options, request).await
2025    }
2026
2027    /// Create a room
2028    ///
2029    /// `POST /api/v2/rooms`
2030    pub async fn create(&self, body: RoomsCreateRequest) -> Result<Object> {
2031        let request =
2032            Request::new(Method::POST, ["rooms".to_owned()]).json(json_body(&body, None)?);
2033        self.client.json(&self.options, request).await
2034    }
2035
2036    /// Get a room
2037    ///
2038    /// `GET /api/v2/rooms/{roomId}`
2039    pub async fn get(&self, room_id: &str) -> Result<Object> {
2040        let request = Request::new(Method::GET, ["rooms".to_owned(), room_id.to_owned()]);
2041        self.client.json(&self.options, request).await
2042    }
2043
2044    /// Get a room's folders, documents, participants, questions and requests
2045    ///
2046    /// `GET /api/v2/rooms/{roomId}/contents`
2047    pub async fn contents(&self, room_id: &str) -> Result<Object> {
2048        let request = Request::new(
2049            Method::GET,
2050            [
2051                "rooms".to_owned(),
2052                room_id.to_owned(),
2053                "contents".to_owned(),
2054            ],
2055        );
2056        self.client.json(&self.options, request).await
2057    }
2058
2059    /// Move a room through its lifecycle
2060    ///
2061    /// `POST /api/v2/rooms/{roomId}/actions`
2062    pub async fn transition(&self, room_id: &str, body: RoomsTransitionRequest) -> Result<Object> {
2063        let request = Request::new(
2064            Method::POST,
2065            ["rooms".to_owned(), room_id.to_owned(), "actions".to_owned()],
2066        )
2067        .json(json_body(&body, None)?);
2068        self.client.json(&self.options, request).await
2069    }
2070
2071    /// Create a room folder
2072    ///
2073    /// `POST /api/v2/rooms/{roomId}/folders`
2074    pub async fn folders_create(
2075        &self,
2076        room_id: &str,
2077        body: RoomsFoldersCreateRequest,
2078    ) -> Result<Object> {
2079        let request = Request::new(
2080            Method::POST,
2081            ["rooms".to_owned(), room_id.to_owned(), "folders".to_owned()],
2082        )
2083        .json(json_body(&body, None)?);
2084        self.client.json(&self.options, request).await
2085    }
2086
2087    /// Rename or move a room folder
2088    ///
2089    /// `PATCH /api/v2/rooms/{roomId}/folders/{folderId}`
2090    pub async fn folders_update(
2091        &self,
2092        room_id: &str,
2093        folder_id: &str,
2094        body: Option<RoomsFoldersUpdateRequest>,
2095    ) -> Result<Object> {
2096        let request = Request::new(
2097            Method::PATCH,
2098            [
2099                "rooms".to_owned(),
2100                room_id.to_owned(),
2101                "folders".to_owned(),
2102                folder_id.to_owned(),
2103            ],
2104        )
2105        .json(json_body(&body.unwrap_or_default(), None)?);
2106        self.client.json(&self.options, request).await
2107    }
2108
2109    /// Add a document version to a room folder
2110    ///
2111    /// `POST /api/v2/rooms/{roomId}/documents`
2112    pub async fn documents_add(
2113        &self,
2114        room_id: &str,
2115        body: RoomsDocumentsAddRequest,
2116    ) -> Result<Object> {
2117        let request = Request::new(
2118            Method::POST,
2119            [
2120                "rooms".to_owned(),
2121                room_id.to_owned(),
2122                "documents".to_owned(),
2123            ],
2124        )
2125        .json(json_body(&body, None)?);
2126        self.client.json(&self.options, request).await
2127    }
2128
2129    /// Rename or move a room document
2130    ///
2131    /// `PATCH /api/v2/rooms/{roomId}/documents/{roomDocumentId}`
2132    pub async fn documents_update(
2133        &self,
2134        room_id: &str,
2135        room_document_id: &str,
2136        body: Option<RoomsDocumentsUpdateRequest>,
2137    ) -> Result<Object> {
2138        let request = Request::new(
2139            Method::PATCH,
2140            [
2141                "rooms".to_owned(),
2142                room_id.to_owned(),
2143                "documents".to_owned(),
2144                room_document_id.to_owned(),
2145            ],
2146        )
2147        .json(json_body(&body.unwrap_or_default(), None)?);
2148        self.client.json(&self.options, request).await
2149    }
2150
2151    /// Invite a participant to a room
2152    ///
2153    /// `POST /api/v2/rooms/{roomId}/participants`
2154    pub async fn participants_add(
2155        &self,
2156        room_id: &str,
2157        body: RoomsParticipantsAddRequest,
2158    ) -> Result<Object> {
2159        let request = Request::new(
2160            Method::POST,
2161            [
2162                "rooms".to_owned(),
2163                room_id.to_owned(),
2164                "participants".to_owned(),
2165            ],
2166        )
2167        .json(json_body(&body, None)?);
2168        self.client.json(&self.options, request).await
2169    }
2170
2171    /// Revoke or restore a room participant
2172    ///
2173    /// `PATCH /api/v2/rooms/{roomId}/participants/{participantId}`
2174    pub async fn participants_update(
2175        &self,
2176        room_id: &str,
2177        participant_id: &str,
2178        body: RoomsParticipantsUpdateRequest,
2179    ) -> Result<Object> {
2180        let request = Request::new(
2181            Method::PATCH,
2182            [
2183                "rooms".to_owned(),
2184                room_id.to_owned(),
2185                "participants".to_owned(),
2186                participant_id.to_owned(),
2187            ],
2188        )
2189        .json(json_body(&body, None)?);
2190        self.client.json(&self.options, request).await
2191    }
2192
2193    /// Set a room access rule
2194    ///
2195    /// `POST /api/v2/rooms/{roomId}/permissions`
2196    pub async fn permissions_set(
2197        &self,
2198        room_id: &str,
2199        body: RoomsPermissionsSetRequest,
2200    ) -> Result<Object> {
2201        let request = Request::new(
2202            Method::POST,
2203            [
2204                "rooms".to_owned(),
2205                room_id.to_owned(),
2206                "permissions".to_owned(),
2207            ],
2208        )
2209        .json(json_body(&body, None)?);
2210        self.client.json(&self.options, request).await
2211    }
2212
2213    /// Revoke a room access rule
2214    ///
2215    /// `DELETE /api/v2/rooms/{roomId}/permissions/{permissionId}`
2216    pub async fn permissions_revoke(
2217        &self,
2218        room_id: &str,
2219        permission_id: &str,
2220        body: Option<RoomsPermissionsRevokeRequest>,
2221    ) -> Result<Object> {
2222        let request = Request::new(
2223            Method::DELETE,
2224            [
2225                "rooms".to_owned(),
2226                room_id.to_owned(),
2227                "permissions".to_owned(),
2228                permission_id.to_owned(),
2229            ],
2230        )
2231        .json(json_body(&body.unwrap_or_default(), None)?);
2232        self.client.json(&self.options, request).await
2233    }
2234
2235    /// Create a document request
2236    ///
2237    /// `POST /api/v2/rooms/{roomId}/requests`
2238    pub async fn requests_create(
2239        &self,
2240        room_id: &str,
2241        body: RoomsRequestsCreateRequest,
2242    ) -> Result<Object> {
2243        let request = Request::new(
2244            Method::POST,
2245            [
2246                "rooms".to_owned(),
2247                room_id.to_owned(),
2248                "requests".to_owned(),
2249            ],
2250        )
2251        .json(json_body(&body, None)?);
2252        self.client.json(&self.options, request).await
2253    }
2254
2255    /// Ask a question in a room
2256    ///
2257    /// `POST /api/v2/rooms/{roomId}/questions`
2258    pub async fn questions_create(
2259        &self,
2260        room_id: &str,
2261        body: RoomsQuestionsCreateRequest,
2262    ) -> Result<Object> {
2263        let request = Request::new(
2264            Method::POST,
2265            [
2266                "rooms".to_owned(),
2267                room_id.to_owned(),
2268                "questions".to_owned(),
2269            ],
2270        )
2271        .json(json_body(&body, None)?);
2272        self.client.json(&self.options, request).await
2273    }
2274
2275    /// Answer a room question
2276    ///
2277    /// `POST /api/v2/rooms/{roomId}/questions/{questionId}/answers`
2278    pub async fn questions_answer(
2279        &self,
2280        room_id: &str,
2281        question_id: &str,
2282        body: RoomsQuestionsAnswerRequest,
2283    ) -> Result<Object> {
2284        let request = Request::new(
2285            Method::POST,
2286            [
2287                "rooms".to_owned(),
2288                room_id.to_owned(),
2289                "questions".to_owned(),
2290                question_id.to_owned(),
2291                "answers".to_owned(),
2292            ],
2293        )
2294        .json(json_body(&body, None)?);
2295        self.client.json(&self.options, request).await
2296    }
2297
2298    /// Get engagement across a room
2299    ///
2300    /// `GET /api/v2/rooms/{roomId}/analytics`
2301    pub async fn analytics(&self, room_id: &str) -> Result<Object> {
2302        let request = Request::new(
2303            Method::GET,
2304            [
2305                "rooms".to_owned(),
2306                room_id.to_owned(),
2307                "analytics".to_owned(),
2308            ],
2309        );
2310        self.client.json(&self.options, request).await
2311    }
2312}
2313
2314/// The `portals` endpoints. Get it with [`Wellfriend::portals`].
2315#[derive(Clone, Debug)]
2316pub struct Portals {
2317    pub(crate) client: Wellfriend,
2318    pub(crate) options: RequestOptions,
2319}
2320
2321impl Portals {
2322    /// The same handle with these options for every call made through it.
2323    pub fn with_options(mut self, options: RequestOptions) -> Self {
2324        self.options = options;
2325        self
2326    }
2327
2328    /// List portals
2329    ///
2330    /// `GET /api/v2/portals`
2331    pub async fn list(&self) -> Result<Object> {
2332        let request = Request::new(Method::GET, ["portals".to_owned()]);
2333        self.client.json(&self.options, request).await
2334    }
2335
2336    /// Create a portal
2337    ///
2338    /// `POST /api/v2/portals`
2339    pub async fn create(&self, body: PortalsCreateRequest) -> Result<Object> {
2340        let request =
2341            Request::new(Method::POST, ["portals".to_owned()]).json(json_body(&body, None)?);
2342        self.client.json(&self.options, request).await
2343    }
2344
2345    /// Get a portal
2346    ///
2347    /// `GET /api/v2/portals/{portalId}`
2348    pub async fn get(&self, portal_id: &str) -> Result<Object> {
2349        let request = Request::new(Method::GET, ["portals".to_owned(), portal_id.to_owned()]);
2350        self.client.json(&self.options, request).await
2351    }
2352
2353    /// Change a portal's name, branding or navigation
2354    ///
2355    /// `PATCH /api/v2/portals/{portalId}`
2356    pub async fn update(
2357        &self,
2358        portal_id: &str,
2359        body: Option<PortalsUpdateRequest>,
2360    ) -> Result<Object> {
2361        let request = Request::new(Method::PATCH, ["portals".to_owned(), portal_id.to_owned()])
2362            .json(json_body(&body.unwrap_or_default(), None)?);
2363        self.client.json(&self.options, request).await
2364    }
2365
2366    /// Publish a portal
2367    ///
2368    /// `POST /api/v2/portals/{portalId}/actions`
2369    pub async fn publish(
2370        &self,
2371        portal_id: &str,
2372        body: Option<PortalsPublishRequest>,
2373    ) -> Result<Object> {
2374        let request = Request::new(
2375            Method::POST,
2376            [
2377                "portals".to_owned(),
2378                portal_id.to_owned(),
2379                "actions".to_owned(),
2380            ],
2381        )
2382        .json(json_body(&body.unwrap_or_default(), None)?);
2383        self.client.json(&self.options, request).await
2384    }
2385
2386    /// List a room in a portal
2387    ///
2388    /// `POST /api/v2/portals/{portalId}/rooms`
2389    pub async fn rooms_add(&self, portal_id: &str, body: PortalsRoomsAddRequest) -> Result<Object> {
2390        let request = Request::new(
2391            Method::POST,
2392            [
2393                "portals".to_owned(),
2394                portal_id.to_owned(),
2395                "rooms".to_owned(),
2396            ],
2397        )
2398        .json(json_body(&body, None)?);
2399        self.client.json(&self.options, request).await
2400    }
2401
2402    /// Post a portal announcement
2403    ///
2404    /// `POST /api/v2/portals/{portalId}/announcements`
2405    pub async fn announcements_create(
2406        &self,
2407        portal_id: &str,
2408        body: PortalsAnnouncementsCreateRequest,
2409    ) -> Result<Object> {
2410        let request = Request::new(
2411            Method::POST,
2412            [
2413                "portals".to_owned(),
2414                portal_id.to_owned(),
2415                "announcements".to_owned(),
2416            ],
2417        )
2418        .json(json_body(&body, None)?);
2419        self.client.json(&self.options, request).await
2420    }
2421
2422    /// Add a portal resource
2423    ///
2424    /// `POST /api/v2/portals/{portalId}/resources`
2425    pub async fn resources_create(
2426        &self,
2427        portal_id: &str,
2428        body: PortalsResourcesCreateRequest,
2429    ) -> Result<Object> {
2430        let request = Request::new(
2431            Method::POST,
2432            [
2433                "portals".to_owned(),
2434                portal_id.to_owned(),
2435                "resources".to_owned(),
2436            ],
2437        )
2438        .json(json_body(&body, None)?);
2439        self.client.json(&self.options, request).await
2440    }
2441
2442    /// Get engagement across a portal's rooms
2443    ///
2444    /// `GET /api/v2/portals/{portalId}/analytics`
2445    pub async fn analytics(&self, portal_id: &str) -> Result<Object> {
2446        let request = Request::new(
2447            Method::GET,
2448            [
2449                "portals".to_owned(),
2450                portal_id.to_owned(),
2451                "analytics".to_owned(),
2452            ],
2453        );
2454        self.client.json(&self.options, request).await
2455    }
2456}
2457
2458/// The `embed-sessions` endpoints. Get it with [`Wellfriend::embed_sessions`].
2459#[derive(Clone, Debug)]
2460pub struct EmbedSessions {
2461    pub(crate) client: Wellfriend,
2462    pub(crate) options: RequestOptions,
2463}
2464
2465impl EmbedSessions {
2466    /// The same handle with these options for every call made through it.
2467    pub fn with_options(mut self, options: RequestOptions) -> Self {
2468        self.options = options;
2469        self
2470    }
2471
2472    /// Create a short-lived embed session
2473    ///
2474    /// `POST /api/v2/embed-sessions`
2475    pub async fn create(&self, body: EmbedSessionsCreateRequest) -> Result<Object> {
2476        let request =
2477            Request::new(Method::POST, ["embed-sessions".to_owned()]).json(json_body(&body, None)?);
2478        self.client.json(&self.options, request).await
2479    }
2480
2481    /// Get an embed session
2482    ///
2483    /// `GET /api/v2/embed-sessions/{sessionId}`
2484    pub async fn get(&self, session_id: &str) -> Result<Object> {
2485        let request = Request::new(
2486            Method::GET,
2487            ["embed-sessions".to_owned(), session_id.to_owned()],
2488        );
2489        self.client.json(&self.options, request).await
2490    }
2491
2492    /// Extend an active embed session
2493    ///
2494    /// `POST /api/v2/embed-sessions/{sessionId}/refresh`
2495    pub async fn refresh(
2496        &self,
2497        session_id: &str,
2498        body: Option<EmbedSessionsRefreshRequest>,
2499    ) -> Result<Object> {
2500        let request = Request::new(
2501            Method::POST,
2502            [
2503                "embed-sessions".to_owned(),
2504                session_id.to_owned(),
2505                "refresh".to_owned(),
2506            ],
2507        )
2508        .json(json_body(&body.unwrap_or_default(), None)?);
2509        self.client.json(&self.options, request).await
2510    }
2511
2512    /// End an embed session now
2513    ///
2514    /// `POST /api/v2/embed-sessions/{sessionId}/revoke`
2515    pub async fn revoke(
2516        &self,
2517        session_id: &str,
2518        body: Option<EmbedSessionsRevokeRequest>,
2519    ) -> Result<Object> {
2520        let request = Request::new(
2521            Method::POST,
2522            [
2523                "embed-sessions".to_owned(),
2524                session_id.to_owned(),
2525                "revoke".to_owned(),
2526            ],
2527        )
2528        .json(json_body(&body.unwrap_or_default(), None)?);
2529        self.client.json(&self.options, request).await
2530    }
2531}
2532
2533/// The `esign` endpoints. Get it with [`Wellfriend::esign`].
2534#[derive(Clone, Debug)]
2535pub struct Esign {
2536    pub(crate) client: Wellfriend,
2537    pub(crate) options: RequestOptions,
2538}
2539
2540impl Esign {
2541    /// The same handle with these options for every call made through it.
2542    pub fn with_options(mut self, options: RequestOptions) -> Self {
2543        self.options = options;
2544        self
2545    }
2546
2547    /// Get e-signature levels, jurisdictions and document types
2548    ///
2549    /// `GET /api/v2/esign/levels`
2550    pub async fn levels(&self) -> Result<EsignLevelsResponse> {
2551        let request = Request::new(Method::GET, ["esign".to_owned(), "levels".to_owned()]);
2552        self.client.json(&self.options, request).await
2553    }
2554
2555    /// List e-signature envelopes
2556    ///
2557    /// `GET /api/v2/esign/envelopes`
2558    pub async fn envelopes_list(
2559        &self,
2560        params: Option<EsignEnvelopesListParams>,
2561    ) -> Result<Page<EsignEnvelopesListItem>> {
2562        let request = Request::new(Method::GET, ["esign".to_owned(), "envelopes".to_owned()])
2563            .query(
2564                "documentId",
2565                params.as_ref().and_then(|p| p.document_id.as_ref()),
2566            )
2567            .query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
2568            .query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
2569        self.client.json(&self.options, request).await
2570    }
2571
2572    /// Every item of [`envelopes_list`](Self::envelopes_list), fetching further pages as the stream is read.
2573    pub fn envelopes_stream(
2574        &self,
2575        params: Option<EsignEnvelopesListParams>,
2576    ) -> PageStream<EsignEnvelopesListItem> {
2577        let this = self.clone();
2578        let params = params.unwrap_or_default();
2579        crate::pagination::paginate(move |cursor| {
2580            let this = this.clone();
2581            let mut params = params.clone();
2582            if cursor.is_some() {
2583                params.cursor = cursor;
2584            }
2585            Box::pin(async move { this.envelopes_list(Some(params)).await })
2586        })
2587    }
2588
2589    /// Send a document for e-signature
2590    ///
2591    /// `POST /api/v2/esign/envelopes`
2592    pub async fn envelopes_create(
2593        &self,
2594        body: EsignEnvelopesCreateRequest,
2595    ) -> Result<EsignEnvelopesCreateResponse> {
2596        let key = self.options.key();
2597        let request = Request::new(Method::POST, ["esign".to_owned(), "envelopes".to_owned()])
2598            .json(json_body(&body, Some(&key))?)
2599            .idempotency_key(key);
2600        self.client.json(&self.options, request).await
2601    }
2602
2603    /// Get an e-signature envelope
2604    ///
2605    /// `GET /api/v2/esign/envelopes/{envelopeId}`
2606    pub async fn envelopes_get(&self, envelope_id: &str) -> Result<EsignEnvelopesGetResponse> {
2607        let request = Request::new(
2608            Method::GET,
2609            [
2610                "esign".to_owned(),
2611                "envelopes".to_owned(),
2612                envelope_id.to_owned(),
2613            ],
2614        );
2615        self.client.json(&self.options, request).await
2616    }
2617
2618    /// Cancel an e-signature envelope
2619    ///
2620    /// `POST /api/v2/esign/envelopes/{envelopeId}/cancel`
2621    pub async fn envelopes_cancel(
2622        &self,
2623        envelope_id: &str,
2624        body: Option<EsignEnvelopesCancelRequest>,
2625    ) -> Result<EsignEnvelopesGetResponse> {
2626        let request = Request::new(
2627            Method::POST,
2628            [
2629                "esign".to_owned(),
2630                "envelopes".to_owned(),
2631                envelope_id.to_owned(),
2632                "cancel".to_owned(),
2633            ],
2634        )
2635        .json(json_body(&body.unwrap_or_default(), None)?);
2636        self.client.json(&self.options, request).await
2637    }
2638
2639    /// Download the certificate of completion
2640    ///
2641    /// `GET /api/v2/esign/envelopes/{envelopeId}/certificate`
2642    pub async fn envelopes_certificate(&self, envelope_id: &str) -> Result<Download> {
2643        let request = Request::new(
2644            Method::GET,
2645            [
2646                "esign".to_owned(),
2647                "envelopes".to_owned(),
2648                envelope_id.to_owned(),
2649                "certificate".to_owned(),
2650            ],
2651        );
2652        Ok(Download::new(
2653            self.client.send(&self.options, request).await?,
2654        ))
2655    }
2656
2657    /// Validate the signatures in a PDF
2658    ///
2659    /// `POST /api/v2/esign/validate`
2660    pub async fn validate(&self, input: impl Into<FileInput>) -> Result<EsignValidateResponse> {
2661        let request = Request::new(Method::POST, ["esign".to_owned(), "validate".to_owned()])
2662            .body(crate::uploads::file_body(input.into(), "application/pdf").await?);
2663        self.client.json(&self.options, request).await
2664    }
2665}
2666
2667impl Wellfriend {
2668    /// The `platform` endpoints.
2669    pub fn platform(&self) -> Platform {
2670        Platform {
2671            client: self.clone(),
2672            options: RequestOptions::default(),
2673        }
2674    }
2675
2676    /// The `pricing` endpoints.
2677    pub fn pricing(&self) -> Pricing {
2678        Pricing {
2679            client: self.clone(),
2680            options: RequestOptions::default(),
2681        }
2682    }
2683
2684    /// The `workflows` endpoints.
2685    pub fn workflows(&self) -> Workflows {
2686        Workflows {
2687            client: self.clone(),
2688            options: RequestOptions::default(),
2689        }
2690    }
2691
2692    /// The `documents` endpoints.
2693    pub fn documents(&self) -> Documents {
2694        Documents {
2695            client: self.clone(),
2696            options: RequestOptions::default(),
2697        }
2698    }
2699
2700    /// The `uploads` endpoints.
2701    pub fn uploads(&self) -> Uploads {
2702        Uploads {
2703            client: self.clone(),
2704            options: RequestOptions::default(),
2705        }
2706    }
2707
2708    /// The `document-operations` endpoints.
2709    pub fn document_operations(&self) -> DocumentOperations {
2710        DocumentOperations {
2711            client: self.clone(),
2712            options: RequestOptions::default(),
2713        }
2714    }
2715
2716    /// The `secure-links` endpoints.
2717    pub fn secure_links(&self) -> SecureLinks {
2718        SecureLinks {
2719            client: self.clone(),
2720            options: RequestOptions::default(),
2721        }
2722    }
2723
2724    /// The `workflow-runs` endpoints.
2725    pub fn workflow_runs(&self) -> WorkflowRuns {
2726        WorkflowRuns {
2727            client: self.clone(),
2728            options: RequestOptions::default(),
2729        }
2730    }
2731
2732    /// The `workflow-approvals` endpoints.
2733    pub fn workflow_approvals(&self) -> WorkflowApprovals {
2734        WorkflowApprovals {
2735            client: self.clone(),
2736            options: RequestOptions::default(),
2737        }
2738    }
2739
2740    /// The `connectors` endpoints.
2741    pub fn connectors(&self) -> Connectors {
2742        Connectors {
2743            client: self.clone(),
2744            options: RequestOptions::default(),
2745        }
2746    }
2747
2748    /// The `templates` endpoints.
2749    pub fn templates(&self) -> Templates {
2750        Templates {
2751            client: self.clone(),
2752            options: RequestOptions::default(),
2753        }
2754    }
2755
2756    /// The `signature_requests` endpoints.
2757    pub fn signature_requests(&self) -> SignatureRequests {
2758        SignatureRequests {
2759            client: self.clone(),
2760            options: RequestOptions::default(),
2761        }
2762    }
2763
2764    /// The `annotations` endpoints.
2765    pub fn annotations(&self) -> Annotations {
2766        Annotations {
2767            client: self.clone(),
2768            options: RequestOptions::default(),
2769        }
2770    }
2771
2772    /// The `forms` endpoints.
2773    pub fn forms(&self) -> Forms {
2774        Forms {
2775            client: self.clone(),
2776            options: RequestOptions::default(),
2777        }
2778    }
2779
2780    /// The `deal_rooms` endpoints.
2781    pub fn deal_rooms(&self) -> DealRooms {
2782        DealRooms {
2783            client: self.clone(),
2784            options: RequestOptions::default(),
2785        }
2786    }
2787
2788    /// The `embeds` endpoints.
2789    pub fn embeds(&self) -> Embeds {
2790        Embeds {
2791            client: self.clone(),
2792            options: RequestOptions::default(),
2793        }
2794    }
2795
2796    /// The `document-versions` endpoints.
2797    pub fn document_versions(&self) -> DocumentVersions {
2798        DocumentVersions {
2799            client: self.clone(),
2800            options: RequestOptions::default(),
2801        }
2802    }
2803
2804    /// The `document-analytics` endpoints.
2805    pub fn document_analytics(&self) -> DocumentAnalytics {
2806        DocumentAnalytics {
2807            client: self.clone(),
2808            options: RequestOptions::default(),
2809        }
2810    }
2811
2812    /// The `keys` endpoints.
2813    pub fn keys(&self) -> Keys {
2814        Keys {
2815            client: self.clone(),
2816            options: RequestOptions::default(),
2817        }
2818    }
2819
2820    /// The `usage` endpoints.
2821    pub fn usage(&self) -> Usage {
2822        Usage {
2823            client: self.clone(),
2824            options: RequestOptions::default(),
2825        }
2826    }
2827
2828    /// The `logs` endpoints.
2829    pub fn logs(&self) -> Logs {
2830        Logs {
2831            client: self.clone(),
2832            options: RequestOptions::default(),
2833        }
2834    }
2835
2836    /// The `rooms` endpoints.
2837    pub fn rooms(&self) -> Rooms {
2838        Rooms {
2839            client: self.clone(),
2840            options: RequestOptions::default(),
2841        }
2842    }
2843
2844    /// The `portals` endpoints.
2845    pub fn portals(&self) -> Portals {
2846        Portals {
2847            client: self.clone(),
2848            options: RequestOptions::default(),
2849        }
2850    }
2851
2852    /// The `embed-sessions` endpoints.
2853    pub fn embed_sessions(&self) -> EmbedSessions {
2854        EmbedSessions {
2855            client: self.clone(),
2856            options: RequestOptions::default(),
2857        }
2858    }
2859
2860    /// The `esign` endpoints.
2861    pub fn esign(&self) -> Esign {
2862        Esign {
2863            client: self.clone(),
2864            options: RequestOptions::default(),
2865        }
2866    }
2867}