#![allow(clippy::too_many_arguments)]
use reqwest::Method;
use crate::client::{json_body, Request, RequestOptions, Wellfriend};
use crate::error::Result;
#[allow(unused_imports)]
use crate::generated::models::*;
#[allow(unused_imports)]
use crate::models::*;
#[allow(unused_imports)]
use crate::webhooks::Webhooks;
#[allow(unused_imports)]
use crate::{Download, FileInput, Object, Page, PageStream};
#[derive(Clone, Debug)]
pub struct Platform {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl Platform {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn capabilities_list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
let request = Request::new(Method::GET, ["capabilities".to_owned()])
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
self.client.json(&self.options, request).await
}
pub fn capabilities_stream(&self, params: Option<ListParams>) -> PageStream<Object> {
let this = self.clone();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.capabilities_list(Some(params)).await })
})
}
}
#[derive(Clone, Debug)]
pub struct Pricing {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl Pricing {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn quote(&self, body: Option<PricingQuoteRequest>) -> Result<Quote> {
let request = Request::new(Method::POST, ["quote".to_owned()])
.json(json_body(&body.unwrap_or_default(), None)?);
self.client
.json_field(&self.options, request, "quote")
.await
}
}
#[derive(Clone, Debug)]
pub struct Workflows {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl Workflows {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn validate(&self, body: WorkflowsValidateRequest) -> Result<Object> {
let request = Request::new(
Method::POST,
["workflows".to_owned(), "validate".to_owned()],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn create(&self, body: WorkflowsCreateRequest) -> Result<Workflow> {
let key = self.options.key();
let request = Request::new(Method::POST, ["workflows".to_owned()])
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client
.json_field(&self.options, request, "workflow")
.await
}
pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Workflow>> {
let request = Request::new(Method::GET, ["workflows".to_owned()])
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
self.client.json(&self.options, request).await
}
pub fn stream(&self, params: Option<ListParams>) -> PageStream<Workflow> {
let this = self.clone();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.list(Some(params)).await })
})
}
pub async fn get(&self, workflow_id: &str) -> Result<Workflow> {
let request = Request::new(
Method::GET,
["workflows".to_owned(), workflow_id.to_owned()],
);
self.client
.json_field(&self.options, request, "workflow")
.await
}
pub async fn update(
&self,
workflow_id: &str,
body: WorkflowsUpdateRequest,
) -> Result<Workflow> {
let request = Request::new(
Method::PATCH,
["workflows".to_owned(), workflow_id.to_owned()],
)
.json(json_body(&body, None)?);
self.client
.json_field(&self.options, request, "workflow")
.await
}
pub async fn publish(
&self,
workflow_id: &str,
body: WorkflowsPublishRequest,
) -> Result<Workflow> {
let request = Request::new(
Method::POST,
[
"workflows".to_owned(),
workflow_id.to_owned(),
"publish".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client
.json_field(&self.options, request, "workflow")
.await
}
}
impl Webhooks {
pub async fn verify_remote(&self, body: Option<WebhooksVerifyRemoteRequest>) -> Result<Object> {
let request = Request::new(Method::POST, ["webhooks".to_owned(), "verify".to_owned()])
.json(json_body(&body.unwrap_or_default(), None)?);
self.client.json(&self.options, request).await
}
pub async fn endpoints_create(&self, body: WebhooksEndpointsCreateRequest) -> Result<Object> {
let key = self.options.key();
let request = Request::new(Method::POST, ["webhook-endpoints".to_owned()])
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
pub async fn endpoints_list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
let request = Request::new(Method::GET, ["webhook-endpoints".to_owned()])
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
self.client.json(&self.options, request).await
}
pub fn endpoints_stream(&self, params: Option<ListParams>) -> PageStream<Object> {
let this = self.clone();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.endpoints_list(Some(params)).await })
})
}
pub async fn endpoints_get(&self, endpoint_id: &str) -> Result<WebhooksEndpointsGetResponse> {
let request = Request::new(
Method::GET,
["webhook-endpoints".to_owned(), endpoint_id.to_owned()],
);
self.client.json(&self.options, request).await
}
pub async fn endpoints_update(
&self,
endpoint_id: &str,
body: Option<WebhooksEndpointsUpdateRequest>,
) -> Result<WebhooksEndpointsGetResponse> {
let request = Request::new(
Method::PATCH,
["webhook-endpoints".to_owned(), endpoint_id.to_owned()],
)
.json(json_body(&body.unwrap_or_default(), None)?);
self.client.json(&self.options, request).await
}
pub async fn endpoints_delete(
&self,
endpoint_id: &str,
body: WebhooksEndpointsDeleteRequest,
) -> Result<WebhooksEndpointsDeleteResponse> {
let request = Request::new(
Method::DELETE,
["webhook-endpoints".to_owned(), endpoint_id.to_owned()],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn endpoints_test(
&self,
endpoint_id: &str,
body: WebhooksEndpointsTestRequest,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"webhook-endpoints".to_owned(),
endpoint_id.to_owned(),
"test".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn deliveries_list(
&self,
params: Option<ListParams>,
) -> Result<Page<WebhooksDeliveriesListItem>> {
let request = Request::new(Method::GET, ["webhook-deliveries".to_owned()])
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
self.client.json(&self.options, request).await
}
pub fn deliveries_stream(
&self,
params: Option<ListParams>,
) -> PageStream<WebhooksDeliveriesListItem> {
let this = self.clone();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.deliveries_list(Some(params)).await })
})
}
pub async fn deliveries_replay(
&self,
delivery_id: &str,
body: Option<WebhooksDeliveriesReplayRequest>,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"webhook-deliveries".to_owned(),
delivery_id.to_owned(),
"replay".to_owned(),
],
)
.json(json_body(&body.unwrap_or_default(), None)?);
self.client.json(&self.options, request).await
}
pub async fn endpoints_rotate_secret(
&self,
endpoint_id: &str,
body: Option<WebhooksEndpointsRotateSecretRequest>,
) -> Result<WebhooksEndpointsRotateSecretResponse> {
let request = Request::new(
Method::POST,
[
"webhook-endpoints".to_owned(),
endpoint_id.to_owned(),
"rotate-secret".to_owned(),
],
)
.json(json_body(&body.unwrap_or_default(), None)?);
self.client.json(&self.options, request).await
}
pub async fn endpoints_replay(
&self,
endpoint_id: &str,
body: WebhooksEndpointsReplayRequest,
) -> Result<WebhooksEndpointsReplayResponse> {
let request = Request::new(
Method::POST,
[
"webhook-endpoints".to_owned(),
endpoint_id.to_owned(),
"replay".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn endpoints_insights(
&self,
endpoint_id: &str,
) -> Result<WebhooksEndpointsInsightsResponse> {
let request = Request::new(
Method::GET,
[
"webhook-endpoints".to_owned(),
endpoint_id.to_owned(),
"insights".to_owned(),
],
);
self.client.json(&self.options, request).await
}
pub async fn deliveries_get(&self, delivery_id: &str) -> Result<WebhooksDeliveriesGetResponse> {
let request = Request::new(
Method::GET,
["webhook-deliveries".to_owned(), delivery_id.to_owned()],
);
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct Documents {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl Documents {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn create(&self, input: impl Into<FileInput>) -> Result<Document> {
crate::uploads::upload_document(&self.client, &self.options, input.into()).await
}
pub async fn list(&self, params: Option<DocumentsListParams>) -> Result<Page<Document>> {
let request = Request::new(Method::GET, ["documents".to_owned()])
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()))
.query("q", params.as_ref().and_then(|p| p.q.as_ref()));
self.client.json(&self.options, request).await
}
pub fn stream(&self, params: Option<DocumentsListParams>) -> PageStream<Document> {
let this = self.clone();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.list(Some(params)).await })
})
}
pub async fn get(&self, document_id: &str) -> Result<Document> {
let request = Request::new(
Method::GET,
["documents".to_owned(), document_id.to_owned()],
);
self.client
.json_field(&self.options, request, "document")
.await
}
}
#[derive(Clone, Debug)]
pub struct Uploads {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl Uploads {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn create(&self, body: UploadsCreateRequest) -> Result<Upload> {
let key = self.options.key();
let request = Request::new(Method::POST, ["uploads".to_owned()])
.json(json_body(&body, None)?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
pub async fn get(&self, upload_id: &str) -> Result<Upload> {
let request = Request::new(Method::GET, ["uploads".to_owned(), upload_id.to_owned()]);
self.client.json(&self.options, request).await
}
pub async fn abort(&self, upload_id: &str, body: UploadsAbortRequest) -> Result<Upload> {
let request = Request::new(Method::DELETE, ["uploads".to_owned(), upload_id.to_owned()])
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn parts_put(
&self,
upload_id: &str,
index: &str,
part: bytes::Bytes,
) -> Result<UploadPart> {
let request = Request::new(
Method::PUT,
[
"uploads".to_owned(),
upload_id.to_owned(),
"parts".to_owned(),
index.to_owned(),
],
)
.header(
"x-part-sha256",
&crate::util::hex(&<sha2::Sha256 as sha2::Digest>::digest(&part)),
)
.body(crate::client::RequestBody::Bytes {
data: part,
content_type: "application/octet-stream".into(),
})
.retry_always();
self.client.json(&self.options, request).await
}
pub async fn complete(
&self,
upload_id: &str,
body: Option<UploadsCompleteRequest>,
) -> Result<UploadCompletion> {
let request = Request::new(
Method::POST,
[
"uploads".to_owned(),
upload_id.to_owned(),
"complete".to_owned(),
],
)
.json(json_body(&body.unwrap_or_default(), None)?)
.retry_always();
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct DocumentOperations {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl DocumentOperations {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn create(&self, body: DocumentOperationsCreateRequest) -> Result<Operation> {
let key = self.options.key();
let request = Request::new(Method::POST, ["document-operations".to_owned()])
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client
.json_field(&self.options, request, "operation")
.await
}
pub async fn get(&self, operation_id: &str) -> Result<Operation> {
let request = Request::new(
Method::GET,
["document-operations".to_owned(), operation_id.to_owned()],
);
self.client
.json_field(&self.options, request, "operation")
.await
}
pub async fn outputs(&self, operation_id: &str) -> Result<OperationOutputs> {
let request = Request::new(
Method::GET,
[
"document-operations".to_owned(),
operation_id.to_owned(),
"outputs".to_owned(),
],
);
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct SecureLinks {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl SecureLinks {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn create(&self, body: SecureLinksCreateRequest) -> Result<Object> {
let key = self.options.key();
let request = Request::new(Method::POST, ["secure-links".to_owned()])
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
pub async fn list(&self) -> Result<Object> {
let request = Request::new(Method::GET, ["secure-links".to_owned()]);
self.client.json(&self.options, request).await
}
pub async fn get(&self, link_id: &str) -> Result<Object> {
let request = Request::new(Method::GET, ["secure-links".to_owned(), link_id.to_owned()]);
self.client.json(&self.options, request).await
}
pub async fn update(
&self,
link_id: &str,
body: Option<SecureLinksUpdateRequest>,
) -> Result<Object> {
let request = Request::new(
Method::PATCH,
["secure-links".to_owned(), link_id.to_owned()],
)
.json(json_body(&body.unwrap_or_default(), None)?);
self.client.json(&self.options, request).await
}
pub async fn revoke(&self, link_id: &str, body: SecureLinksRevokeRequest) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"secure-links".to_owned(),
link_id.to_owned(),
"revoke".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn version(&self, link_id: &str, body: SecureLinksVersionRequest) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"secure-links".to_owned(),
link_id.to_owned(),
"version".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn recipients_list(&self, link_id: &str) -> Result<Object> {
let request = Request::new(
Method::GET,
[
"secure-links".to_owned(),
link_id.to_owned(),
"recipients".to_owned(),
],
);
self.client.json(&self.options, request).await
}
pub async fn recipients_add(
&self,
link_id: &str,
body: SecureLinksRecipientsAddRequest,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"secure-links".to_owned(),
link_id.to_owned(),
"recipients".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn password(
&self,
link_id: &str,
body: SecureLinksPasswordRequest,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"secure-links".to_owned(),
link_id.to_owned(),
"password".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn sessions_list(&self, link_id: &str) -> Result<Object> {
let request = Request::new(
Method::GET,
[
"secure-links".to_owned(),
link_id.to_owned(),
"sessions".to_owned(),
],
);
self.client.json(&self.options, request).await
}
pub async fn sessions_revoke(
&self,
link_id: &str,
session_id: &str,
body: Option<SecureLinksSessionsRevokeRequest>,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"secure-links".to_owned(),
link_id.to_owned(),
"sessions".to_owned(),
session_id.to_owned(),
"revoke".to_owned(),
],
)
.json(json_body(&body.unwrap_or_default(), None)?);
self.client.json(&self.options, request).await
}
pub async fn analytics(&self, link_id: &str) -> Result<Object> {
let request = Request::new(
Method::GET,
[
"secure-links".to_owned(),
link_id.to_owned(),
"analytics".to_owned(),
],
);
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct WorkflowRuns {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl WorkflowRuns {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn create(
&self,
workflow_id: &str,
body: WorkflowRunsCreateRequest,
) -> Result<WorkflowRun> {
let key = self.options.key();
let request = Request::new(
Method::POST,
[
"workflows".to_owned(),
workflow_id.to_owned(),
"runs".to_owned(),
],
)
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json_field(&self.options, request, "run").await
}
pub async fn get(&self, run_id: &str) -> Result<WorkflowRun> {
let request = Request::new(Method::GET, ["workflow-runs".to_owned(), run_id.to_owned()]);
self.client.json_field(&self.options, request, "run").await
}
pub async fn cancel(
&self,
run_id: &str,
body: WorkflowRunsCancelRequest,
) -> Result<WorkflowRun> {
let request = Request::new(
Method::POST,
[
"workflow-runs".to_owned(),
run_id.to_owned(),
"cancel".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json_field(&self.options, request, "run").await
}
pub async fn replay(
&self,
run_id: &str,
body: WorkflowRunsReplayRequest,
) -> Result<WorkflowRun> {
let request = Request::new(
Method::POST,
[
"workflow-runs".to_owned(),
run_id.to_owned(),
"replay".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json_field(&self.options, request, "run").await
}
}
#[derive(Clone, Debug)]
pub struct WorkflowApprovals {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl WorkflowApprovals {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn decide(
&self,
approval_id: &str,
body: WorkflowApprovalsDecideRequest,
) -> Result<Object> {
let key = self.options.key();
let request = Request::new(
Method::POST,
[
"workflow-approvals".to_owned(),
approval_id.to_owned(),
"decision".to_owned(),
],
)
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct Connectors {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl Connectors {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn accounts_list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
let request = Request::new(Method::GET, ["connector-accounts".to_owned()])
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
self.client.json(&self.options, request).await
}
pub fn accounts_stream(&self, params: Option<ListParams>) -> PageStream<Object> {
let this = self.clone();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.accounts_list(Some(params)).await })
})
}
pub async fn accounts_test(
&self,
account_id: &str,
body: ConnectorsAccountsTestRequest,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"connector-accounts".to_owned(),
account_id.to_owned(),
"test".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn accounts_disconnect(
&self,
account_id: &str,
body: ConnectorsAccountsDisconnectRequest,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"connector-accounts".to_owned(),
account_id.to_owned(),
"disconnect".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn items_list(
&self,
account_id: &str,
params: Option<ListParams>,
) -> Result<Page<Object>> {
let request = Request::new(
Method::GET,
[
"connector-accounts".to_owned(),
account_id.to_owned(),
"items".to_owned(),
],
)
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
self.client.json(&self.options, request).await
}
pub fn items_stream(
&self,
account_id: impl Into<String>,
params: Option<ListParams>,
) -> PageStream<Object> {
let this = self.clone();
let account_id: String = account_id.into();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let account_id = account_id.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.items_list(&account_id, Some(params)).await })
})
}
pub async fn operations_list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
let request = Request::new(Method::GET, ["connector-operations".to_owned()])
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
self.client.json(&self.options, request).await
}
pub fn operations_stream(&self, params: Option<ListParams>) -> PageStream<Object> {
let this = self.clone();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.operations_list(Some(params)).await })
})
}
pub async fn import(&self, body: Option<ConnectorsImportRequest>) -> Result<Object> {
let request = Request::new(Method::POST, ["connector-imports".to_owned()])
.json(json_body(&body.unwrap_or_default(), None)?);
self.client.json(&self.options, request).await
}
pub async fn send(&self, body: Option<ConnectorsSendRequest>) -> Result<Object> {
let request = Request::new(Method::POST, ["connector-sends".to_owned()])
.json(json_body(&body.unwrap_or_default(), None)?);
self.client.json(&self.options, request).await
}
pub async fn export(&self, body: Option<ConnectorsExportRequest>) -> Result<Object> {
let request = Request::new(Method::POST, ["connector-exports".to_owned()])
.json(json_body(&body.unwrap_or_default(), None)?);
self.client.json(&self.options, request).await
}
pub async fn generic_create(&self, body: ConnectorsGenericCreateRequest) -> Result<Object> {
let key = self.options.key();
let request = Request::new(Method::POST, ["generic-http-connections".to_owned()])
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
pub async fn generic_trigger(
&self,
account_id: &str,
body: ConnectorsGenericTriggerRequest,
) -> Result<Object> {
let request = Request::new(
Method::POST,
["generic-http-triggers".to_owned(), account_id.to_owned()],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct Templates {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl Templates {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
let request = Request::new(Method::GET, ["templates".to_owned()])
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
self.client.json(&self.options, request).await
}
pub fn stream(&self, params: Option<ListParams>) -> PageStream<Object> {
let this = self.clone();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.list(Some(params)).await })
})
}
pub async fn create(&self, body: TemplatesCreateRequest) -> Result<Object> {
let key = self.options.key();
let request = Request::new(Method::POST, ["templates".to_owned()])
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
pub async fn get(&self, resource_id: &str) -> Result<Object> {
let request = Request::new(
Method::GET,
["templates".to_owned(), resource_id.to_owned()],
);
self.client.json(&self.options, request).await
}
pub async fn update(&self, resource_id: &str, body: TemplatesUpdateRequest) -> Result<Object> {
let request = Request::new(
Method::PATCH,
["templates".to_owned(), resource_id.to_owned()],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn transition(
&self,
resource_id: &str,
body: TemplatesTransitionRequest,
) -> Result<Object> {
let key = self.options.key();
let request = Request::new(
Method::POST,
[
"templates".to_owned(),
resource_id.to_owned(),
"actions".to_owned(),
],
)
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct SignatureRequests {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl SignatureRequests {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
let request = Request::new(Method::GET, ["signature-requests".to_owned()])
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
self.client.json(&self.options, request).await
}
pub fn stream(&self, params: Option<ListParams>) -> PageStream<Object> {
let this = self.clone();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.list(Some(params)).await })
})
}
pub async fn create(&self, body: SignatureRequestsCreateRequest) -> Result<Object> {
let key = self.options.key();
let request = Request::new(Method::POST, ["signature-requests".to_owned()])
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
pub async fn get(&self, resource_id: &str) -> Result<Object> {
let request = Request::new(
Method::GET,
["signature-requests".to_owned(), resource_id.to_owned()],
);
self.client.json(&self.options, request).await
}
pub async fn update(
&self,
resource_id: &str,
body: SignatureRequestsUpdateRequest,
) -> Result<Object> {
let request = Request::new(
Method::PATCH,
["signature-requests".to_owned(), resource_id.to_owned()],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn transition(
&self,
resource_id: &str,
body: SignatureRequestsTransitionRequest,
) -> Result<Object> {
let key = self.options.key();
let request = Request::new(
Method::POST,
[
"signature-requests".to_owned(),
resource_id.to_owned(),
"actions".to_owned(),
],
)
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct Annotations {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl Annotations {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
let request = Request::new(Method::GET, ["annotations".to_owned()])
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
self.client.json(&self.options, request).await
}
pub fn stream(&self, params: Option<ListParams>) -> PageStream<Object> {
let this = self.clone();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.list(Some(params)).await })
})
}
pub async fn create(&self, body: AnnotationsCreateRequest) -> Result<Object> {
let key = self.options.key();
let request = Request::new(Method::POST, ["annotations".to_owned()])
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
pub async fn get(&self, resource_id: &str) -> Result<Object> {
let request = Request::new(
Method::GET,
["annotations".to_owned(), resource_id.to_owned()],
);
self.client.json(&self.options, request).await
}
pub async fn update(
&self,
resource_id: &str,
body: AnnotationsUpdateRequest,
) -> Result<Object> {
let request = Request::new(
Method::PATCH,
["annotations".to_owned(), resource_id.to_owned()],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn transition(
&self,
resource_id: &str,
body: AnnotationsTransitionRequest,
) -> Result<Object> {
let key = self.options.key();
let request = Request::new(
Method::POST,
[
"annotations".to_owned(),
resource_id.to_owned(),
"actions".to_owned(),
],
)
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct Forms {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl Forms {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
let request = Request::new(Method::GET, ["forms".to_owned()])
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
self.client.json(&self.options, request).await
}
pub fn stream(&self, params: Option<ListParams>) -> PageStream<Object> {
let this = self.clone();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.list(Some(params)).await })
})
}
pub async fn create(&self, body: FormsCreateRequest) -> Result<Object> {
let key = self.options.key();
let request = Request::new(Method::POST, ["forms".to_owned()])
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
pub async fn get(&self, resource_id: &str) -> Result<Object> {
let request = Request::new(Method::GET, ["forms".to_owned(), resource_id.to_owned()]);
self.client.json(&self.options, request).await
}
pub async fn update(&self, resource_id: &str, body: FormsUpdateRequest) -> Result<Object> {
let request = Request::new(Method::PATCH, ["forms".to_owned(), resource_id.to_owned()])
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn transition(
&self,
resource_id: &str,
body: FormsTransitionRequest,
) -> Result<Object> {
let key = self.options.key();
let request = Request::new(
Method::POST,
[
"forms".to_owned(),
resource_id.to_owned(),
"actions".to_owned(),
],
)
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct DealRooms {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl DealRooms {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
let request = Request::new(Method::GET, ["deal-rooms".to_owned()])
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
self.client.json(&self.options, request).await
}
pub fn stream(&self, params: Option<ListParams>) -> PageStream<Object> {
let this = self.clone();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.list(Some(params)).await })
})
}
pub async fn create(&self, body: DealRoomsCreateRequest) -> Result<Object> {
let key = self.options.key();
let request = Request::new(Method::POST, ["deal-rooms".to_owned()])
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
pub async fn get(&self, resource_id: &str) -> Result<Object> {
let request = Request::new(
Method::GET,
["deal-rooms".to_owned(), resource_id.to_owned()],
);
self.client.json(&self.options, request).await
}
pub async fn update(&self, resource_id: &str, body: DealRoomsUpdateRequest) -> Result<Object> {
let request = Request::new(
Method::PATCH,
["deal-rooms".to_owned(), resource_id.to_owned()],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn transition(
&self,
resource_id: &str,
body: DealRoomsTransitionRequest,
) -> Result<Object> {
let key = self.options.key();
let request = Request::new(
Method::POST,
[
"deal-rooms".to_owned(),
resource_id.to_owned(),
"actions".to_owned(),
],
)
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct Embeds {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl Embeds {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
let request = Request::new(Method::GET, ["embeds".to_owned()])
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
self.client.json(&self.options, request).await
}
pub fn stream(&self, params: Option<ListParams>) -> PageStream<Object> {
let this = self.clone();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.list(Some(params)).await })
})
}
pub async fn create(&self, body: EmbedsCreateRequest) -> Result<Object> {
let key = self.options.key();
let request = Request::new(Method::POST, ["embeds".to_owned()])
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
pub async fn get(&self, resource_id: &str) -> Result<Object> {
let request = Request::new(Method::GET, ["embeds".to_owned(), resource_id.to_owned()]);
self.client.json(&self.options, request).await
}
pub async fn update(&self, resource_id: &str, body: EmbedsUpdateRequest) -> Result<Object> {
let request = Request::new(Method::PATCH, ["embeds".to_owned(), resource_id.to_owned()])
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn transition(
&self,
resource_id: &str,
body: EmbedsTransitionRequest,
) -> Result<Object> {
let key = self.options.key();
let request = Request::new(
Method::POST,
[
"embeds".to_owned(),
resource_id.to_owned(),
"actions".to_owned(),
],
)
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct DocumentVersions {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl DocumentVersions {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn list(
&self,
document_id: &str,
params: Option<ListParams>,
) -> Result<Page<DocumentVersion>> {
let request = Request::new(
Method::GET,
[
"documents".to_owned(),
document_id.to_owned(),
"versions".to_owned(),
],
)
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
self.client.json(&self.options, request).await
}
pub fn stream(
&self,
document_id: impl Into<String>,
params: Option<ListParams>,
) -> PageStream<DocumentVersion> {
let this = self.clone();
let document_id: String = document_id.into();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let document_id = document_id.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.list(&document_id, Some(params)).await })
})
}
pub async fn get(&self, document_id: &str, version_id: &str) -> Result<DocumentVersion> {
let request = Request::new(
Method::GET,
[
"documents".to_owned(),
document_id.to_owned(),
"versions".to_owned(),
version_id.to_owned(),
],
);
self.client.json(&self.options, request).await
}
pub async fn download(&self, document_id: &str, version_id: &str) -> Result<Download> {
let request = Request::new(
Method::GET,
[
"documents".to_owned(),
document_id.to_owned(),
"versions".to_owned(),
version_id.to_owned(),
"content".to_owned(),
],
);
Ok(Download::new(
self.client.send(&self.options, request).await?,
))
}
pub async fn render_page(
&self,
document_id: &str,
version_id: &str,
page: &str,
) -> Result<Download> {
let request = Request::new(
Method::GET,
[
"documents".to_owned(),
document_id.to_owned(),
"versions".to_owned(),
version_id.to_owned(),
"pages".to_owned(),
page.to_owned(),
"render".to_owned(),
],
);
Ok(Download::new(
self.client.send(&self.options, request).await?,
))
}
}
#[derive(Clone, Debug)]
pub struct DocumentAnalytics {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl DocumentAnalytics {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn get(&self, document_id: &str) -> Result<Object> {
let request = Request::new(
Method::GET,
[
"documents".to_owned(),
document_id.to_owned(),
"analytics".to_owned(),
],
);
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct Keys {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl Keys {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
let request = Request::new(Method::GET, ["keys".to_owned()])
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
self.client.json(&self.options, request).await
}
pub fn stream(&self, params: Option<ListParams>) -> PageStream<Object> {
let this = self.clone();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.list(Some(params)).await })
})
}
pub async fn create(&self, body: KeysCreateRequest) -> Result<Object> {
let request = Request::new(Method::POST, ["keys".to_owned()]).json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn revoke(&self, key_id: &str, body: KeysRevokeRequest) -> Result<Object> {
let request = Request::new(
Method::POST,
["keys".to_owned(), key_id.to_owned(), "revoke".to_owned()],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn rotate(&self, key_id: &str, body: KeysRotateRequest) -> Result<Object> {
let request = Request::new(
Method::POST,
["keys".to_owned(), key_id.to_owned(), "rotate".to_owned()],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct Usage {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl Usage {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn get(&self) -> Result<Object> {
let request = Request::new(Method::GET, ["usage".to_owned()]);
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct Logs {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl Logs {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn list(&self, params: Option<ListParams>) -> Result<Page<Object>> {
let request = Request::new(Method::GET, ["logs".to_owned()])
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
self.client.json(&self.options, request).await
}
pub fn stream(&self, params: Option<ListParams>) -> PageStream<Object> {
let this = self.clone();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.list(Some(params)).await })
})
}
}
#[derive(Clone, Debug)]
pub struct Rooms {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl Rooms {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn list(&self) -> Result<Object> {
let request = Request::new(Method::GET, ["rooms".to_owned()]);
self.client.json(&self.options, request).await
}
pub async fn create(&self, body: RoomsCreateRequest) -> Result<Object> {
let request =
Request::new(Method::POST, ["rooms".to_owned()]).json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn get(&self, room_id: &str) -> Result<Object> {
let request = Request::new(Method::GET, ["rooms".to_owned(), room_id.to_owned()]);
self.client.json(&self.options, request).await
}
pub async fn contents(&self, room_id: &str) -> Result<Object> {
let request = Request::new(
Method::GET,
[
"rooms".to_owned(),
room_id.to_owned(),
"contents".to_owned(),
],
);
self.client.json(&self.options, request).await
}
pub async fn transition(&self, room_id: &str, body: RoomsTransitionRequest) -> Result<Object> {
let request = Request::new(
Method::POST,
["rooms".to_owned(), room_id.to_owned(), "actions".to_owned()],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn folders_create(
&self,
room_id: &str,
body: RoomsFoldersCreateRequest,
) -> Result<Object> {
let request = Request::new(
Method::POST,
["rooms".to_owned(), room_id.to_owned(), "folders".to_owned()],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn folders_update(
&self,
room_id: &str,
folder_id: &str,
body: Option<RoomsFoldersUpdateRequest>,
) -> Result<Object> {
let request = Request::new(
Method::PATCH,
[
"rooms".to_owned(),
room_id.to_owned(),
"folders".to_owned(),
folder_id.to_owned(),
],
)
.json(json_body(&body.unwrap_or_default(), None)?);
self.client.json(&self.options, request).await
}
pub async fn documents_add(
&self,
room_id: &str,
body: RoomsDocumentsAddRequest,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"rooms".to_owned(),
room_id.to_owned(),
"documents".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn documents_update(
&self,
room_id: &str,
room_document_id: &str,
body: Option<RoomsDocumentsUpdateRequest>,
) -> Result<Object> {
let request = Request::new(
Method::PATCH,
[
"rooms".to_owned(),
room_id.to_owned(),
"documents".to_owned(),
room_document_id.to_owned(),
],
)
.json(json_body(&body.unwrap_or_default(), None)?);
self.client.json(&self.options, request).await
}
pub async fn participants_add(
&self,
room_id: &str,
body: RoomsParticipantsAddRequest,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"rooms".to_owned(),
room_id.to_owned(),
"participants".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn participants_update(
&self,
room_id: &str,
participant_id: &str,
body: RoomsParticipantsUpdateRequest,
) -> Result<Object> {
let request = Request::new(
Method::PATCH,
[
"rooms".to_owned(),
room_id.to_owned(),
"participants".to_owned(),
participant_id.to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn permissions_set(
&self,
room_id: &str,
body: RoomsPermissionsSetRequest,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"rooms".to_owned(),
room_id.to_owned(),
"permissions".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn permissions_revoke(
&self,
room_id: &str,
permission_id: &str,
body: Option<RoomsPermissionsRevokeRequest>,
) -> Result<Object> {
let request = Request::new(
Method::DELETE,
[
"rooms".to_owned(),
room_id.to_owned(),
"permissions".to_owned(),
permission_id.to_owned(),
],
)
.json(json_body(&body.unwrap_or_default(), None)?);
self.client.json(&self.options, request).await
}
pub async fn requests_create(
&self,
room_id: &str,
body: RoomsRequestsCreateRequest,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"rooms".to_owned(),
room_id.to_owned(),
"requests".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn questions_create(
&self,
room_id: &str,
body: RoomsQuestionsCreateRequest,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"rooms".to_owned(),
room_id.to_owned(),
"questions".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn questions_answer(
&self,
room_id: &str,
question_id: &str,
body: RoomsQuestionsAnswerRequest,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"rooms".to_owned(),
room_id.to_owned(),
"questions".to_owned(),
question_id.to_owned(),
"answers".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn analytics(&self, room_id: &str) -> Result<Object> {
let request = Request::new(
Method::GET,
[
"rooms".to_owned(),
room_id.to_owned(),
"analytics".to_owned(),
],
);
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct Portals {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl Portals {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn list(&self) -> Result<Object> {
let request = Request::new(Method::GET, ["portals".to_owned()]);
self.client.json(&self.options, request).await
}
pub async fn create(&self, body: PortalsCreateRequest) -> Result<Object> {
let request =
Request::new(Method::POST, ["portals".to_owned()]).json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn get(&self, portal_id: &str) -> Result<Object> {
let request = Request::new(Method::GET, ["portals".to_owned(), portal_id.to_owned()]);
self.client.json(&self.options, request).await
}
pub async fn update(
&self,
portal_id: &str,
body: Option<PortalsUpdateRequest>,
) -> Result<Object> {
let request = Request::new(Method::PATCH, ["portals".to_owned(), portal_id.to_owned()])
.json(json_body(&body.unwrap_or_default(), None)?);
self.client.json(&self.options, request).await
}
pub async fn publish(
&self,
portal_id: &str,
body: Option<PortalsPublishRequest>,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"portals".to_owned(),
portal_id.to_owned(),
"actions".to_owned(),
],
)
.json(json_body(&body.unwrap_or_default(), None)?);
self.client.json(&self.options, request).await
}
pub async fn rooms_add(&self, portal_id: &str, body: PortalsRoomsAddRequest) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"portals".to_owned(),
portal_id.to_owned(),
"rooms".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn announcements_create(
&self,
portal_id: &str,
body: PortalsAnnouncementsCreateRequest,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"portals".to_owned(),
portal_id.to_owned(),
"announcements".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn resources_create(
&self,
portal_id: &str,
body: PortalsResourcesCreateRequest,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"portals".to_owned(),
portal_id.to_owned(),
"resources".to_owned(),
],
)
.json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn analytics(&self, portal_id: &str) -> Result<Object> {
let request = Request::new(
Method::GET,
[
"portals".to_owned(),
portal_id.to_owned(),
"analytics".to_owned(),
],
);
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct EmbedSessions {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl EmbedSessions {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn create(&self, body: EmbedSessionsCreateRequest) -> Result<Object> {
let request =
Request::new(Method::POST, ["embed-sessions".to_owned()]).json(json_body(&body, None)?);
self.client.json(&self.options, request).await
}
pub async fn get(&self, session_id: &str) -> Result<Object> {
let request = Request::new(
Method::GET,
["embed-sessions".to_owned(), session_id.to_owned()],
);
self.client.json(&self.options, request).await
}
pub async fn refresh(
&self,
session_id: &str,
body: Option<EmbedSessionsRefreshRequest>,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"embed-sessions".to_owned(),
session_id.to_owned(),
"refresh".to_owned(),
],
)
.json(json_body(&body.unwrap_or_default(), None)?);
self.client.json(&self.options, request).await
}
pub async fn revoke(
&self,
session_id: &str,
body: Option<EmbedSessionsRevokeRequest>,
) -> Result<Object> {
let request = Request::new(
Method::POST,
[
"embed-sessions".to_owned(),
session_id.to_owned(),
"revoke".to_owned(),
],
)
.json(json_body(&body.unwrap_or_default(), None)?);
self.client.json(&self.options, request).await
}
}
#[derive(Clone, Debug)]
pub struct Esign {
pub(crate) client: Wellfriend,
pub(crate) options: RequestOptions,
}
impl Esign {
pub fn with_options(mut self, options: RequestOptions) -> Self {
self.options = options;
self
}
pub async fn levels(&self) -> Result<EsignLevelsResponse> {
let request = Request::new(Method::GET, ["esign".to_owned(), "levels".to_owned()]);
self.client.json(&self.options, request).await
}
pub async fn envelopes_list(
&self,
params: Option<EsignEnvelopesListParams>,
) -> Result<Page<EsignEnvelopesListItem>> {
let request = Request::new(Method::GET, ["esign".to_owned(), "envelopes".to_owned()])
.query(
"documentId",
params.as_ref().and_then(|p| p.document_id.as_ref()),
)
.query("limit", params.as_ref().and_then(|p| p.limit.as_ref()))
.query("cursor", params.as_ref().and_then(|p| p.cursor.as_ref()));
self.client.json(&self.options, request).await
}
pub fn envelopes_stream(
&self,
params: Option<EsignEnvelopesListParams>,
) -> PageStream<EsignEnvelopesListItem> {
let this = self.clone();
let params = params.unwrap_or_default();
crate::pagination::paginate(move |cursor| {
let this = this.clone();
let mut params = params.clone();
if cursor.is_some() {
params.cursor = cursor;
}
Box::pin(async move { this.envelopes_list(Some(params)).await })
})
}
pub async fn envelopes_create(
&self,
body: EsignEnvelopesCreateRequest,
) -> Result<EsignEnvelopesCreateResponse> {
let key = self.options.key();
let request = Request::new(Method::POST, ["esign".to_owned(), "envelopes".to_owned()])
.json(json_body(&body, Some(&key))?)
.idempotency_key(key);
self.client.json(&self.options, request).await
}
pub async fn envelopes_get(&self, envelope_id: &str) -> Result<EsignEnvelopesGetResponse> {
let request = Request::new(
Method::GET,
[
"esign".to_owned(),
"envelopes".to_owned(),
envelope_id.to_owned(),
],
);
self.client.json(&self.options, request).await
}
pub async fn envelopes_cancel(
&self,
envelope_id: &str,
body: Option<EsignEnvelopesCancelRequest>,
) -> Result<EsignEnvelopesGetResponse> {
let request = Request::new(
Method::POST,
[
"esign".to_owned(),
"envelopes".to_owned(),
envelope_id.to_owned(),
"cancel".to_owned(),
],
)
.json(json_body(&body.unwrap_or_default(), None)?);
self.client.json(&self.options, request).await
}
pub async fn envelopes_certificate(&self, envelope_id: &str) -> Result<Download> {
let request = Request::new(
Method::GET,
[
"esign".to_owned(),
"envelopes".to_owned(),
envelope_id.to_owned(),
"certificate".to_owned(),
],
);
Ok(Download::new(
self.client.send(&self.options, request).await?,
))
}
pub async fn validate(&self, input: impl Into<FileInput>) -> Result<EsignValidateResponse> {
let request = Request::new(Method::POST, ["esign".to_owned(), "validate".to_owned()])
.body(crate::uploads::file_body(input.into(), "application/pdf").await?);
self.client.json(&self.options, request).await
}
}
impl Wellfriend {
pub fn platform(&self) -> Platform {
Platform {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn pricing(&self) -> Pricing {
Pricing {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn workflows(&self) -> Workflows {
Workflows {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn documents(&self) -> Documents {
Documents {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn uploads(&self) -> Uploads {
Uploads {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn document_operations(&self) -> DocumentOperations {
DocumentOperations {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn secure_links(&self) -> SecureLinks {
SecureLinks {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn workflow_runs(&self) -> WorkflowRuns {
WorkflowRuns {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn workflow_approvals(&self) -> WorkflowApprovals {
WorkflowApprovals {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn connectors(&self) -> Connectors {
Connectors {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn templates(&self) -> Templates {
Templates {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn signature_requests(&self) -> SignatureRequests {
SignatureRequests {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn annotations(&self) -> Annotations {
Annotations {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn forms(&self) -> Forms {
Forms {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn deal_rooms(&self) -> DealRooms {
DealRooms {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn embeds(&self) -> Embeds {
Embeds {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn document_versions(&self) -> DocumentVersions {
DocumentVersions {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn document_analytics(&self) -> DocumentAnalytics {
DocumentAnalytics {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn keys(&self) -> Keys {
Keys {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn usage(&self) -> Usage {
Usage {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn logs(&self) -> Logs {
Logs {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn rooms(&self) -> Rooms {
Rooms {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn portals(&self) -> Portals {
Portals {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn embed_sessions(&self) -> EmbedSessions {
EmbedSessions {
client: self.clone(),
options: RequestOptions::default(),
}
}
pub fn esign(&self) -> Esign {
Esign {
client: self.clone(),
options: RequestOptions::default(),
}
}
}