/*
* Zernio API
*
* API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api Versioning and deprecation: all endpoints are versioned in the URL path (current version: /v1). Breaking changes only ship in a new path version; existing versions keep working. Deprecated operations are marked 'deprecated: true' in this spec and announced in the changelog (https://zernio.com/changelog) before removal. Errors: every 4xx/5xx response is application/json with a machine-readable 'code' and a human-readable 'error' message (see the ErrorResponse schema). Request ids: responses carry an X-Request-Id header with the id we log the request under. Quote it when reporting a problem. A valid x-request-id you send is reused as that id.
*
* The version of the OpenAPI document: 1.104.0
* Contact: support@zernio.com
* Generated by: https://openapi-generator.tech
*/
use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
/// struct for typed errors of method [`batch_ad_catalog_products`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BatchAdCatalogProductsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::InlineObject2),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_ad_catalog`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAdCatalogError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_ad_catalog_feed`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAdCatalogFeedError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::InlineObject2),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_ad_catalog_feed_upload`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAdCatalogFeedUploadError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::InlineObject2),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_ad_catalog_product`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAdCatalogProductError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::InlineObject2),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_ad_catalog_product_set`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAdCatalogProductSetError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::InlineObject2),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_ad_catalog`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAdCatalogError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::InlineObject2),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_ad_catalog_product`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAdCatalogProductError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::InlineObject2),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_ad_catalog_product_set`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteAdCatalogProductSetError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::InlineObject2),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_ad_catalog`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAdCatalogError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::InlineObject2),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_ad_catalog_batch`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAdCatalogBatchError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::InlineObject2),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_ad_catalog_product`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAdCatalogProductError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::InlineObject2),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_ad_catalog_feed_uploads`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAdCatalogFeedUploadsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::InlineObject2),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_ad_catalog_feeds`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAdCatalogFeedsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::InlineObject2),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_ad_catalog_product_sets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAdCatalogProductSetsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::InlineObject2),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_ad_catalog_products`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAdCatalogProductsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::InlineObject2),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_ad_catalogs`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListAdCatalogsError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_ad_catalog_product`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateAdCatalogProductError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::InlineObject2),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_ad_catalog_product_set`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateAdCatalogProductSetError {
Status400(models::ErrorResponse),
Status401(models::InlineObject1),
Status403(models::ErrorResponse),
Status404(models::InlineObject2),
UnknownValue(serde_json::Value),
}
/// Up to 5000 CREATE / UPDATE / DELETE requests keyed by `retailerId`, processed asynchronously by Meta. Returns handles; poll GET /v1/ads/catalogs/{catalogId}/batches/{handle} for the outcome and per-item errors. CREATE requests need name, url, imageUrl, price and currency.
pub async fn batch_ad_catalog_products(
configuration: &configuration::Configuration,
catalog_id: &str,
batch_ad_catalog_products_request: models::BatchAdCatalogProductsRequest,
) -> Result<models::BatchAdCatalogProducts202Response, Error<BatchAdCatalogProductsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_catalog_id = catalog_id;
let p_body_batch_ad_catalog_products_request = batch_ad_catalog_products_request;
let uri_str = format!(
"{}/v1/ads/catalogs/{catalogId}/products/batch",
configuration.base_path,
catalogId = crate::apis::urlencode(p_path_catalog_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_batch_ad_catalog_products_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::BatchAdCatalogProducts202Response`"))),
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::BatchAdCatalogProducts202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<BatchAdCatalogProductsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates a Meta Commerce catalog in the business portfolio (resolved like GET). The same catalog serves Advantage+ catalog ads, Instagram/Facebook Shops and the WhatsApp Business catalog: link it to a WhatsApp number with POST /v1/whatsapp/catalogs. Needs catalog_management on the Meta login.
pub async fn create_ad_catalog(
configuration: &configuration::Configuration,
create_ad_catalog_request: models::CreateAdCatalogRequest,
) -> Result<models::CreateAdCatalog201Response, Error<CreateAdCatalogError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_ad_catalog_request = create_ad_catalog_request;
let uri_str = format!("{}/v1/ads/catalogs", configuration.base_path);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_ad_catalog_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateAdCatalog201Response`"))),
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::CreateAdCatalog201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAdCatalogError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// A feed pulls a CSV/TSV/XML product file from a URL. With `schedule` Meta fetches it on a cadence; without it, trigger fetches with POST /v1/ads/catalogs/{catalogId}/feeds/{feedId}/uploads.
pub async fn create_ad_catalog_feed(
configuration: &configuration::Configuration,
catalog_id: &str,
create_ad_catalog_feed_request: models::CreateAdCatalogFeedRequest,
) -> Result<models::CreateAdCatalogFeed201Response, Error<CreateAdCatalogFeedError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_catalog_id = catalog_id;
let p_body_create_ad_catalog_feed_request = create_ad_catalog_feed_request;
let uri_str = format!(
"{}/v1/ads/catalogs/{catalogId}/feeds",
configuration.base_path,
catalogId = crate::apis::urlencode(p_path_catalog_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_ad_catalog_feed_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateAdCatalogFeed201Response`"))),
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::CreateAdCatalogFeed201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAdCatalogFeedError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Asks Meta to fetch the product file at `url` into the feed. Processing is asynchronous: read the outcome with GET uploads.
pub async fn create_ad_catalog_feed_upload(
configuration: &configuration::Configuration,
catalog_id: &str,
feed_id: &str,
create_ad_catalog_feed_upload_request: models::CreateAdCatalogFeedUploadRequest,
) -> Result<models::CreateAdCatalogFeedUpload202Response, Error<CreateAdCatalogFeedUploadError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_catalog_id = catalog_id;
let p_path_feed_id = feed_id;
let p_body_create_ad_catalog_feed_upload_request = create_ad_catalog_feed_upload_request;
let uri_str = format!(
"{}/v1/ads/catalogs/{catalogId}/feeds/{feedId}/uploads",
configuration.base_path,
catalogId = crate::apis::urlencode(p_path_catalog_id),
feedId = crate::apis::urlencode(p_path_feed_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_ad_catalog_feed_upload_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateAdCatalogFeedUpload202Response`"))),
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::CreateAdCatalogFeedUpload202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAdCatalogFeedUploadError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Adds one product. `retailerId` is your SKU and stays the handle for later lookups and batch updates. For many products at once use POST /v1/ads/catalogs/{catalogId}/products/batch. Needs catalog_management on the Meta login.
pub async fn create_ad_catalog_product(
configuration: &configuration::Configuration,
catalog_id: &str,
create_ad_catalog_product_request: models::CreateAdCatalogProductRequest,
) -> Result<models::CreateAdCatalogProduct201Response, Error<CreateAdCatalogProductError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_catalog_id = catalog_id;
let p_body_create_ad_catalog_product_request = create_ad_catalog_product_request;
let uri_str = format!(
"{}/v1/ads/catalogs/{catalogId}/products",
configuration.base_path,
catalogId = crate::apis::urlencode(p_path_catalog_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_ad_catalog_product_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateAdCatalogProduct201Response`"))),
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::CreateAdCatalogProduct201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAdCatalogProductError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// A product set is a filter over the catalog, e.g. `{\"retailer_id\": {\"is_any\": [\"sku-1\", \"sku-2\"]}}` or `{\"brand\": {\"i_contains\": \"acme\"}}` (Meta's product set filter syntax).
pub async fn create_ad_catalog_product_set(
configuration: &configuration::Configuration,
catalog_id: &str,
create_ad_catalog_product_set_request: models::CreateAdCatalogProductSetRequest,
) -> Result<models::CreateAdCatalogProductSet201Response, Error<CreateAdCatalogProductSetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_catalog_id = catalog_id;
let p_body_create_ad_catalog_product_set_request = create_ad_catalog_product_set_request;
let uri_str = format!(
"{}/v1/ads/catalogs/{catalogId}/product-sets",
configuration.base_path,
catalogId = crate::apis::urlencode(p_path_catalog_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_create_ad_catalog_product_set_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateAdCatalogProductSet201Response`"))),
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::CreateAdCatalogProductSet201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAdCatalogProductSetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Deletes the catalog and every product in it on Meta. Ads and WhatsApp numbers that use it lose their catalog.
pub async fn delete_ad_catalog(
configuration: &configuration::Configuration,
catalog_id: &str,
account_id: &str,
catalog_account_id: Option<&str>,
) -> Result<models::DeleteAdCatalog200Response, Error<DeleteAdCatalogError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_catalog_id = catalog_id;
let p_query_account_id = account_id;
let p_query_catalog_account_id = catalog_account_id;
let uri_str = format!(
"{}/v1/ads/catalogs/{catalogId}",
configuration.base_path,
catalogId = crate::apis::urlencode(p_path_catalog_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_catalog_account_id {
req_builder = req_builder.query(&[("catalogAccountId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAdCatalog200Response`"))),
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::DeleteAdCatalog200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteAdCatalogError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_ad_catalog_product(
configuration: &configuration::Configuration,
catalog_id: &str,
product_id: &str,
account_id: &str,
catalog_account_id: Option<&str>,
) -> Result<models::DeleteAdCatalogProduct200Response, Error<DeleteAdCatalogProductError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_catalog_id = catalog_id;
let p_path_product_id = product_id;
let p_query_account_id = account_id;
let p_query_catalog_account_id = catalog_account_id;
let uri_str = format!(
"{}/v1/ads/catalogs/{catalogId}/products/{productId}",
configuration.base_path,
catalogId = crate::apis::urlencode(p_path_catalog_id),
productId = crate::apis::urlencode(p_path_product_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_catalog_account_id {
req_builder = req_builder.query(&[("catalogAccountId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAdCatalogProduct200Response`"))),
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::DeleteAdCatalogProduct200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteAdCatalogProductError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn delete_ad_catalog_product_set(
configuration: &configuration::Configuration,
catalog_id: &str,
product_set_id: &str,
account_id: &str,
catalog_account_id: Option<&str>,
) -> Result<models::DeleteAdCatalogProductSet200Response, Error<DeleteAdCatalogProductSetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_catalog_id = catalog_id;
let p_path_product_set_id = product_set_id;
let p_query_account_id = account_id;
let p_query_catalog_account_id = catalog_account_id;
let uri_str = format!(
"{}/v1/ads/catalogs/{catalogId}/product-sets/{productSetId}",
configuration.base_path,
catalogId = crate::apis::urlencode(p_path_catalog_id),
productSetId = crate::apis::urlencode(p_path_product_set_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_catalog_account_id {
req_builder = req_builder.query(&[("catalogAccountId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteAdCatalogProductSet200Response`"))),
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::DeleteAdCatalogProductSet200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteAdCatalogProductSetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_ad_catalog(
configuration: &configuration::Configuration,
catalog_id: &str,
account_id: &str,
catalog_account_id: Option<&str>,
) -> Result<models::CreateAdCatalog201Response, Error<GetAdCatalogError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_catalog_id = catalog_id;
let p_query_account_id = account_id;
let p_query_catalog_account_id = catalog_account_id;
let uri_str = format!(
"{}/v1/ads/catalogs/{catalogId}",
configuration.base_path,
catalogId = crate::apis::urlencode(p_path_catalog_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_catalog_account_id {
req_builder = req_builder.query(&[("catalogAccountId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateAdCatalog201Response`"))),
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::CreateAdCatalog201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetAdCatalogError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_ad_catalog_batch(
configuration: &configuration::Configuration,
catalog_id: &str,
handle: &str,
account_id: &str,
catalog_account_id: Option<&str>,
) -> Result<models::GetAdCatalogBatch200Response, Error<GetAdCatalogBatchError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_catalog_id = catalog_id;
let p_path_handle = handle;
let p_query_account_id = account_id;
let p_query_catalog_account_id = catalog_account_id;
let uri_str = format!(
"{}/v1/ads/catalogs/{catalogId}/batches/{handle}",
configuration.base_path,
catalogId = crate::apis::urlencode(p_path_catalog_id),
handle = crate::apis::urlencode(p_path_handle)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_catalog_account_id {
req_builder = req_builder.query(&[("catalogAccountId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetAdCatalogBatch200Response`"))),
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::GetAdCatalogBatch200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetAdCatalogBatchError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn get_ad_catalog_product(
configuration: &configuration::Configuration,
catalog_id: &str,
product_id: &str,
account_id: &str,
catalog_account_id: Option<&str>,
) -> Result<models::CreateAdCatalogProduct201Response, Error<GetAdCatalogProductError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_catalog_id = catalog_id;
let p_path_product_id = product_id;
let p_query_account_id = account_id;
let p_query_catalog_account_id = catalog_account_id;
let uri_str = format!(
"{}/v1/ads/catalogs/{catalogId}/products/{productId}",
configuration.base_path,
catalogId = crate::apis::urlencode(p_path_catalog_id),
productId = crate::apis::urlencode(p_path_product_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_catalog_account_id {
req_builder = req_builder.query(&[("catalogAccountId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateAdCatalogProduct201Response`"))),
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::CreateAdCatalogProduct201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetAdCatalogProductError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn list_ad_catalog_feed_uploads(
configuration: &configuration::Configuration,
catalog_id: &str,
feed_id: &str,
account_id: &str,
catalog_account_id: Option<&str>,
) -> Result<models::ListAdCatalogFeedUploads200Response, Error<ListAdCatalogFeedUploadsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_catalog_id = catalog_id;
let p_path_feed_id = feed_id;
let p_query_account_id = account_id;
let p_query_catalog_account_id = catalog_account_id;
let uri_str = format!(
"{}/v1/ads/catalogs/{catalogId}/feeds/{feedId}/uploads",
configuration.base_path,
catalogId = crate::apis::urlencode(p_path_catalog_id),
feedId = crate::apis::urlencode(p_path_feed_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_catalog_account_id {
req_builder = req_builder.query(&[("catalogAccountId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListAdCatalogFeedUploads200Response`"))),
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::ListAdCatalogFeedUploads200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAdCatalogFeedUploadsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn list_ad_catalog_feeds(
configuration: &configuration::Configuration,
catalog_id: &str,
account_id: &str,
catalog_account_id: Option<&str>,
) -> Result<models::ListAdCatalogFeeds200Response, Error<ListAdCatalogFeedsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_catalog_id = catalog_id;
let p_query_account_id = account_id;
let p_query_catalog_account_id = catalog_account_id;
let uri_str = format!(
"{}/v1/ads/catalogs/{catalogId}/feeds",
configuration.base_path,
catalogId = crate::apis::urlencode(p_path_catalog_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_catalog_account_id {
req_builder = req_builder.query(&[("catalogAccountId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListAdCatalogFeeds200Response`"))),
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::ListAdCatalogFeeds200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAdCatalogFeedsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists a Meta product catalog's product sets, the unit a catalog ad promotes. Pass the chosen set id, not the parent catalog id, as `promotedObject.productSetId` on POST /v1/ads/create with `goal: catalog_sales`.
pub async fn list_ad_catalog_product_sets(
configuration: &configuration::Configuration,
catalog_id: &str,
account_id: &str,
catalog_account_id: Option<&str>,
) -> Result<models::ListAdCatalogProductSets200Response, Error<ListAdCatalogProductSetsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_catalog_id = catalog_id;
let p_query_account_id = account_id;
let p_query_catalog_account_id = catalog_account_id;
let uri_str = format!(
"{}/v1/ads/catalogs/{catalogId}/product-sets",
configuration.base_path,
catalogId = crate::apis::urlencode(p_path_catalog_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_catalog_account_id {
req_builder = req_builder.query(&[("catalogAccountId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListAdCatalogProductSets200Response`"))),
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::ListAdCatalogProductSets200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAdCatalogProductSetsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Pages through the catalog's products. Filter by your own `retailerId` to look one up. `price` and `salePrice` come back formatted by Meta (for example \"€49.90\").
pub async fn list_ad_catalog_products(
configuration: &configuration::Configuration,
catalog_id: &str,
account_id: &str,
catalog_account_id: Option<&str>,
limit: Option<i32>,
after: Option<&str>,
retailer_id: Option<&str>,
) -> Result<models::ListAdCatalogProducts200Response, Error<ListAdCatalogProductsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_catalog_id = catalog_id;
let p_query_account_id = account_id;
let p_query_catalog_account_id = catalog_account_id;
let p_query_limit = limit;
let p_query_after = after;
let p_query_retailer_id = retailer_id;
let uri_str = format!(
"{}/v1/ads/catalogs/{catalogId}/products",
configuration.base_path,
catalogId = crate::apis::urlencode(p_path_catalog_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_catalog_account_id {
req_builder = req_builder.query(&[("catalogAccountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_after {
req_builder = req_builder.query(&[("after", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_retailer_id {
req_builder = req_builder.query(&[("retailerId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListAdCatalogProducts200Response`"))),
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::ListAdCatalogProducts200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAdCatalogProductsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists the Meta Commerce catalogs of a business portfolio (owned + agency-shared). The business comes from `businessId`, else the ad account's owner (`adAccountId`), else the WhatsApp Business Account's owner when `accountId` is a WhatsApp connection, else the only business the Meta login can see. Reads work with scopes customers already granted.
pub async fn list_ad_catalogs(
configuration: &configuration::Configuration,
account_id: &str,
catalog_account_id: Option<&str>,
ad_account_id: Option<&str>,
business_id: Option<&str>,
) -> Result<models::ListAdCatalogs200Response, Error<ListAdCatalogsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_catalog_account_id = catalog_account_id;
let p_query_ad_account_id = ad_account_id;
let p_query_business_id = business_id;
let uri_str = format!("{}/v1/ads/catalogs", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("accountId", &p_query_account_id.to_string())]);
if let Some(ref param_value) = p_query_catalog_account_id {
req_builder = req_builder.query(&[("catalogAccountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_ad_account_id {
req_builder = req_builder.query(&[("adAccountId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_business_id {
req_builder = req_builder.query(&[("businessId", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListAdCatalogs200Response`"))),
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::ListAdCatalogs200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListAdCatalogsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Partial update: only the fields sent change. `retailerId` cannot change.
pub async fn update_ad_catalog_product(
configuration: &configuration::Configuration,
catalog_id: &str,
product_id: &str,
update_ad_catalog_product_request: models::UpdateAdCatalogProductRequest,
) -> Result<models::CreateAdCatalogProduct201Response, Error<UpdateAdCatalogProductError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_catalog_id = catalog_id;
let p_path_product_id = product_id;
let p_body_update_ad_catalog_product_request = update_ad_catalog_product_request;
let uri_str = format!(
"{}/v1/ads/catalogs/{catalogId}/products/{productId}",
configuration.base_path,
catalogId = crate::apis::urlencode(p_path_catalog_id),
productId = crate::apis::urlencode(p_path_product_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_ad_catalog_product_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateAdCatalogProduct201Response`"))),
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::CreateAdCatalogProduct201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateAdCatalogProductError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
pub async fn update_ad_catalog_product_set(
configuration: &configuration::Configuration,
catalog_id: &str,
product_set_id: &str,
update_ad_catalog_product_set_request: models::UpdateAdCatalogProductSetRequest,
) -> Result<models::CreateAdCatalogProductSet201Response, Error<UpdateAdCatalogProductSetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_catalog_id = catalog_id;
let p_path_product_set_id = product_set_id;
let p_body_update_ad_catalog_product_set_request = update_ad_catalog_product_set_request;
let uri_str = format!(
"{}/v1/ads/catalogs/{catalogId}/product-sets/{productSetId}",
configuration.base_path,
catalogId = crate::apis::urlencode(p_path_catalog_id),
productSetId = crate::apis::urlencode(p_path_product_set_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(ref token) = configuration.bearer_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
req_builder = req_builder.json(&p_body_update_ad_catalog_product_set_request);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateAdCatalogProductSet201Response`"))),
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::CreateAdCatalogProductSet201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateAdCatalogProductSetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}