use super::types;
use crate::{
ByteStream, ClientHooks, ClientInfo, Error, OperationInfo, RequestBuilderExt,
ResponseValue, encode_path,
};
#[derive(Debug, Clone)]
pub struct BrapiPostContent<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
cache_ttl: Result<f64, String>,
body: Result<types::BrapiPostContentBody, String>,
}
impl<'a> BrapiPostContent<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
cache_ttl: Err("cache_ttl was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn cache_ttl<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.cache_ttl = value
.try_into()
.map_err(|_| "conversion to `f64` for cache_ttl failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::BrapiPostContentBody>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `BrapiPostContentBody` for body failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
cache_ttl,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let cache_ttl = cache_ttl.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/browser-rendering/content",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.query(&progenitor_client::QueryParam::new("cacheTTL", &cache_ttl))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "brapi_post_content",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct BrapiPostJson<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
cache_ttl: Result<f64, String>,
body: Result<types::BrapiPostJsonBody, String>,
}
impl<'a> BrapiPostJson<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
cache_ttl: Err("cache_ttl was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn cache_ttl<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.cache_ttl = value
.try_into()
.map_err(|_| "conversion to `f64` for cache_ttl failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::BrapiPostJsonBody>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `BrapiPostJsonBody` for body failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
cache_ttl,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let cache_ttl = cache_ttl.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/browser-rendering/json",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.query(&progenitor_client::QueryParam::new("cacheTTL", &cache_ttl))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "brapi_post_json",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct BrapiPostLinks<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
cache_ttl: Result<f64, String>,
body: Result<types::BrapiPostLinksBody, String>,
}
impl<'a> BrapiPostLinks<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
cache_ttl: Err("cache_ttl was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn cache_ttl<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.cache_ttl = value
.try_into()
.map_err(|_| "conversion to `f64` for cache_ttl failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::BrapiPostLinksBody>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `BrapiPostLinksBody` for body failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
cache_ttl,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let cache_ttl = cache_ttl.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/browser-rendering/links",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.query(&progenitor_client::QueryParam::new("cacheTTL", &cache_ttl))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "brapi_post_links",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct BrapiPostMarkdown<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
cache_ttl: Result<f64, String>,
body: Result<types::BrapiPostMarkdownBody, String>,
}
impl<'a> BrapiPostMarkdown<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
cache_ttl: Err("cache_ttl was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn cache_ttl<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.cache_ttl = value
.try_into()
.map_err(|_| "conversion to `f64` for cache_ttl failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::BrapiPostMarkdownBody>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `BrapiPostMarkdownBody` for body failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
cache_ttl,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let cache_ttl = cache_ttl.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/browser-rendering/markdown",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.query(&progenitor_client::QueryParam::new("cacheTTL", &cache_ttl))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "brapi_post_markdown",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct BrapiPostPdf<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
cache_ttl: Result<f64, String>,
body: Result<types::BrapiPostPdfBody, String>,
}
impl<'a> BrapiPostPdf<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
cache_ttl: Err("cache_ttl was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn cache_ttl<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.cache_ttl = value
.try_into()
.map_err(|_| "conversion to `f64` for cache_ttl failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::BrapiPostPdfBody>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `BrapiPostPdfBody` for body failed".to_string());
self
}
pub async fn send(self) -> Result<ResponseValue<ByteStream>, Error<()>> {
let Self {
client,
account_id,
cache_ttl,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let cache_ttl = cache_ttl.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/browser-rendering/pdf",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.json(&body)
.query(&progenitor_client::QueryParam::new("cacheTTL", &cache_ttl))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "brapi_post_pdf",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => Ok(ResponseValue::stream(response)),
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct BrapiPostScrape<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
cache_ttl: Result<f64, String>,
body: Result<types::BrapiPostScrapeBody, String>,
}
impl<'a> BrapiPostScrape<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
cache_ttl: Err("cache_ttl was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn cache_ttl<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.cache_ttl = value
.try_into()
.map_err(|_| "conversion to `f64` for cache_ttl failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::BrapiPostScrapeBody>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `BrapiPostScrapeBody` for body failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
cache_ttl,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let cache_ttl = cache_ttl.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/browser-rendering/scrape",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.query(&progenitor_client::QueryParam::new("cacheTTL", &cache_ttl))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "brapi_post_scrape",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct BrapiPostScreenshot<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
cache_ttl: Result<f64, String>,
body: Result<types::BrapiPostScreenshotBody, String>,
}
impl<'a> BrapiPostScreenshot<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
cache_ttl: Err("cache_ttl was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn cache_ttl<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.cache_ttl = value
.try_into()
.map_err(|_| "conversion to `f64` for cache_ttl failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::BrapiPostScreenshotBody>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `BrapiPostScreenshotBody` for body failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
cache_ttl,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let cache_ttl = cache_ttl.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/browser-rendering/screenshot",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.query(&progenitor_client::QueryParam::new("cacheTTL", &cache_ttl))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "brapi_post_screenshot",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}
#[derive(Debug, Clone)]
pub struct BrapiPostSnapshot<'a> {
client: &'a crate::Client,
account_id: Result<::std::string::String, String>,
cache_ttl: Result<f64, String>,
body: Result<types::BrapiPostSnapshotBody, String>,
}
impl<'a> BrapiPostSnapshot<'a> {
pub fn new(client: &'a crate::Client) -> Self {
Self {
client: client,
account_id: Err("account_id was not initialized".to_string()),
cache_ttl: Err("cache_ttl was not initialized".to_string()),
body: Err("body was not initialized".to_string()),
}
}
pub fn account_id<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<::std::string::String>,
{
self.account_id = value.try_into().map_err(|_| {
"conversion to `:: std :: string :: String` for account_id failed".to_string()
});
self
}
pub fn cache_ttl<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<f64>,
{
self.cache_ttl = value
.try_into()
.map_err(|_| "conversion to `f64` for cache_ttl failed".to_string());
self
}
pub fn body<V>(mut self, value: V) -> Self
where
V: std::convert::TryInto<types::BrapiPostSnapshotBody>,
{
self.body = value
.try_into()
.map_err(|_| "conversion to `BrapiPostSnapshotBody` for body failed".to_string());
self
}
pub async fn send(
self,
) -> Result<
ResponseValue<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
Error<()>,
> {
let Self {
client,
account_id,
cache_ttl,
body,
} = self;
let account_id = account_id.map_err(Error::InvalidRequest)?;
let cache_ttl = cache_ttl.map_err(Error::InvalidRequest)?;
let body = body.map_err(Error::InvalidRequest)?;
let url = format!(
"{}/accounts/{}/browser-rendering/snapshot",
client.baseurl,
encode_path(&account_id.to_string()),
);
let mut header_map = ::reqwest::header::HeaderMap::with_capacity(1usize);
header_map.append(
::reqwest::header::HeaderName::from_static("api-version"),
::reqwest::header::HeaderValue::from_static(crate::Client::api_version()),
);
#[allow(unused_mut)]
let mut request = client
.client
.post(url)
.header(
::reqwest::header::ACCEPT,
::reqwest::header::HeaderValue::from_static("application/json"),
)
.json(&body)
.query(&progenitor_client::QueryParam::new("cacheTTL", &cache_ttl))
.headers(header_map)
.build()?;
let info = OperationInfo {
operation_id: "brapi_post_snapshot",
};
client.pre(&mut request, &info).await?;
let result = client.exec(request, &info).await;
client.post(&result, &info).await?;
let response = result?;
match response.status().as_u16() {
200u16 => ResponseValue::from_response(response).await,
_ => Err(Error::UnexpectedResponse(response)),
}
}
}