/*
* 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.440.2
* 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 [`add_commerce_discount_codes`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddCommerceDiscountCodesError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`add_commerce_marketing_engagement`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddCommerceMarketingEngagementError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`add_commerce_product_images`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum AddCommerceProductImagesError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`change_commerce_collection_channels`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ChangeCommerceCollectionChannelsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`change_commerce_collection_products`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ChangeCommerceCollectionProductsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`change_commerce_inventory`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ChangeCommerceInventoryError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`change_commerce_product_channels`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ChangeCommerceProductChannelsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`change_commerce_product_state`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ChangeCommerceProductStateError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`change_commerce_product_tags`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ChangeCommerceProductTagsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_commerce_catalog_sync`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCommerceCatalogSyncError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_commerce_collection`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCommerceCollectionError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_commerce_discount`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCommerceDiscountError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_commerce_menu`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCommerceMenuError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_commerce_metaobject`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCommerceMetaobjectError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_commerce_page`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCommercePageError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_commerce_product`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCommerceProductError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_commerce_product_options`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCommerceProductOptionsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_commerce_product_variants`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCommerceProductVariantsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_commerce_redirect`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCommerceRedirectError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_commerce_catalog_sync`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCommerceCatalogSyncError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_commerce_collection`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCommerceCollectionError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_commerce_collection_metafields`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCommerceCollectionMetafieldsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_commerce_discount`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCommerceDiscountError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_commerce_marketing_activity`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCommerceMarketingActivityError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_commerce_menu`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCommerceMenuError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_commerce_metaobject`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCommerceMetaobjectError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_commerce_page`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCommercePageError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_commerce_price_list_prices`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCommercePriceListPricesError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_commerce_product_metafields`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCommerceProductMetafieldsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_commerce_product_options`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCommerceProductOptionsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_commerce_product_variants`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCommerceProductVariantsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`delete_commerce_redirect`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCommerceRedirectError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`duplicate_commerce_product`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DuplicateCommerceProductError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_commerce_catalog_sync`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCommerceCatalogSyncError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_commerce_collection`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCommerceCollectionError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_commerce_discount`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCommerceDiscountError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_commerce_menu`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCommerceMenuError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_commerce_metaobject`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCommerceMetaobjectError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_commerce_order`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCommerceOrderError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_commerce_page`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCommercePageError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_commerce_product`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCommerceProductError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_commerce_store`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCommerceStoreError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_commerce_catalog_syncs`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCommerceCatalogSyncsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status404(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_commerce_channels`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCommerceChannelsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_commerce_collection_metafields`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCommerceCollectionMetafieldsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_commerce_collections`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCommerceCollectionsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_commerce_discounts`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCommerceDiscountsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_commerce_inventory`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCommerceInventoryError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_commerce_locations`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCommerceLocationsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_commerce_markets`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCommerceMarketsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_commerce_menus`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCommerceMenusError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_commerce_metaobject_definitions`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCommerceMetaobjectDefinitionsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_commerce_metaobjects`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCommerceMetaobjectsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_commerce_orders`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCommerceOrdersError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_commerce_pages`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCommercePagesError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_commerce_price_lists`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCommercePriceListsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_commerce_product_metafields`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCommerceProductMetafieldsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_commerce_products`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCommerceProductsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_commerce_redirects`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCommerceRedirectsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`remove_commerce_product_images`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RemoveCommerceProductImagesError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`reorder_commerce_collection_products`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReorderCommerceCollectionProductsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`reorder_commerce_product_images`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReorderCommerceProductImagesError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`run_commerce_catalog_sync`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RunCommerceCatalogSyncError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status404(),
Status409(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`set_commerce_collection_metafields`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetCommerceCollectionMetafieldsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`set_commerce_discount_active`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetCommerceDiscountActiveError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`set_commerce_price_list_prices`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetCommercePriceListPricesError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`set_commerce_product_metafields`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SetCommerceProductMetafieldsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_commerce_collection`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCommerceCollectionError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_commerce_discount`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCommerceDiscountError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_commerce_menu`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCommerceMenuError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_commerce_metaobject`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCommerceMetaobjectError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_commerce_page`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCommercePageError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_commerce_product`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCommerceProductError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_commerce_product_prices`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCommerceProductPricesError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_commerce_redirect`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCommerceRedirectError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`upsert_commerce_marketing_activity`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpsertCommerceMarketingActivityError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(),
Status404(),
Status429(),
UnknownValue(serde_json::Value),
}
/// Adds up to 250 more codes to a code discount, for example one per influencer. The platform adds them in the background. Needs discounts.codes, which WooCommerce stores do not have.
pub async fn add_commerce_discount_codes(
configuration: &configuration::Configuration,
discount_id: &str,
add_commerce_discount_codes_request: models::AddCommerceDiscountCodesRequest,
) -> Result<models::ReorderCommerceProductImages200Response, Error<AddCommerceDiscountCodesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_discount_id = discount_id;
let p_body_add_commerce_discount_codes_request = add_commerce_discount_codes_request;
let uri_str = format!(
"{}/v1/commerce/discounts/{discountId}/codes",
configuration.base_path,
discountId = crate::apis::urlencode(p_path_discount_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_add_commerce_discount_codes_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::ReorderCommerceProductImages200Response`"))),
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::ReorderCommerceProductImages200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AddCommerceDiscountCodesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Reports one day's numbers for an activity (UTC day), shown next to it in the store's Marketing section.
pub async fn add_commerce_marketing_engagement(
configuration: &configuration::Configuration,
remote_id: &str,
add_commerce_marketing_engagement_request: models::AddCommerceMarketingEngagementRequest,
) -> Result<
models::AddCommerceMarketingEngagement201Response,
Error<AddCommerceMarketingEngagementError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_remote_id = remote_id;
let p_body_add_commerce_marketing_engagement_request =
add_commerce_marketing_engagement_request;
let uri_str = format!(
"{}/v1/commerce/marketing-activities/{remoteId}/engagements",
configuration.base_path,
remoteId = crate::apis::urlencode(p_path_remote_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_add_commerce_marketing_engagement_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::AddCommerceMarketingEngagement201Response`"))),
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::AddCommerceMarketingEngagement201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AddCommerceMarketingEngagementError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Adds images from public URLs. The platform fetches them, so they can appear on the product a few seconds after the call returns.
pub async fn add_commerce_product_images(
configuration: &configuration::Configuration,
product_id: &str,
add_commerce_product_images_request: models::AddCommerceProductImagesRequest,
) -> Result<models::CreateCommerceProduct201Response, Error<AddCommerceProductImagesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_product_id = product_id;
let p_body_add_commerce_product_images_request = add_commerce_product_images_request;
let uri_str = format!(
"{}/v1/commerce/products/{productId}/images",
configuration.base_path,
productId = crate::apis::urlencode(p_path_product_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_add_commerce_product_images_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::CreateCommerceProduct201Response`"))),
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::CreateCommerceProduct201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<AddCommerceProductImagesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Publishes to and/or unpublishes from sales channels (the online store, Shop, POS and others). List channels with GET /v1/commerce/channels.
pub async fn change_commerce_collection_channels(
configuration: &configuration::Configuration,
collection_id: &str,
change_commerce_product_channels_request: models::ChangeCommerceProductChannelsRequest,
) -> Result<
models::ChangeCommerceCollectionChannels200Response,
Error<ChangeCommerceCollectionChannelsError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_id = collection_id;
let p_body_change_commerce_product_channels_request = change_commerce_product_channels_request;
let uri_str = format!(
"{}/v1/commerce/collections/{collectionId}/channels",
configuration.base_path,
collectionId = crate::apis::urlencode(p_path_collection_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_change_commerce_product_channels_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::ChangeCommerceCollectionChannels200Response`"))),
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::ChangeCommerceCollectionChannels200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ChangeCommerceCollectionChannelsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Adds and/or removes hand-picked products. Products a collection includes through its own rules are not affected. `pending` is true when the platform finishes the change in the background; the product count then catches up a few seconds later.
pub async fn change_commerce_collection_products(
configuration: &configuration::Configuration,
collection_id: &str,
change_commerce_collection_products_request: models::ChangeCommerceCollectionProductsRequest,
) -> Result<
models::ChangeCommerceCollectionProducts200Response,
Error<ChangeCommerceCollectionProductsError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_id = collection_id;
let p_body_change_commerce_collection_products_request =
change_commerce_collection_products_request;
let uri_str = format!(
"{}/v1/commerce/collections/{collectionId}/products",
configuration.base_path,
collectionId = crate::apis::urlencode(p_path_collection_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_change_commerce_collection_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::ChangeCommerceCollectionProducts200Response`"))),
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::ChangeCommerceCollectionProducts200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ChangeCommerceCollectionProductsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// `set` makes `quantity` the new available count; `adjust` adds `quantity` (negative to subtract). The variant must be stocked at the location. Answers the product's stock after the change.
pub async fn change_commerce_inventory(
configuration: &configuration::Configuration,
product_id: &str,
change_commerce_inventory_request: models::ChangeCommerceInventoryRequest,
) -> Result<models::ListCommerceInventory200Response, Error<ChangeCommerceInventoryError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_product_id = product_id;
let p_body_change_commerce_inventory_request = change_commerce_inventory_request;
let uri_str = format!(
"{}/v1/commerce/products/{productId}/inventory",
configuration.base_path,
productId = crate::apis::urlencode(p_path_product_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_change_commerce_inventory_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::ListCommerceInventory200Response`"))),
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::ListCommerceInventory200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ChangeCommerceInventoryError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Publishes to and/or unpublishes from sales channels (the online store, Shop, POS and others). List channels with GET /v1/commerce/channels.
pub async fn change_commerce_product_channels(
configuration: &configuration::Configuration,
product_id: &str,
change_commerce_product_channels_request: models::ChangeCommerceProductChannelsRequest,
) -> Result<
models::ChangeCommerceProductChannels200Response,
Error<ChangeCommerceProductChannelsError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_product_id = product_id;
let p_body_change_commerce_product_channels_request = change_commerce_product_channels_request;
let uri_str = format!(
"{}/v1/commerce/products/{productId}/channels",
configuration.base_path,
productId = crate::apis::urlencode(p_path_product_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_change_commerce_product_channels_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::ChangeCommerceProductChannels200Response`"))),
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::ChangeCommerceProductChannels200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ChangeCommerceProductChannelsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Applies one action to up to 50 products and reports each product's outcome, so one failure does not abort the rest. On Shopify, `deactivate` sets the product to draft and `delete` is permanent.
pub async fn change_commerce_product_state(
configuration: &configuration::Configuration,
change_commerce_product_state_request: models::ChangeCommerceProductStateRequest,
) -> Result<models::ChangeCommerceProductState200Response, Error<ChangeCommerceProductStateError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_change_commerce_product_state_request = change_commerce_product_state_request;
let uri_str = format!("{}/v1/commerce/products/state", 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_change_commerce_product_state_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::ChangeCommerceProductState200Response`"))),
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::ChangeCommerceProductState200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ChangeCommerceProductStateError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Adds and/or removes tags on up to 50 products and reports each product's outcome.
pub async fn change_commerce_product_tags(
configuration: &configuration::Configuration,
change_commerce_product_tags_request: models::ChangeCommerceProductTagsRequest,
) -> Result<models::ChangeCommerceProductTags200Response, Error<ChangeCommerceProductTagsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_change_commerce_product_tags_request = change_commerce_product_tags_request;
let uri_str = format!("{}/v1/commerce/products/tags", 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_change_commerce_product_tags_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::ChangeCommerceProductTags200Response`"))),
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::ChangeCommerceProductTags200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ChangeCommerceProductTagsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Keeps a Meta product catalog in sync with the store, for catalog ads (`goal: catalog_sales`) and Shops. ### How the sync runs 1. The first full run starts right away in the background; `runStatus` and the item counts report its outcome. 2. After that, product changes on the store update the catalog within minutes. 3. A daily full run removes items for products or variants the store no longer has. Every active product variant that is published to the online store and has an image becomes a catalog item, grouped by product (`item_group_id`). Items are namespaced to the store, so a catalog can take several stores and a run never touches items it did not create. ### Catalog account `catalogAccountId` is a connected facebook, instagram or metaads account whose Meta login can manage the catalog (the catalog_management permission). Find catalogs with `GET /v1/ads/catalogs`.
pub async fn create_commerce_catalog_sync(
configuration: &configuration::Configuration,
create_commerce_catalog_sync_request: models::CreateCommerceCatalogSyncRequest,
) -> Result<models::CreateCommerceCatalogSync202Response, Error<CreateCommerceCatalogSyncError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_commerce_catalog_sync_request = create_commerce_catalog_sync_request;
let uri_str = format!("{}/v1/commerce/catalog-syncs", 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_commerce_catalog_sync_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::CreateCommerceCatalogSync202Response`"))),
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::CreateCommerceCatalogSync202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCommerceCatalogSyncError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates a collection, optionally with hand-picked products. On Shopify the collection starts unpublished from the online store; publish it from the Shopify admin.
pub async fn create_commerce_collection(
configuration: &configuration::Configuration,
create_commerce_collection_request: models::CreateCommerceCollectionRequest,
) -> Result<models::CreateCommerceCollection201Response, Error<CreateCommerceCollectionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_commerce_collection_request = create_commerce_collection_request;
let uri_str = format!("{}/v1/commerce/collections", 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_commerce_collection_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::CreateCommerceCollection201Response`"))),
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::CreateCommerceCollection201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCommerceCollectionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates a code discount (buyers enter a code) or an automatic one (applied at checkout), as a percentage, a fixed amount or free shipping. It applies to every product unless productIds or collectionIds narrow it, and to every buyer.
pub async fn create_commerce_discount(
configuration: &configuration::Configuration,
create_commerce_discount_request: models::CreateCommerceDiscountRequest,
) -> Result<models::CreateCommerceDiscount201Response, Error<CreateCommerceDiscountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_commerce_discount_request = create_commerce_discount_request;
let uri_str = format!("{}/v1/commerce/discounts", 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_commerce_discount_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::CreateCommerceDiscount201Response`"))),
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::CreateCommerceDiscount201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCommerceDiscountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates a navigation menu from `title`, `handle` and up to 100 `items`, and returns it with status 201. Shopify only. Needs navigation.write.
pub async fn create_commerce_menu(
configuration: &configuration::Configuration,
create_commerce_menu_request: models::CreateCommerceMenuRequest,
) -> Result<models::CreateCommerceMenu201Response, Error<CreateCommerceMenuError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_commerce_menu_request = create_commerce_menu_request;
let uri_str = format!("{}/v1/commerce/menus", 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_commerce_menu_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::CreateCommerceMenu201Response`"))),
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::CreateCommerceMenu201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCommerceMenuError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates a metaobject of `type` with its `fields` (key and string value, up to 100) and an optional `handle`, and returns it with status 201. Shopify only. Needs metaobjects.write.
pub async fn create_commerce_metaobject(
configuration: &configuration::Configuration,
create_commerce_metaobject_request: models::CreateCommerceMetaobjectRequest,
) -> Result<models::CreateCommerceMetaobject201Response, Error<CreateCommerceMetaobjectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_commerce_metaobject_request = create_commerce_metaobject_request;
let uri_str = format!("{}/v1/commerce/metaobjects", 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_commerce_metaobject_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::CreateCommerceMetaobject201Response`"))),
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::CreateCommerceMetaobject201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCommerceMetaobjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates a content page from `title`, optional `handle`, `bodyHtml` and `isPublished`, and returns it with status 201. Needs pages.write.
pub async fn create_commerce_page(
configuration: &configuration::Configuration,
create_commerce_page_request: models::CreateCommercePageRequest,
) -> Result<models::CreateCommercePage201Response, Error<CreateCommercePageError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_commerce_page_request = create_commerce_page_request;
let uri_str = format!("{}/v1/commerce/pages", 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_commerce_page_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::CreateCommercePage201Response`"))),
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::CreateCommercePage201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCommercePageError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates a product with its options and variants. - `status` defaults to `draft`: no platform offers a sandbox for product writes, so nothing goes on sale unless you ask for `active`. - A product without `options` has exactly one variant. - Images are fetched by the platform from the given URLs and may appear on the product a few seconds later.
pub async fn create_commerce_product(
configuration: &configuration::Configuration,
create_commerce_product_request: models::CreateCommerceProductRequest,
) -> Result<models::CreateCommerceProduct201Response, Error<CreateCommerceProductError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_commerce_product_request = create_commerce_product_request;
let uri_str = format!("{}/v1/commerce/products", 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_commerce_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::CreateCommerceProduct201Response`"))),
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::CreateCommerceProduct201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCommerceProductError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Adds option axes (e.g. Size, Color) and their values. With createVariants true the platform creates a variant for every new combination; otherwise existing variants take the first value.
pub async fn create_commerce_product_options(
configuration: &configuration::Configuration,
product_id: &str,
create_commerce_product_options_request: models::CreateCommerceProductOptionsRequest,
) -> Result<models::CreateCommerceProduct201Response, Error<CreateCommerceProductOptionsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_product_id = product_id;
let p_body_create_commerce_product_options_request = create_commerce_product_options_request;
let uri_str = format!(
"{}/v1/commerce/products/{productId}/options",
configuration.base_path,
productId = crate::apis::urlencode(p_path_product_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_commerce_product_options_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::CreateCommerceProduct201Response`"))),
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::CreateCommerceProduct201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCommerceProductOptionsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Adds variants to a product. Each variant names a value for every product option (create options first with POST .../options). A product's placeholder default variant is replaced when real ones arrive.
pub async fn create_commerce_product_variants(
configuration: &configuration::Configuration,
product_id: &str,
create_commerce_product_variants_request: models::CreateCommerceProductVariantsRequest,
) -> Result<models::CreateCommerceProduct201Response, Error<CreateCommerceProductVariantsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_product_id = product_id;
let p_body_create_commerce_product_variants_request = create_commerce_product_variants_request;
let uri_str = format!(
"{}/v1/commerce/products/{productId}/variants",
configuration.base_path,
productId = crate::apis::urlencode(p_path_product_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_commerce_product_variants_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::CreateCommerceProduct201Response`"))),
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::CreateCommerceProduct201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCommerceProductVariantsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates a redirect from `path` (starting with `/`) to `target` (a path or a full URL) and returns it with status 201. Shopify only. Needs navigation.write.
pub async fn create_commerce_redirect(
configuration: &configuration::Configuration,
create_commerce_redirect_request: models::CreateCommerceRedirectRequest,
) -> Result<models::CreateCommerceRedirect201Response, Error<CreateCommerceRedirectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_commerce_redirect_request = create_commerce_redirect_request;
let uri_str = format!("{}/v1/commerce/redirects", 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_commerce_redirect_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::CreateCommerceRedirect201Response`"))),
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::CreateCommerceRedirect201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCommerceRedirectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Stops syncing. Items already in the catalog stay there.
pub async fn delete_commerce_catalog_sync(
configuration: &configuration::Configuration,
sync_id: &str,
) -> Result<models::DeleteCommerceCatalogSync200Response, Error<DeleteCommerceCatalogSyncError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_sync_id = sync_id;
let uri_str = format!(
"{}/v1/commerce/catalog-syncs/{syncId}",
configuration.base_path,
syncId = crate::apis::urlencode(p_path_sync_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &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());
};
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::DeleteCommerceCatalogSync200Response`"))),
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::DeleteCommerceCatalogSync200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCommerceCatalogSyncError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Deletes the collection. Its products are not affected.
pub async fn delete_commerce_collection(
configuration: &configuration::Configuration,
collection_id: &str,
account_id: &str,
) -> Result<models::DeleteCommerceCollection200Response, Error<DeleteCommerceCollectionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_id = collection_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/commerce/collections/{collectionId}",
configuration.base_path,
collectionId = crate::apis::urlencode(p_path_collection_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 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::DeleteCommerceCollection200Response`"))),
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::DeleteCommerceCollection200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCommerceCollectionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Deletes the collection metafields named in `keys` (comma-separated `namespace.key`, up to 25). Needs collections.metafields: WooCommerce answers 400 platform_not_supported.
pub async fn delete_commerce_collection_metafields(
configuration: &configuration::Configuration,
collection_id: &str,
account_id: &str,
keys: &str,
) -> Result<
models::DeleteCommerceProductMetafields200Response,
Error<DeleteCommerceCollectionMetafieldsError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_id = collection_id;
let p_query_account_id = account_id;
let p_query_keys = keys;
let uri_str = format!(
"{}/v1/commerce/collections/{collectionId}/metafields",
configuration.base_path,
collectionId = crate::apis::urlencode(p_path_collection_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())]);
req_builder = req_builder.query(&[("keys", &p_query_keys.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::DeleteCommerceProductMetafields200Response`"))),
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::DeleteCommerceProductMetafields200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCommerceCollectionMetafieldsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Deletes the discount; its codes stop working at checkout. This cannot be undone. Needs discounts.write.
pub async fn delete_commerce_discount(
configuration: &configuration::Configuration,
discount_id: &str,
account_id: &str,
) -> Result<models::DeleteCommerceDiscount200Response, Error<DeleteCommerceDiscountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_discount_id = discount_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/commerce/discounts/{discountId}",
configuration.base_path,
discountId = crate::apis::urlencode(p_path_discount_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 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::DeleteCommerceDiscount200Response`"))),
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::DeleteCommerceDiscount200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCommerceDiscountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Deletes the marketing activity you created with PUT /v1/commerce/marketing-activities, identified by the `remoteId` you gave it. Shopify only. Needs marketing.write.
pub async fn delete_commerce_marketing_activity(
configuration: &configuration::Configuration,
remote_id: &str,
account_id: &str,
) -> Result<
models::DeleteCommerceMarketingActivity200Response,
Error<DeleteCommerceMarketingActivityError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_remote_id = remote_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/commerce/marketing-activities/{remoteId}",
configuration.base_path,
remoteId = crate::apis::urlencode(p_path_remote_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 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::DeleteCommerceMarketingActivity200Response`"))),
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::DeleteCommerceMarketingActivity200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCommerceMarketingActivityError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Deletes the navigation menu. Shopify only. Needs navigation.write.
pub async fn delete_commerce_menu(
configuration: &configuration::Configuration,
menu_id: &str,
account_id: &str,
) -> Result<models::DeleteCommerceMenu200Response, Error<DeleteCommerceMenuError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_menu_id = menu_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/commerce/menus/{menuId}",
configuration.base_path,
menuId = crate::apis::urlencode(p_path_menu_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 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::DeleteCommerceMenu200Response`"))),
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::DeleteCommerceMenu200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCommerceMenuError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Deletes the metaobject. References to it from metafields stop resolving. Shopify only. Needs metaobjects.write.
pub async fn delete_commerce_metaobject(
configuration: &configuration::Configuration,
metaobject_id: &str,
account_id: &str,
) -> Result<models::DeleteCommerceMetaobject200Response, Error<DeleteCommerceMetaobjectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_metaobject_id = metaobject_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/commerce/metaobjects/{metaobjectId}",
configuration.base_path,
metaobjectId = crate::apis::urlencode(p_path_metaobject_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 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::DeleteCommerceMetaobject200Response`"))),
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::DeleteCommerceMetaobject200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCommerceMetaobjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Deletes the page from the store. This cannot be undone. Needs pages.write.
pub async fn delete_commerce_page(
configuration: &configuration::Configuration,
page_id: &str,
account_id: &str,
) -> Result<models::DeleteCommercePage200Response, Error<DeleteCommercePageError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_page_id = page_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/commerce/pages/{pageId}",
configuration.base_path,
pageId = crate::apis::urlencode(p_path_page_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 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::DeleteCommercePage200Response`"))),
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::DeleteCommercePage200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCommercePageError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The variants go back to the market's converted price.
pub async fn delete_commerce_price_list_prices(
configuration: &configuration::Configuration,
price_list_id: &str,
account_id: &str,
variant_ids: &str,
) -> Result<
models::DeleteCommercePriceListPrices200Response,
Error<DeleteCommercePriceListPricesError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_price_list_id = price_list_id;
let p_query_account_id = account_id;
let p_query_variant_ids = variant_ids;
let uri_str = format!(
"{}/v1/commerce/price-lists/{priceListId}/prices",
configuration.base_path,
priceListId = crate::apis::urlencode(p_path_price_list_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())]);
req_builder = req_builder.query(&[("variantIds", &p_query_variant_ids.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::DeleteCommercePriceListPrices200Response`"))),
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::DeleteCommercePriceListPrices200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCommercePriceListPricesError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Deletes the product custom fields named in `keys` (comma-separated `namespace.key`, up to 25) and returns how many were deleted. Needs metafields.write.
pub async fn delete_commerce_product_metafields(
configuration: &configuration::Configuration,
product_id: &str,
account_id: &str,
keys: &str,
) -> Result<
models::DeleteCommerceProductMetafields200Response,
Error<DeleteCommerceProductMetafieldsError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_product_id = product_id;
let p_query_account_id = account_id;
let p_query_keys = keys;
let uri_str = format!(
"{}/v1/commerce/products/{productId}/metafields",
configuration.base_path,
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())]);
req_builder = req_builder.query(&[("keys", &p_query_keys.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::DeleteCommerceProductMetafields200Response`"))),
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::DeleteCommerceProductMetafields200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCommerceProductMetafieldsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Deletes options by name, with the variants that depended on them.
pub async fn delete_commerce_product_options(
configuration: &configuration::Configuration,
product_id: &str,
account_id: &str,
names: &str,
) -> Result<models::CreateCommerceProduct201Response, Error<DeleteCommerceProductOptionsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_product_id = product_id;
let p_query_account_id = account_id;
let p_query_names = names;
let uri_str = format!(
"{}/v1/commerce/products/{productId}/options",
configuration.base_path,
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())]);
req_builder = req_builder.query(&[("names", &p_query_names.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::CreateCommerceProduct201Response`"))),
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::CreateCommerceProduct201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCommerceProductOptionsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Deletes the variants in `variantIds` (comma-separated, up to 100) and returns the updated product. A product keeps at least one variant, so deleting every variant is refused by the platform. Needs products.variants.
pub async fn delete_commerce_product_variants(
configuration: &configuration::Configuration,
product_id: &str,
account_id: &str,
variant_ids: &str,
) -> Result<models::CreateCommerceProduct201Response, Error<DeleteCommerceProductVariantsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_product_id = product_id;
let p_query_account_id = account_id;
let p_query_variant_ids = variant_ids;
let uri_str = format!(
"{}/v1/commerce/products/{productId}/variants",
configuration.base_path,
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())]);
req_builder = req_builder.query(&[("variantIds", &p_query_variant_ids.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::CreateCommerceProduct201Response`"))),
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::CreateCommerceProduct201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCommerceProductVariantsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Deletes the redirect; the old path answers 404 again. Shopify only. Needs navigation.write.
pub async fn delete_commerce_redirect(
configuration: &configuration::Configuration,
redirect_id: &str,
account_id: &str,
) -> Result<models::DeleteCommerceRedirect200Response, Error<DeleteCommerceRedirectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_redirect_id = redirect_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/commerce/redirects/{redirectId}",
configuration.base_path,
redirectId = crate::apis::urlencode(p_path_redirect_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 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::DeleteCommerceRedirect200Response`"))),
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::DeleteCommerceRedirect200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCommerceRedirectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Copies a product with its options, variants and (by default) images. The copy starts as a draft.
pub async fn duplicate_commerce_product(
configuration: &configuration::Configuration,
product_id: &str,
duplicate_commerce_product_request: models::DuplicateCommerceProductRequest,
) -> Result<models::CreateCommerceProduct201Response, Error<DuplicateCommerceProductError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_product_id = product_id;
let p_body_duplicate_commerce_product_request = duplicate_commerce_product_request;
let uri_str = format!(
"{}/v1/commerce/products/{productId}/duplicate",
configuration.base_path,
productId = crate::apis::urlencode(p_path_product_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_duplicate_commerce_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::CreateCommerceProduct201Response`"))),
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::CreateCommerceProduct201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DuplicateCommerceProductError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// One catalog sync with the status and counts of its last run (`itemsSent`, `itemsSkipped`, `itemsDeleted`, `lastError`). Poll it after POST /v1/commerce/catalog-syncs/{syncId}/run to follow a run.
pub async fn get_commerce_catalog_sync(
configuration: &configuration::Configuration,
sync_id: &str,
) -> Result<models::CreateCommerceCatalogSync202Response, Error<GetCommerceCatalogSyncError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_sync_id = sync_id;
let uri_str = format!(
"{}/v1/commerce/catalog-syncs/{syncId}",
configuration.base_path,
syncId = crate::apis::urlencode(p_path_sync_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &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());
};
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::CreateCommerceCatalogSync202Response`"))),
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::CreateCommerceCatalogSync202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCommerceCatalogSyncError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// One collection (a category on WooCommerce) with its image, sort order and product count. List its products with GET /v1/commerce/products?collectionId=. Needs collections.read.
pub async fn get_commerce_collection(
configuration: &configuration::Configuration,
collection_id: &str,
account_id: &str,
) -> Result<models::CreateCommerceCollection201Response, Error<GetCommerceCollectionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_id = collection_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/commerce/collections/{collectionId}",
configuration.base_path,
collectionId = crate::apis::urlencode(p_path_collection_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 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::CreateCommerceCollection201Response`"))),
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::CreateCommerceCollection201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCommerceCollectionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// One discount with its value, targets, minimum, usage and schedule. Needs discounts.read.
pub async fn get_commerce_discount(
configuration: &configuration::Configuration,
discount_id: &str,
account_id: &str,
) -> Result<models::CreateCommerceDiscount201Response, Error<GetCommerceDiscountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_discount_id = discount_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/commerce/discounts/{discountId}",
configuration.base_path,
discountId = crate::apis::urlencode(p_path_discount_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 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::CreateCommerceDiscount201Response`"))),
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::CreateCommerceDiscount201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCommerceDiscountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// One navigation menu with its nested items. Shopify only. Needs navigation.read.
pub async fn get_commerce_menu(
configuration: &configuration::Configuration,
menu_id: &str,
account_id: &str,
) -> Result<models::CreateCommerceMenu201Response, Error<GetCommerceMenuError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_menu_id = menu_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/commerce/menus/{menuId}",
configuration.base_path,
menuId = crate::apis::urlencode(p_path_menu_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 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::CreateCommerceMenu201Response`"))),
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::CreateCommerceMenu201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCommerceMenuError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// One metaobject with its fields. Shopify only. Needs metaobjects.read.
pub async fn get_commerce_metaobject(
configuration: &configuration::Configuration,
metaobject_id: &str,
account_id: &str,
) -> Result<models::CreateCommerceMetaobject201Response, Error<GetCommerceMetaobjectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_metaobject_id = metaobject_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/commerce/metaobjects/{metaobjectId}",
configuration.base_path,
metaobjectId = crate::apis::urlencode(p_path_metaobject_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 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::CreateCommerceMetaobject201Response`"))),
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::CreateCommerceMetaobject201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCommerceMetaobjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// One order with every line item, tax line and refund. Needs orders.read.
pub async fn get_commerce_order(
configuration: &configuration::Configuration,
order_id: &str,
account_id: &str,
) -> Result<models::GetCommerceOrder200Response, Error<GetCommerceOrderError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_order_id = order_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/commerce/orders/{orderId}",
configuration.base_path,
orderId = crate::apis::urlencode(p_path_order_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 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::GetCommerceOrder200Response`"))),
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::GetCommerceOrder200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCommerceOrderError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// One content page with its body. Needs pages.read.
pub async fn get_commerce_page(
configuration: &configuration::Configuration,
page_id: &str,
account_id: &str,
) -> Result<models::CreateCommercePage201Response, Error<GetCommercePageError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_page_id = page_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/commerce/pages/{pageId}",
configuration.base_path,
pageId = crate::apis::urlencode(p_path_page_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 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::CreateCommercePage201Response`"))),
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::CreateCommercePage201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCommercePageError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// One product with all its variants, options and images. Needs products.read. 404 product_not_found when the id does not exist in the store.
pub async fn get_commerce_product(
configuration: &configuration::Configuration,
product_id: &str,
account_id: &str,
) -> Result<models::CreateCommerceProduct201Response, Error<GetCommerceProductError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_product_id = product_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/commerce/products/{productId}",
configuration.base_path,
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 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::CreateCommerceProduct201Response`"))),
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::CreateCommerceProduct201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCommerceProductError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns the connected store with its currency, country and the `capabilities` it supports, so an integration can tell up front which Commerce operations the store serves. ### Shopify permissions On Shopify, these need permissions the store owner approves separately: stock, sales channels, discounts, navigation, metaobjects, markets, marketing and image removal. - `missingCapabilities` lists what is not granted yet. - `grantPermissionsUrl` is the page where the owner approves it.
pub async fn get_commerce_store(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::GetCommerceStore200Response, Error<GetCommerceStoreError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let uri_str = format!("{}/v1/commerce/store", 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 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::GetCommerceStore200Response`"))),
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::GetCommerceStore200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCommerceStoreError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The ad-platform catalogs this store is kept in sync with.
pub async fn list_commerce_catalog_syncs(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::ListCommerceCatalogSyncs200Response, Error<ListCommerceCatalogSyncsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let uri_str = format!("{}/v1/commerce/catalog-syncs", 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 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::ListCommerceCatalogSyncs200Response`"))),
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::ListCommerceCatalogSyncs200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCommerceCatalogSyncsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Where products and collections can be published: the online store, Shop, POS and installed channel apps.
pub async fn list_commerce_channels(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::ListCommerceChannels200Response, Error<ListCommerceChannelsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let uri_str = format!("{}/v1/commerce/channels", 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 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::ListCommerceChannels200Response`"))),
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::ListCommerceChannels200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCommerceChannelsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The collection's metafields as namespace, key, type and value. Needs collections.metafields: WooCommerce keeps custom fields on products only and answers 400 platform_not_supported.
pub async fn list_commerce_collection_metafields(
configuration: &configuration::Configuration,
collection_id: &str,
account_id: &str,
) -> Result<
models::ListCommerceProductMetafields200Response,
Error<ListCommerceCollectionMetafieldsError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_id = collection_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/commerce/collections/{collectionId}/metafields",
configuration.base_path,
collectionId = crate::apis::urlencode(p_path_collection_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 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::ListCommerceProductMetafields200Response`"))),
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::ListCommerceProductMetafields200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCommerceCollectionMetafieldsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists the store's product collections. Cursor-paginated like products. List a collection's products with `GET /v1/commerce/products?collectionId=...`.
pub async fn list_commerce_collections(
configuration: &configuration::Configuration,
account_id: &str,
limit: Option<i32>,
cursor: Option<&str>,
query: Option<&str>,
) -> Result<models::ListCommerceCollections200Response, Error<ListCommerceCollectionsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_limit = limit;
let p_query_cursor = cursor;
let p_query_query = query;
let uri_str = format!("{}/v1/commerce/collections", 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_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_cursor {
req_builder = req_builder.query(&[("cursor", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_query {
req_builder = req_builder.query(&[("query", ¶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::ListCommerceCollections200Response`"))),
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::ListCommerceCollections200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCommerceCollectionsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The store's discounts (Shopify code and automatic discounts, WooCommerce coupons), cursor-paginated with `limit`, `cursor` and an optional `query`. Each discount lists its first 10 codes; `codeCount` has the total. Needs discounts.read.
pub async fn list_commerce_discounts(
configuration: &configuration::Configuration,
account_id: &str,
limit: Option<i32>,
cursor: Option<&str>,
query: Option<&str>,
) -> Result<models::ListCommerceDiscounts200Response, Error<ListCommerceDiscountsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_limit = limit;
let p_query_cursor = cursor;
let p_query_query = query;
let uri_str = format!("{}/v1/commerce/discounts", 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_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_cursor {
req_builder = req_builder.query(&[("cursor", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_query {
req_builder = req_builder.query(&[("query", ¶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::ListCommerceDiscounts200Response`"))),
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::ListCommerceDiscounts200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCommerceDiscountsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Stock per variant and location: available, on hand, committed to orders and incoming.
pub async fn list_commerce_inventory(
configuration: &configuration::Configuration,
account_id: &str,
product_id: &str,
) -> Result<models::ListCommerceInventory200Response, Error<ListCommerceInventoryError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_product_id = product_id;
let uri_str = format!("{}/v1/commerce/inventory", 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())]);
req_builder = req_builder.query(&[("productId", &p_query_product_id.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::ListCommerceInventory200Response`"))),
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::ListCommerceInventory200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCommerceInventoryError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The store's stock locations (warehouses, shops).
pub async fn list_commerce_locations(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::ListCommerceLocations200Response, Error<ListCommerceLocationsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let uri_str = format!("{}/v1/commerce/locations", 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 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::ListCommerceLocations200Response`"))),
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::ListCommerceLocations200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCommerceLocationsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The regions the store sells to, each with its own currency and pricing.
pub async fn list_commerce_markets(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::ListCommerceMarkets200Response, Error<ListCommerceMarketsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let uri_str = format!("{}/v1/commerce/markets", 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 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::ListCommerceMarkets200Response`"))),
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::ListCommerceMarkets200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCommerceMarketsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The store's navigation menus with their items. Shopify only. Needs navigation.read.
pub async fn list_commerce_menus(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::ListCommerceMenus200Response, Error<ListCommerceMenusError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let uri_str = format!("{}/v1/commerce/menus", 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 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::ListCommerceMenus200Response`"))),
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::ListCommerceMenus200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCommerceMenusError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The custom content types defined on the store and their fields.
pub async fn list_commerce_metaobject_definitions(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<
models::ListCommerceMetaobjectDefinitions200Response,
Error<ListCommerceMetaobjectDefinitionsError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/commerce/metaobject-definitions",
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 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::ListCommerceMetaobjectDefinitions200Response`"))),
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::ListCommerceMetaobjectDefinitions200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCommerceMetaobjectDefinitionsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The metaobjects of one `type` (a definition handle from GET /v1/commerce/metaobject-definitions), cursor-paginated with `limit` and `cursor`. Shopify only. Needs metaobjects.read.
pub async fn list_commerce_metaobjects(
configuration: &configuration::Configuration,
account_id: &str,
r#type: &str,
limit: Option<i32>,
cursor: Option<&str>,
) -> Result<models::ListCommerceMetaobjects200Response, Error<ListCommerceMetaobjectsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_type = r#type;
let p_query_limit = limit;
let p_query_cursor = cursor;
let uri_str = format!("{}/v1/commerce/metaobjects", 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())]);
req_builder = req_builder.query(&[("type", &p_query_type.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_cursor {
req_builder = req_builder.query(&[("cursor", ¶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::ListCommerceMetaobjects200Response`"))),
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::ListCommerceMetaobjects200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCommerceMetaobjectsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The store's orders in one format for every platform, with what an invoice needs. Needs orders.read. Each order includes: - line items with unit prices, discounts and tax per line - shipping and fee lines - billing details - payment status and refunds ### Ordering and syncing Newest order first. With `updatedAfter`, oldest change first, so a sync can page forward from its last seen `updatedAt`. Start each sync a few minutes before the last `updatedAt` you saw and drop duplicates by `id`, since an order edited while you page can shift the list. ### Limits - Shopify returns at most 25 orders per page and, unless the store was granted access to all orders, only the last 60 days. - Buyer fields (`customer` and addresses) are null when the store's approval does not cover buyer data.
pub async fn list_commerce_orders(
configuration: &configuration::Configuration,
account_id: &str,
limit: Option<i32>,
cursor: Option<&str>,
created_after: Option<String>,
created_before: Option<String>,
updated_after: Option<String>,
) -> Result<models::ListCommerceOrders200Response, Error<ListCommerceOrdersError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_limit = limit;
let p_query_cursor = cursor;
let p_query_created_after = created_after;
let p_query_created_before = created_before;
let p_query_updated_after = updated_after;
let uri_str = format!("{}/v1/commerce/orders", 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_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_cursor {
req_builder = req_builder.query(&[("cursor", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_created_after {
req_builder = req_builder.query(&[("createdAfter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_created_before {
req_builder = req_builder.query(&[("createdBefore", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_updated_after {
req_builder = req_builder.query(&[("updatedAfter", ¶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::ListCommerceOrders200Response`"))),
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::ListCommerceOrders200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCommerceOrdersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The store's content pages (Shopify online store pages, WordPress pages), cursor-paginated with `limit`, `cursor` and an optional `query`. Needs pages.read.
pub async fn list_commerce_pages(
configuration: &configuration::Configuration,
account_id: &str,
limit: Option<i32>,
cursor: Option<&str>,
query: Option<&str>,
) -> Result<models::ListCommercePages200Response, Error<ListCommercePagesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_limit = limit;
let p_query_cursor = cursor;
let p_query_query = query;
let uri_str = format!("{}/v1/commerce/pages", 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_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_cursor {
req_builder = req_builder.query(&[("cursor", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_query {
req_builder = req_builder.query(&[("query", ¶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::ListCommercePages200Response`"))),
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::ListCommercePages200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCommercePagesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Price lists hold fixed prices per variant for a market.
pub async fn list_commerce_price_lists(
configuration: &configuration::Configuration,
account_id: &str,
) -> Result<models::ListCommercePriceLists200Response, Error<ListCommercePriceListsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let uri_str = format!("{}/v1/commerce/price-lists", 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 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::ListCommercePriceLists200Response`"))),
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::ListCommercePriceLists200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCommercePriceListsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The product's custom fields (metafields on Shopify, public meta on WooCommerce) as namespace, key, type and value. Needs metafields.read.
pub async fn list_commerce_product_metafields(
configuration: &configuration::Configuration,
product_id: &str,
account_id: &str,
) -> Result<
models::ListCommerceProductMetafields200Response,
Error<ListCommerceProductMetafieldsError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_product_id = product_id;
let p_query_account_id = account_id;
let uri_str = format!(
"{}/v1/commerce/products/{productId}/metafields",
configuration.base_path,
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 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::ListCommerceProductMetafields200Response`"))),
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::ListCommerceProductMetafields200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCommerceProductMetafieldsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists the store's products with their variants, options and images. - Cursor-paginated: pass `limit` (1-100, default 20) and the `cursor` from a previous response's `nextCursor`, which is null on the last page. - Filter with `status` and/or `query` (the platform's product search syntax, passed through verbatim). - A status the platform has no equivalent of returns an empty page.
pub async fn list_commerce_products(
configuration: &configuration::Configuration,
account_id: &str,
limit: Option<i32>,
cursor: Option<&str>,
status: Option<models::CommerceProductStatus>,
query: Option<&str>,
collection_id: Option<&str>,
) -> Result<models::ListCommerceProducts200Response, Error<ListCommerceProductsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_limit = limit;
let p_query_cursor = cursor;
let p_query_status = status;
let p_query_query = query;
let p_query_collection_id = collection_id;
let uri_str = format!("{}/v1/commerce/products", 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_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_cursor {
req_builder = req_builder.query(&[("cursor", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_status {
req_builder = req_builder.query(&[("status", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_query {
req_builder = req_builder.query(&[("query", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_collection_id {
req_builder = req_builder.query(&[("collectionId", ¶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::ListCommerceProducts200Response`"))),
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::ListCommerceProducts200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCommerceProductsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The store's URL redirects (old path to new target), cursor-paginated with `limit`, `cursor` and an optional `query` on the path. Shopify only. Needs navigation.read.
pub async fn list_commerce_redirects(
configuration: &configuration::Configuration,
account_id: &str,
limit: Option<i32>,
cursor: Option<&str>,
query: Option<&str>,
) -> Result<models::ListCommerceRedirects200Response, Error<ListCommerceRedirectsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_account_id = account_id;
let p_query_limit = limit;
let p_query_cursor = cursor;
let p_query_query = query;
let uri_str = format!("{}/v1/commerce/redirects", 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_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_cursor {
req_builder = req_builder.query(&[("cursor", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_query {
req_builder = req_builder.query(&[("query", ¶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::ListCommerceRedirects200Response`"))),
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::ListCommerceRedirects200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCommerceRedirectsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Removes images from the product by image id (the `id` on each image). The file stays in the store's media library. Needs the products.images_remove capability.
pub async fn remove_commerce_product_images(
configuration: &configuration::Configuration,
product_id: &str,
account_id: &str,
image_ids: &str,
) -> Result<models::CreateCommerceProduct201Response, Error<RemoveCommerceProductImagesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_product_id = product_id;
let p_query_account_id = account_id;
let p_query_image_ids = image_ids;
let uri_str = format!(
"{}/v1/commerce/products/{productId}/images",
configuration.base_path,
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())]);
req_builder = req_builder.query(&[("imageIds", &p_query_image_ids.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::CreateCommerceProduct201Response`"))),
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::CreateCommerceProduct201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RemoveCommerceProductImagesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Moves products to new 0-based positions. Only for collections sorted `manual`.
pub async fn reorder_commerce_collection_products(
configuration: &configuration::Configuration,
collection_id: &str,
reorder_commerce_collection_products_request: models::ReorderCommerceCollectionProductsRequest,
) -> Result<
models::ReorderCommerceProductImages200Response,
Error<ReorderCommerceCollectionProductsError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_id = collection_id;
let p_body_reorder_commerce_collection_products_request =
reorder_commerce_collection_products_request;
let uri_str = format!(
"{}/v1/commerce/collections/{collectionId}/reorder",
configuration.base_path,
collectionId = crate::apis::urlencode(p_path_collection_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_reorder_commerce_collection_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::ReorderCommerceProductImages200Response`"))),
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::ReorderCommerceProductImages200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ReorderCommerceCollectionProductsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Puts the product's images in the given order; the first becomes the featured image. `pending` is true while the platform finishes in the background.
pub async fn reorder_commerce_product_images(
configuration: &configuration::Configuration,
product_id: &str,
reorder_commerce_product_images_request: models::ReorderCommerceProductImagesRequest,
) -> Result<models::ReorderCommerceProductImages200Response, Error<ReorderCommerceProductImagesError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_path_product_id = product_id;
let p_body_reorder_commerce_product_images_request = reorder_commerce_product_images_request;
let uri_str = format!(
"{}/v1/commerce/products/{productId}/images/reorder",
configuration.base_path,
productId = crate::apis::urlencode(p_path_product_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_reorder_commerce_product_images_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::ReorderCommerceProductImages200Response`"))),
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::ReorderCommerceProductImages200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ReorderCommerceProductImagesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Queues a full run. Poll GET /v1/commerce/catalog-syncs/{syncId} for the outcome.
pub async fn run_commerce_catalog_sync(
configuration: &configuration::Configuration,
sync_id: &str,
) -> Result<models::CreateCommerceCatalogSync202Response, Error<RunCommerceCatalogSyncError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_sync_id = sync_id;
let uri_str = format!(
"{}/v1/commerce/catalog-syncs/{syncId}/run",
configuration.base_path,
syncId = crate::apis::urlencode(p_path_sync_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());
};
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::CreateCommerceCatalogSync202Response`"))),
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::CreateCommerceCatalogSync202Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RunCommerceCatalogSyncError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates or updates custom fields by namespace and key. Needs collections.metafields: WooCommerce keeps custom fields on products only and answers 400 platform_not_supported.
pub async fn set_commerce_collection_metafields(
configuration: &configuration::Configuration,
collection_id: &str,
set_commerce_product_metafields_request: models::SetCommerceProductMetafieldsRequest,
) -> Result<
models::ListCommerceProductMetafields200Response,
Error<SetCommerceCollectionMetafieldsError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_id = collection_id;
let p_body_set_commerce_product_metafields_request = set_commerce_product_metafields_request;
let uri_str = format!(
"{}/v1/commerce/collections/{collectionId}/metafields",
configuration.base_path,
collectionId = crate::apis::urlencode(p_path_collection_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_set_commerce_product_metafields_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::ListCommerceProductMetafields200Response`"))),
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::ListCommerceProductMetafields200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SetCommerceCollectionMetafieldsError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Deactivating ends the discount now; activating starts it now.
pub async fn set_commerce_discount_active(
configuration: &configuration::Configuration,
discount_id: &str,
set_commerce_discount_active_request: models::SetCommerceDiscountActiveRequest,
) -> Result<models::CreateCommerceDiscount201Response, Error<SetCommerceDiscountActiveError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_discount_id = discount_id;
let p_body_set_commerce_discount_active_request = set_commerce_discount_active_request;
let uri_str = format!(
"{}/v1/commerce/discounts/{discountId}/state",
configuration.base_path,
discountId = crate::apis::urlencode(p_path_discount_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_set_commerce_discount_active_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::CreateCommerceDiscount201Response`"))),
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::CreateCommerceDiscount201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SetCommerceDiscountActiveError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Sets fixed prices for variants in the price list's currency, overriding the converted price in that market.
pub async fn set_commerce_price_list_prices(
configuration: &configuration::Configuration,
price_list_id: &str,
set_commerce_price_list_prices_request: models::SetCommercePriceListPricesRequest,
) -> Result<models::SetCommercePriceListPrices200Response, Error<SetCommercePriceListPricesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_price_list_id = price_list_id;
let p_body_set_commerce_price_list_prices_request = set_commerce_price_list_prices_request;
let uri_str = format!(
"{}/v1/commerce/price-lists/{priceListId}/prices",
configuration.base_path,
priceListId = crate::apis::urlencode(p_path_price_list_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_set_commerce_price_list_prices_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::SetCommercePriceListPrices200Response`"))),
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::SetCommercePriceListPrices200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SetCommercePriceListPricesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates or updates custom fields by namespace and key.
pub async fn set_commerce_product_metafields(
configuration: &configuration::Configuration,
product_id: &str,
set_commerce_product_metafields_request: models::SetCommerceProductMetafieldsRequest,
) -> Result<
models::ListCommerceProductMetafields200Response,
Error<SetCommerceProductMetafieldsError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_product_id = product_id;
let p_body_set_commerce_product_metafields_request = set_commerce_product_metafields_request;
let uri_str = format!(
"{}/v1/commerce/products/{productId}/metafields",
configuration.base_path,
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_set_commerce_product_metafields_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::ListCommerceProductMetafields200Response`"))),
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::ListCommerceProductMetafields200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SetCommerceProductMetafieldsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Partial update; at least one field besides accountId is required. Change membership with POST /v1/commerce/collections/{collectionId}/products.
pub async fn update_commerce_collection(
configuration: &configuration::Configuration,
collection_id: &str,
update_commerce_collection_request: models::UpdateCommerceCollectionRequest,
) -> Result<models::CreateCommerceCollection201Response, Error<UpdateCommerceCollectionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_collection_id = collection_id;
let p_body_update_commerce_collection_request = update_commerce_collection_request;
let uri_str = format!(
"{}/v1/commerce/collections/{collectionId}",
configuration.base_path,
collectionId = crate::apis::urlencode(p_path_collection_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &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_commerce_collection_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::CreateCommerceCollection201Response`"))),
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::CreateCommerceCollection201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCommerceCollectionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Changes a percentage, fixed-amount or free-shipping discount. Buy-X-get-Y and app discounts are read-only here.
pub async fn update_commerce_discount(
configuration: &configuration::Configuration,
discount_id: &str,
update_commerce_discount_request: models::UpdateCommerceDiscountRequest,
) -> Result<models::CreateCommerceDiscount201Response, Error<UpdateCommerceDiscountError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_discount_id = discount_id;
let p_body_update_commerce_discount_request = update_commerce_discount_request;
let uri_str = format!(
"{}/v1/commerce/discounts/{discountId}",
configuration.base_path,
discountId = crate::apis::urlencode(p_path_discount_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &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_commerce_discount_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::CreateCommerceDiscount201Response`"))),
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::CreateCommerceDiscount201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCommerceDiscountError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Replaces the title and the whole item tree.
pub async fn update_commerce_menu(
configuration: &configuration::Configuration,
menu_id: &str,
update_commerce_menu_request: models::UpdateCommerceMenuRequest,
) -> Result<models::CreateCommerceMenu201Response, Error<UpdateCommerceMenuError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_menu_id = menu_id;
let p_body_update_commerce_menu_request = update_commerce_menu_request;
let uri_str = format!(
"{}/v1/commerce/menus/{menuId}",
configuration.base_path,
menuId = crate::apis::urlencode(p_path_menu_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_commerce_menu_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::CreateCommerceMenu201Response`"))),
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::CreateCommerceMenu201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCommerceMenuError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Sets the given field values; fields left out keep theirs.
pub async fn update_commerce_metaobject(
configuration: &configuration::Configuration,
metaobject_id: &str,
update_commerce_metaobject_request: models::UpdateCommerceMetaobjectRequest,
) -> Result<models::CreateCommerceMetaobject201Response, Error<UpdateCommerceMetaobjectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_metaobject_id = metaobject_id;
let p_body_update_commerce_metaobject_request = update_commerce_metaobject_request;
let uri_str = format!(
"{}/v1/commerce/metaobjects/{metaobjectId}",
configuration.base_path,
metaobjectId = crate::apis::urlencode(p_path_metaobject_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &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_commerce_metaobject_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::CreateCommerceMetaobject201Response`"))),
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::CreateCommerceMetaobject201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCommerceMetaobjectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Updates the fields you pass (`title`, `handle`, `bodyHtml`, `isPublished`) and returns the page. Needs pages.write.
pub async fn update_commerce_page(
configuration: &configuration::Configuration,
page_id: &str,
update_commerce_page_request: models::UpdateCommercePageRequest,
) -> Result<models::CreateCommercePage201Response, Error<UpdateCommercePageError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_page_id = page_id;
let p_body_update_commerce_page_request = update_commerce_page_request;
let uri_str = format!(
"{}/v1/commerce/pages/{pageId}",
configuration.base_path,
pageId = crate::apis::urlencode(p_path_page_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &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_commerce_page_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::CreateCommercePage201Response`"))),
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::CreateCommercePage201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCommercePageError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Partial-updates the product's own fields; at least one besides `accountId` is required. `tags` replaces the full list. Change prices with `POST /v1/commerce/products/{productId}/price` and status with `POST /v1/commerce/products/state`.
pub async fn update_commerce_product(
configuration: &configuration::Configuration,
product_id: &str,
update_commerce_product_request: models::UpdateCommerceProductRequest,
) -> Result<models::CreateCommerceProduct201Response, Error<UpdateCommerceProductError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_product_id = product_id;
let p_body_update_commerce_product_request = update_commerce_product_request;
let uri_str = format!(
"{}/v1/commerce/products/{productId}",
configuration.base_path,
productId = crate::apis::urlencode(p_path_product_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &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_commerce_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::CreateCommerceProduct201Response`"))),
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::CreateCommerceProduct201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCommerceProductError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Sets the price and/or compare-at price of the listed variants. Other variants are untouched. Amounts are in the store currency; send `compareAtPrice: null` to remove a strike-through price.
pub async fn update_commerce_product_prices(
configuration: &configuration::Configuration,
product_id: &str,
update_commerce_product_prices_request: models::UpdateCommerceProductPricesRequest,
) -> Result<models::CreateCommerceProduct201Response, Error<UpdateCommerceProductPricesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_product_id = product_id;
let p_body_update_commerce_product_prices_request = update_commerce_product_prices_request;
let uri_str = format!(
"{}/v1/commerce/products/{productId}/price",
configuration.base_path,
productId = crate::apis::urlencode(p_path_product_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_update_commerce_product_prices_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::CreateCommerceProduct201Response`"))),
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::CreateCommerceProduct201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCommerceProductPricesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Changes the redirect's `path` and/or `target`. Shopify only. Needs navigation.write.
pub async fn update_commerce_redirect(
configuration: &configuration::Configuration,
redirect_id: &str,
update_commerce_redirect_request: models::UpdateCommerceRedirectRequest,
) -> Result<models::CreateCommerceRedirect201Response, Error<UpdateCommerceRedirectError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_redirect_id = redirect_id;
let p_body_update_commerce_redirect_request = update_commerce_redirect_request;
let uri_str = format!(
"{}/v1/commerce/redirects/{redirectId}",
configuration.base_path,
redirectId = crate::apis::urlencode(p_path_redirect_id)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &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_commerce_redirect_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::CreateCommerceRedirect201Response`"))),
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::CreateCommerceRedirect201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCommerceRedirectError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates or updates (by `remoteId`) an activity in the store's Marketing section, so the merchant sees a post, ad or message you ran for them, with its link and UTM parameters for attribution. Use your own id (for example the Zernio post or ad id) as `remoteId`.
pub async fn upsert_commerce_marketing_activity(
configuration: &configuration::Configuration,
upsert_commerce_marketing_activity_request: models::UpsertCommerceMarketingActivityRequest,
) -> Result<
models::UpsertCommerceMarketingActivity200Response,
Error<UpsertCommerceMarketingActivityError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_upsert_commerce_marketing_activity_request =
upsert_commerce_marketing_activity_request;
let uri_str = format!(
"{}/v1/commerce/marketing-activities",
configuration.base_path
);
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_upsert_commerce_marketing_activity_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::UpsertCommerceMarketingActivity200Response`"))),
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::UpsertCommerceMarketingActivity200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpsertCommerceMarketingActivityError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}