Skip to main content

hanzo_client/apis/
esign_api.rs

1/*
2 * Hanzo Cloud API
3 *
4 * The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
5 *
6 * The version of the OpenAPI document: v1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`get_esign_documents`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetEsignDocumentsError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`get_esign_documents_by_id`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetEsignDocumentsByIdError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_esign_documents_by_id_audit`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetEsignDocumentsByIdAuditError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`get_esign_documents_by_id_download`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetEsignDocumentsByIdDownloadError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`get_esign_health`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetEsignHealthError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`get_esign_oby_org_sign_by_token`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetEsignObyOrgSignByTokenError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`post_esign_documents`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum PostEsignDocumentsError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`post_esign_documents_by_id_fields`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum PostEsignDocumentsByIdFieldsError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`post_esign_documents_by_id_recipients`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum PostEsignDocumentsByIdRecipientsError {
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`post_esign_documents_by_id_send`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum PostEsignDocumentsByIdSendError {
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`post_esign_oby_org_sign_by_token_complete`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum PostEsignObyOrgSignByTokenCompleteError {
92    UnknownValue(serde_json::Value),
93}
94
95/// struct for typed errors of method [`post_esign_oby_org_sign_by_token_fields_by_fieldid`]
96#[derive(Debug, Clone, Serialize, Deserialize)]
97#[serde(untagged)]
98pub enum PostEsignObyOrgSignByTokenFieldsByFieldidError {
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`post_esign_oby_org_sign_by_token_reject`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum PostEsignObyOrgSignByTokenRejectError {
106    UnknownValue(serde_json::Value),
107}
108
109
110/// Returns your org's documents, newest first.  Each carries its status, recipients and field layout. The listing is capped at 200 and there is no paging, so treat it as the recent window rather than a complete export. It reads the caller's own tenant store, so no other org's documents can appear in it.
111pub async fn get_esign_documents(configuration: &configuration::Configuration, ) -> Result<models::EsignDocuments, Error<GetEsignDocumentsError>> {
112
113    let uri_str = format!("{}/v1/esign/documents", configuration.base_path);
114    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
115
116    if let Some(ref user_agent) = configuration.user_agent {
117        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
118    }
119    if let Some(ref token) = configuration.bearer_access_token {
120        req_builder = req_builder.bearer_auth(token.to_owned());
121    };
122
123    let req = req_builder.build()?;
124    let resp = configuration.client.execute(req).await?;
125
126    let status = resp.status();
127    let content_type = resp
128        .headers()
129        .get("content-type")
130        .and_then(|v| v.to_str().ok())
131        .unwrap_or("application/octet-stream");
132    let content_type = super::ContentType::from(content_type);
133
134    if !status.is_client_error() && !status.is_server_error() {
135        let content = resp.text().await?;
136        match content_type {
137            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
138            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EsignDocuments`"))),
139            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EsignDocuments`")))),
140        }
141    } else {
142        let content = resp.text().await?;
143        let entity: Option<GetEsignDocumentsError> = serde_json::from_str(&content).ok();
144        Err(Error::ResponseError(ResponseContent { status, content, entity }))
145    }
146}
147
148/// Returns one document with its recipients and field layout.  It answers the document, its recipients with each one's read and signing status, and every field with its type, page and position — the view a sender's UI renders, and where the field ids come from. The id is resolved in the caller's OWN tenant store, so another org's document id is a 404 rather than a refusal that would confirm it exists.
149pub async fn get_esign_documents_by_id(configuration: &configuration::Configuration, id: &str) -> Result<models::EsignDocument, Error<GetEsignDocumentsByIdError>> {
150    // add a prefix to parameters to efficiently prevent name collisions
151    let p_id = id;
152
153    let uri_str = format!("{}/v1/esign/documents/{id}", configuration.base_path, id=crate::apis::urlencode(p_id));
154    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
155
156    if let Some(ref user_agent) = configuration.user_agent {
157        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
158    }
159    if let Some(ref token) = configuration.bearer_access_token {
160        req_builder = req_builder.bearer_auth(token.to_owned());
161    };
162
163    let req = req_builder.build()?;
164    let resp = configuration.client.execute(req).await?;
165
166    let status = resp.status();
167    let content_type = resp
168        .headers()
169        .get("content-type")
170        .and_then(|v| v.to_str().ok())
171        .unwrap_or("application/octet-stream");
172    let content_type = super::ContentType::from(content_type);
173
174    if !status.is_client_error() && !status.is_server_error() {
175        let content = resp.text().await?;
176        match content_type {
177            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
178            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EsignDocument`"))),
179            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EsignDocument`")))),
180        }
181    } else {
182        let content = resp.text().await?;
183        let entity: Option<GetEsignDocumentsByIdError> = serde_json::from_str(&content).ok();
184        Err(Error::ResponseError(ResponseContent { status, content, entity }))
185    }
186}
187
188/// Returns the document's full audit trail, oldest first.  It answers every recorded event for the document in order — created, recipient added, field created, sent, opened, each field inserted, each recipient completed or rejected, and completion — with the actor and timestamp on each. This is the evidence record behind a signature, so it is append-only and nothing in the surface edits it.  The id is resolved in the caller's OWN tenant store, so another org's document id is a 404.
189pub async fn get_esign_documents_by_id_audit(configuration: &configuration::Configuration, id: &str) -> Result<models::EsignTrail, Error<GetEsignDocumentsByIdAuditError>> {
190    // add a prefix to parameters to efficiently prevent name collisions
191    let p_id = id;
192
193    let uri_str = format!("{}/v1/esign/documents/{id}/audit", configuration.base_path, id=crate::apis::urlencode(p_id));
194    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
195
196    if let Some(ref user_agent) = configuration.user_agent {
197        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
198    }
199    if let Some(ref token) = configuration.bearer_access_token {
200        req_builder = req_builder.bearer_auth(token.to_owned());
201    };
202
203    let req = req_builder.build()?;
204    let resp = configuration.client.execute(req).await?;
205
206    let status = resp.status();
207    let content_type = resp
208        .headers()
209        .get("content-type")
210        .and_then(|v| v.to_str().ok())
211        .unwrap_or("application/octet-stream");
212    let content_type = super::ContentType::from(content_type);
213
214    if !status.is_client_error() && !status.is_server_error() {
215        let content = resp.text().await?;
216        match content_type {
217            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
218            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EsignTrail`"))),
219            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EsignTrail`")))),
220        }
221    } else {
222        let content = resp.text().await?;
223        let entity: Option<GetEsignDocumentsByIdAuditError> = serde_json::from_str(&content).ok();
224        Err(Error::ResponseError(ResponseContent { status, content, entity }))
225    }
226}
227
228/// Returns the document — the sealed PDF once it is complete.  It answers the document's current PDF as base64 with a sealed flag and a filename. Before completion that is the original upload; once every signer has finished it is the SEALED artifact, with the field values rendered onto the page and a real x509 PKCS#7 digital signature applied. There is one pdfBase64 field either way, so sealed is what tells you which you are holding.  The id is resolved in the caller's OWN tenant store, so another org's document id is a 404.
229pub async fn get_esign_documents_by_id_download(configuration: &configuration::Configuration, id: &str) -> Result<models::EsignPdf, Error<GetEsignDocumentsByIdDownloadError>> {
230    // add a prefix to parameters to efficiently prevent name collisions
231    let p_id = id;
232
233    let uri_str = format!("{}/v1/esign/documents/{id}/download", configuration.base_path, id=crate::apis::urlencode(p_id));
234    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
235
236    if let Some(ref user_agent) = configuration.user_agent {
237        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
238    }
239    if let Some(ref token) = configuration.bearer_access_token {
240        req_builder = req_builder.bearer_auth(token.to_owned());
241    };
242
243    let req = req_builder.build()?;
244    let resp = configuration.client.execute(req).await?;
245
246    let status = resp.status();
247    let content_type = resp
248        .headers()
249        .get("content-type")
250        .and_then(|v| v.to_str().ok())
251        .unwrap_or("application/octet-stream");
252    let content_type = super::ContentType::from(content_type);
253
254    if !status.is_client_error() && !status.is_server_error() {
255        let content = resp.text().await?;
256        match content_type {
257            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
258            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EsignPdf`"))),
259            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EsignPdf`")))),
260        }
261    } else {
262        let content = resp.text().await?;
263        let entity: Option<GetEsignDocumentsByIdDownloadError> = serde_json::from_str(&content).ok();
264        Err(Error::ResponseError(ResponseContent { status, content, entity }))
265    }
266}
267
268/// Reports whether the e-signature surface is mounted.  It answers ok whenever the subsystem is mounted, takes no tenant and needs no principal. It is deliberately shallow: it is registered before the document host is built, so it still answers on a deployment that came up WITHOUT object storage and therefore serves nothing else. Read it as reachability, never as a promise that documents can be stored.
269pub async fn get_esign_health(configuration: &configuration::Configuration, ) -> Result<models::EsignHealth, Error<GetEsignHealthError>> {
270
271    let uri_str = format!("{}/v1/esign/health", configuration.base_path);
272    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
273
274    if let Some(ref user_agent) = configuration.user_agent {
275        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
276    }
277    if let Some(ref token) = configuration.bearer_access_token {
278        req_builder = req_builder.bearer_auth(token.to_owned());
279    };
280
281    let req = req_builder.build()?;
282    let resp = configuration.client.execute(req).await?;
283
284    let status = resp.status();
285    let content_type = resp
286        .headers()
287        .get("content-type")
288        .and_then(|v| v.to_str().ok())
289        .unwrap_or("application/octet-stream");
290    let content_type = super::ContentType::from(content_type);
291
292    if !status.is_client_error() && !status.is_server_error() {
293        let content = resp.text().await?;
294        match content_type {
295            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
296            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EsignHealth`"))),
297            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EsignHealth`")))),
298        }
299    } else {
300        let content = resp.text().await?;
301        let entity: Option<GetEsignHealthError> = serde_json::from_str(&content).ok();
302        Err(Error::ResponseError(ResponseContent { status, content, entity }))
303    }
304}
305
306/// Opens a document you were asked to sign, using your signing link.  It answers the document, the recipient the link identifies, the fields THAT recipient must fill, and the PDF to display. The first open also marks the recipient as having opened it and records that on the audit trail, so this read has a side effect by design.  This surface takes NO account: the signing token is the entire credential, and it names the recipient, so a signer sees only their own fields and never the other recipients' tokens. The token resolves to its owning tenant FIRST, before any per-tenant store is opened, and the org segment is only checked against that answer. An unknown or wrong-org token is one and the same 404, never a hint that some other document exists.
307pub async fn get_esign_oby_org_sign_by_token(configuration: &configuration::Configuration, org: &str, token: &str) -> Result<models::EsignSession, Error<GetEsignObyOrgSignByTokenError>> {
308    // add a prefix to parameters to efficiently prevent name collisions
309    let p_org = org;
310    let p_token = token;
311
312    let uri_str = format!("{}/v1/esign/o/{org}/sign/{token}", configuration.base_path, org=crate::apis::urlencode(p_org), token=crate::apis::urlencode(p_token));
313    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
314
315    if let Some(ref user_agent) = configuration.user_agent {
316        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
317    }
318    if let Some(ref token) = configuration.bearer_access_token {
319        req_builder = req_builder.bearer_auth(token.to_owned());
320    };
321
322    let req = req_builder.build()?;
323    let resp = configuration.client.execute(req).await?;
324
325    let status = resp.status();
326    let content_type = resp
327        .headers()
328        .get("content-type")
329        .and_then(|v| v.to_str().ok())
330        .unwrap_or("application/octet-stream");
331    let content_type = super::ContentType::from(content_type);
332
333    if !status.is_client_error() && !status.is_server_error() {
334        let content = resp.text().await?;
335        match content_type {
336            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
337            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EsignSession`"))),
338            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EsignSession`")))),
339        }
340    } else {
341        let content = resp.text().await?;
342        let entity: Option<GetEsignObyOrgSignByTokenError> = serde_json::from_str(&content).ok();
343        Err(Error::ResponseError(ResponseContent { status, content, entity }))
344    }
345}
346
347/// Uploads a PDF and opens a draft ready for recipients and fields.  It answers 201 with the document in DRAFT — the state where recipients and fields may still be added, and the only state they may. The bytes go to object storage rather than into the tenant database, and the original is kept under its own key so it survives sealing untouched: a completed document can always be compared against what was uploaded. Creation is recorded on the audit trail.  This is the sender's surface: a validated principal is required, and the document lands in that principal's OWN org. Isolation is physical rather than a filter — each tenant has its own store — so another org's document id is simply not there. A body over 32 MiB is refused with 413.
348pub async fn post_esign_documents(configuration: &configuration::Configuration, esign_upload_in: models::EsignUploadIn) -> Result<models::EsignDocument, Error<PostEsignDocumentsError>> {
349    // add a prefix to parameters to efficiently prevent name collisions
350    let p_esign_upload_in = esign_upload_in;
351
352    let uri_str = format!("{}/v1/esign/documents", configuration.base_path);
353    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
354
355    if let Some(ref user_agent) = configuration.user_agent {
356        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
357    }
358    if let Some(ref token) = configuration.bearer_access_token {
359        req_builder = req_builder.bearer_auth(token.to_owned());
360    };
361    req_builder = req_builder.json(&p_esign_upload_in);
362
363    let req = req_builder.build()?;
364    let resp = configuration.client.execute(req).await?;
365
366    let status = resp.status();
367    let content_type = resp
368        .headers()
369        .get("content-type")
370        .and_then(|v| v.to_str().ok())
371        .unwrap_or("application/octet-stream");
372    let content_type = super::ContentType::from(content_type);
373
374    if !status.is_client_error() && !status.is_server_error() {
375        let content = resp.text().await?;
376        match content_type {
377            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
378            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EsignDocument`"))),
379            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EsignDocument`")))),
380        }
381    } else {
382        let content = resp.text().await?;
383        let entity: Option<PostEsignDocumentsError> = serde_json::from_str(&content).ok();
384        Err(Error::ResponseError(ResponseContent { status, content, entity }))
385    }
386}
387
388/// Places a field on the page for one recipient to fill.  It adds a signature, date, name, email or text box at a page and position for ONE named recipient, and answers 201 with its id. The recipient must belong to this document; one from elsewhere is refused.  Fields are what make a recipient signable: a document cannot be sent while any signing recipient has none. Only while DRAFT — adding a field to a sent document is a 409 — and an unknown document is a 404. The addition is recorded on the audit trail.
389pub async fn post_esign_documents_by_id_fields(configuration: &configuration::Configuration, id: &str, esign_field_in: models::EsignFieldIn) -> Result<models::EsignPlacement, Error<PostEsignDocumentsByIdFieldsError>> {
390    // add a prefix to parameters to efficiently prevent name collisions
391    let p_id = id;
392    let p_esign_field_in = esign_field_in;
393
394    let uri_str = format!("{}/v1/esign/documents/{id}/fields", configuration.base_path, id=crate::apis::urlencode(p_id));
395    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
396
397    if let Some(ref user_agent) = configuration.user_agent {
398        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
399    }
400    if let Some(ref token) = configuration.bearer_access_token {
401        req_builder = req_builder.bearer_auth(token.to_owned());
402    };
403    req_builder = req_builder.json(&p_esign_field_in);
404
405    let req = req_builder.build()?;
406    let resp = configuration.client.execute(req).await?;
407
408    let status = resp.status();
409    let content_type = resp
410        .headers()
411        .get("content-type")
412        .and_then(|v| v.to_str().ok())
413        .unwrap_or("application/octet-stream");
414    let content_type = super::ContentType::from(content_type);
415
416    if !status.is_client_error() && !status.is_server_error() {
417        let content = resp.text().await?;
418        match content_type {
419            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
420            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EsignPlacement`"))),
421            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EsignPlacement`")))),
422        }
423    } else {
424        let content = resp.text().await?;
425        let entity: Option<PostEsignDocumentsByIdFieldsError> = serde_json::from_str(&content).ok();
426        Err(Error::ResponseError(ResponseContent { status, content, entity }))
427    }
428}
429
430/// Adds someone to a draft and mints their signing token.  It answers 201 with the recipient's id and their signing TOKEN — the crypto-random capability that is the only credential the signer's surface accepts — so this response is where the signing link is built from. A CC recipient is recorded as already complete, because they are never asked to sign.  Only while DRAFT: adding a recipient to a document already sent is a 409, because the field layout and the turn order were fixed when it went out. An unknown document is a 404. The addition is recorded on the audit trail.
431pub async fn post_esign_documents_by_id_recipients(configuration: &configuration::Configuration, id: &str, esign_recipient_in: models::EsignRecipientIn) -> Result<models::EsignInvite, Error<PostEsignDocumentsByIdRecipientsError>> {
432    // add a prefix to parameters to efficiently prevent name collisions
433    let p_id = id;
434    let p_esign_recipient_in = esign_recipient_in;
435
436    let uri_str = format!("{}/v1/esign/documents/{id}/recipients", configuration.base_path, id=crate::apis::urlencode(p_id));
437    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
438
439    if let Some(ref user_agent) = configuration.user_agent {
440        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
441    }
442    if let Some(ref token) = configuration.bearer_access_token {
443        req_builder = req_builder.bearer_auth(token.to_owned());
444    };
445    req_builder = req_builder.json(&p_esign_recipient_in);
446
447    let req = req_builder.build()?;
448    let resp = configuration.client.execute(req).await?;
449
450    let status = resp.status();
451    let content_type = resp
452        .headers()
453        .get("content-type")
454        .and_then(|v| v.to_str().ok())
455        .unwrap_or("application/octet-stream");
456    let content_type = super::ContentType::from(content_type);
457
458    if !status.is_client_error() && !status.is_server_error() {
459        let content = resp.text().await?;
460        match content_type {
461            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
462            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EsignInvite`"))),
463            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EsignInvite`")))),
464        }
465    } else {
466        let content = resp.text().await?;
467        let entity: Option<PostEsignDocumentsByIdRecipientsError> = serde_json::from_str(&content).ok();
468        Err(Error::ResponseError(ResponseContent { status, content, entity }))
469    }
470}
471
472/// Sends the document out and answers each signer's link.  It moves the document from DRAFT to PENDING and answers the signing tokens — one per signing recipient, with the path to hand them — which is how the links reach the people who must sign. Nothing is emailed by this call; delivering the links is the caller's.  It refuses to send an unsignable document: no recipients at all is a 400, and so is any signing recipient with no fields to fill, named in the error. Re-sending an already-pending document is allowed and re-issues the same links rather than restarting anything; a completed document is a 409, and an unknown one a 404. The send is recorded on the audit trail.
473pub async fn post_esign_documents_by_id_send(configuration: &configuration::Configuration, id: &str) -> Result<models::EsignLinks, Error<PostEsignDocumentsByIdSendError>> {
474    // add a prefix to parameters to efficiently prevent name collisions
475    let p_id = id;
476
477    let uri_str = format!("{}/v1/esign/documents/{id}/send", configuration.base_path, id=crate::apis::urlencode(p_id));
478    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
479
480    if let Some(ref user_agent) = configuration.user_agent {
481        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
482    }
483    if let Some(ref token) = configuration.bearer_access_token {
484        req_builder = req_builder.bearer_auth(token.to_owned());
485    };
486
487    let req = req_builder.build()?;
488    let resp = configuration.client.execute(req).await?;
489
490    let status = resp.status();
491    let content_type = resp
492        .headers()
493        .get("content-type")
494        .and_then(|v| v.to_str().ok())
495        .unwrap_or("application/octet-stream");
496    let content_type = super::ContentType::from(content_type);
497
498    if !status.is_client_error() && !status.is_server_error() {
499        let content = resp.text().await?;
500        match content_type {
501            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
502            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EsignLinks`"))),
503            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EsignLinks`")))),
504        }
505    } else {
506        let content = resp.text().await?;
507        let entity: Option<PostEsignDocumentsByIdSendError> = serde_json::from_str(&content).ok();
508        Err(Error::ResponseError(ResponseContent { status, content, entity }))
509    }
510}
511
512/// Finishes your signing — and seals the document if you were the last.  It marks this recipient as done and answers whether the DOCUMENT sealed with it. When every signing recipient has completed, sealing happens right here in the same call: the collected values are rendered onto the PDF, a real x509 PKCS#7 signature is applied, the sealed bytes are stored beside the untouched original, and the document moves to COMPLETED. Until then the answer is the recipient's own completion with the document still pending.  It refuses to complete a half-filled signature: a recipient with any unfilled field is a 400 naming how many remain. A document not out for signature is a 409, as is a recipient who has already completed, and under SEQUENTIAL order a signer out of turn is a 403. The token is the whole credential — no account, and a token that does not resolve under the org segment is a 404. Sealing and completion are one transaction, so a failure anywhere leaves the document exactly as it was.
513pub async fn post_esign_oby_org_sign_by_token_complete(configuration: &configuration::Configuration, org: &str, token: &str) -> Result<models::EsignCompletion, Error<PostEsignObyOrgSignByTokenCompleteError>> {
514    // add a prefix to parameters to efficiently prevent name collisions
515    let p_org = org;
516    let p_token = token;
517
518    let uri_str = format!("{}/v1/esign/o/{org}/sign/{token}/complete", configuration.base_path, org=crate::apis::urlencode(p_org), token=crate::apis::urlencode(p_token));
519    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
520
521    if let Some(ref user_agent) = configuration.user_agent {
522        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
523    }
524    if let Some(ref token) = configuration.bearer_access_token {
525        req_builder = req_builder.bearer_auth(token.to_owned());
526    };
527
528    let req = req_builder.build()?;
529    let resp = configuration.client.execute(req).await?;
530
531    let status = resp.status();
532    let content_type = resp
533        .headers()
534        .get("content-type")
535        .and_then(|v| v.to_str().ok())
536        .unwrap_or("application/octet-stream");
537    let content_type = super::ContentType::from(content_type);
538
539    if !status.is_client_error() && !status.is_server_error() {
540        let content = resp.text().await?;
541        match content_type {
542            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
543            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EsignCompletion`"))),
544            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EsignCompletion`")))),
545        }
546    } else {
547        let content = resp.text().await?;
548        let entity: Option<PostEsignObyOrgSignByTokenCompleteError> = serde_json::from_str(&content).ok();
549        Err(Error::ResponseError(ResponseContent { status, content, entity }))
550    }
551}
552
553/// Fills in one of your fields.  It records a value for one field and marks it inserted. A signature field takes a value with isBase64 true for drawn image bytes, or false for a typed signature; a date, name or email field falls back to today, the recipient's name or their email when the value is omitted; any other type requires one.  Nothing is sealed here — filling every field still leaves the document pending until the completion call. The token is the whole credential and it bounds what can be written: a field belonging to another recipient is refused with 401 even under a valid token, an unknown field is a 404, and a field already filled is a 409. A document not out for signature is a 409, as is a recipient who has already completed or rejected. Under SEQUENTIAL order a signer whose turn has not come is refused 403 until every earlier signer has signed. Each insertion is recorded on the audit trail.
554pub async fn post_esign_oby_org_sign_by_token_fields_by_fieldid(configuration: &configuration::Configuration, org: &str, token: &str, field_id: &str, esign_value_in: models::EsignValueIn) -> Result<models::EsignInsertion, Error<PostEsignObyOrgSignByTokenFieldsByFieldidError>> {
555    // add a prefix to parameters to efficiently prevent name collisions
556    let p_org = org;
557    let p_token = token;
558    let p_field_id = field_id;
559    let p_esign_value_in = esign_value_in;
560
561    let uri_str = format!("{}/v1/esign/o/{org}/sign/{token}/fields/{fieldId}", configuration.base_path, org=crate::apis::urlencode(p_org), token=crate::apis::urlencode(p_token), fieldId=crate::apis::urlencode(p_field_id));
562    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
563
564    if let Some(ref user_agent) = configuration.user_agent {
565        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
566    }
567    if let Some(ref token) = configuration.bearer_access_token {
568        req_builder = req_builder.bearer_auth(token.to_owned());
569    };
570    req_builder = req_builder.json(&p_esign_value_in);
571
572    let req = req_builder.build()?;
573    let resp = configuration.client.execute(req).await?;
574
575    let status = resp.status();
576    let content_type = resp
577        .headers()
578        .get("content-type")
579        .and_then(|v| v.to_str().ok())
580        .unwrap_or("application/octet-stream");
581    let content_type = super::ContentType::from(content_type);
582
583    if !status.is_client_error() && !status.is_server_error() {
584        let content = resp.text().await?;
585        match content_type {
586            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
587            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EsignInsertion`"))),
588            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EsignInsertion`")))),
589        }
590    } else {
591        let content = resp.text().await?;
592        let entity: Option<PostEsignObyOrgSignByTokenFieldsByFieldidError> = serde_json::from_str(&content).ok();
593        Err(Error::ResponseError(ResponseContent { status, content, entity }))
594    }
595}
596
597/// Declines to sign, with an optional reason.  It records this recipient's refusal and moves the WHOLE DOCUMENT to REJECTED — one declining signer ends it for everyone, and there is no route back: the document cannot then be signed or completed. An optional reason is stored and written onto the audit trail with the rejection, which is what the sender sees.  A document not out for signature is a 409, and so is a recipient who has already signed or already rejected — a refusal cannot be taken back or repeated. The token is the whole credential; one that does not resolve under the org segment is a 404.
598pub async fn post_esign_oby_org_sign_by_token_reject(configuration: &configuration::Configuration, org: &str, token: &str, esign_reject_in: models::EsignRejectIn) -> Result<models::EsignRejection, Error<PostEsignObyOrgSignByTokenRejectError>> {
599    // add a prefix to parameters to efficiently prevent name collisions
600    let p_org = org;
601    let p_token = token;
602    let p_esign_reject_in = esign_reject_in;
603
604    let uri_str = format!("{}/v1/esign/o/{org}/sign/{token}/reject", configuration.base_path, org=crate::apis::urlencode(p_org), token=crate::apis::urlencode(p_token));
605    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
606
607    if let Some(ref user_agent) = configuration.user_agent {
608        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
609    }
610    if let Some(ref token) = configuration.bearer_access_token {
611        req_builder = req_builder.bearer_auth(token.to_owned());
612    };
613    req_builder = req_builder.json(&p_esign_reject_in);
614
615    let req = req_builder.build()?;
616    let resp = configuration.client.execute(req).await?;
617
618    let status = resp.status();
619    let content_type = resp
620        .headers()
621        .get("content-type")
622        .and_then(|v| v.to_str().ok())
623        .unwrap_or("application/octet-stream");
624    let content_type = super::ContentType::from(content_type);
625
626    if !status.is_client_error() && !status.is_server_error() {
627        let content = resp.text().await?;
628        match content_type {
629            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
630            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EsignRejection`"))),
631            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::EsignRejection`")))),
632        }
633    } else {
634        let content = resp.text().await?;
635        let entity: Option<PostEsignObyOrgSignByTokenRejectError> = serde_json::from_str(&content).ok();
636        Err(Error::ResponseError(ResponseContent { status, content, entity }))
637    }
638}
639