/*
* 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.610.0
* Contact: support@zernio.com
* Generated by: https://openapi-generator.tech
*/
use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
/// struct for typed errors of method [`activate_creator_campaign`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ActivateCreatorCampaignError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`approve_campaign_draft`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApproveCampaignDraftError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`approve_campaign_participant`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApproveCampaignParticipantError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`approve_campaign_sample`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApproveCampaignSampleError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
Status502(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`approve_campaign_submission`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ApproveCampaignSubmissionError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`close_creator_campaign`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CloseCreatorCampaignError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_campaign_adjustment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCampaignAdjustmentError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_campaign_invite_link`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCampaignInviteLinkError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_campaign_participant`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCampaignParticipantError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_campaign_payout_batch`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCampaignPayoutBatchError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status402(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status429(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_creator_campaign`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCreatorCampaignError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(),
Status422(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`decline_campaign_sample`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeclineCampaignSampleError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`deny_campaign_participant`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DenyCampaignParticipantError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_campaign_ad_results`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCampaignAdResultsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_campaign_draft`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCampaignDraftError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_campaign_participant`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCampaignParticipantError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_campaign_report`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCampaignReportError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_campaign_submission`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCampaignSubmissionError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_creator_campaign`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCreatorCampaignError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`launch_campaign_ads`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LaunchCampaignAdsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_campaign_drafts`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCampaignDraftsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_campaign_ledger`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCampaignLedgerError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_campaign_orders`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCampaignOrdersError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_campaign_participants`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCampaignParticipantsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_campaign_payables`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCampaignPayablesError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_campaign_payout_batches`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCampaignPayoutBatchesError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_campaign_samples`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCampaignSamplesError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_campaign_submissions`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCampaignSubmissionsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_creator_campaigns`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListCreatorCampaignsError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`move_campaign_participant`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum MoveCampaignParticipantError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`pause_creator_campaign`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PauseCreatorCampaignError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`preview_campaign_payout_batch`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PreviewCampaignPayoutBatchError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`raise_creator_campaign_budget`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RaiseCreatorCampaignBudgetError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`reinstate_campaign_participant`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReinstateCampaignParticipantError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`reject_campaign_draft`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RejectCampaignDraftError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`reject_campaign_submission`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RejectCampaignSubmissionError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`remove_campaign_participant`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RemoveCampaignParticipantError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`reopen_campaign_submission`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ReopenCampaignSubmissionError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`request_campaign_draft_revision`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum RequestCampaignDraftRevisionError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`resend_campaign_participant_invite`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ResendCampaignParticipantInviteError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`settle_campaign_participant`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SettleCampaignParticipantError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`ship_campaign_sample`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ShipCampaignSampleError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
Status422(),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`suspend_campaign_participant`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SuspendCampaignParticipantError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_creator_campaign`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCreatorCampaignError {
Status400(models::ErrorResponse),
Status401(models::ErrorResponse),
Status403(models::ErrorResponse),
Status404(models::ErrorResponse),
Status409(models::ErrorResponse),
UnknownValue(serde_json::Value),
}
/// Moves a `draft` or `paused` campaign to `active`, where creators can join and submit posts and tracked views accrue earnings. Needs at least one platform and a budget above zero; any other starting state answers 409.
pub async fn activate_creator_campaign(
configuration: &configuration::Configuration,
campaign_id: &str,
) -> Result<models::CreateCreatorCampaign201Response, Error<ActivateCreatorCampaignError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/activate",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_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::CreateCreatorCampaign201Response`"))),
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::CreateCreatorCampaign201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ActivateCreatorCampaignError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Approves a `submitted` draft version, emails the creator and fires `campaign_draft.approved`. The creator can then publish it and submit the live post with this `draftId`; each approved draft backs one post only. Each version is decided once: a version that is no longer `submitted` answers 409.
pub async fn approve_campaign_draft(
configuration: &configuration::Configuration,
campaign_id: &str,
draft_id: &str,
idempotency_key: Option<&str>,
) -> Result<models::ApproveCampaignDraft200Response, Error<ApproveCampaignDraftError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_draft_id = draft_id;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/drafts/{draftId}/approve",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
draftId = crate::apis::urlencode(p_path_draft_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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::ApproveCampaignDraft200Response`"))),
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::ApproveCampaignDraft200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ApproveCampaignDraftError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lets a `pending` creator into the campaign: they become `active`, `joinedAt` is set, the creator is emailed and `campaign_participant.approved` fires (not `campaign_participant.joined`). A creator is `pending` when they joined through the open link of a campaign with `joinApproval: manual`. Personal invites are never held. ### Creator limit Pending creators do not count toward `caps.maxParticipants`; the limit is checked here instead. A full campaign refuses the approval with 403 `feature_not_available` and the creator stays `pending`. ### Errors - 403 `feature_not_available`: the campaign reached `caps.maxParticipants`. - 409 `invalid_resource_state`: the participant is not `pending`, or the campaign is closed.
pub async fn approve_campaign_participant(
configuration: &configuration::Configuration,
campaign_id: &str,
participant_id: &str,
idempotency_key: Option<&str>,
) -> Result<models::GetCampaignParticipant200Response, Error<ApproveCampaignParticipantError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_participant_id = participant_id;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/participants/{participantId}/approve",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
participantId = crate::apis::urlencode(p_path_participant_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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::GetCampaignParticipant200Response`"))),
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::GetCampaignParticipant200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ApproveCampaignParticipantError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Approves a `pending` sample request. Zernio creates a 100%-off, single-use discount code (`SAMPLE-XXXXXXXX`) limited to the requested product in the campaign's store (Shopify or WooCommerce), returns it as `discountCode`, emails it to the creator and fires `campaign_sample.approved`. The creator redeems it at checkout. The code is created before the request changes, so when the store refuses (missing discount permission, an unsupported store, a store error) its error is returned and the request stays `pending`. The approval also starts the `sampleContentDueDays` clock behind `contentDueAt` and `contentOwed`. ### Errors - 400 `platform_not_supported`: the store cannot create discounts. - 403: the store has not granted the permission discounts need. - 409 `invalid_resource_state`: the request is not `pending`. - 502 `platform_api_error`: the store is unavailable.
pub async fn approve_campaign_sample(
configuration: &configuration::Configuration,
campaign_id: &str,
sample_id: &str,
idempotency_key: Option<&str>,
) -> Result<models::ApproveCampaignSample200Response, Error<ApproveCampaignSampleError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_sample_id = sample_id;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/samples/{sampleId}/approve",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
sampleId = crate::apis::urlencode(p_path_sample_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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::ApproveCampaignSample200Response`"))),
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::ApproveCampaignSample200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ApproveCampaignSampleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Approves a `tracking` or `pending_review` submission of an active campaign and fires `campaign_submission.approved`. The Zernio dashboard offers Approve only on `pending_review` (a post that needs a decision) and waits for `tracking` posts to get there. The API accepts `tracking` so an integration can approve early. ### Earnings - What the post earned so far moves to owed and is held for the campaign's `holdDays`. - Later earnings post straight to owed. - A per-post campaign pays `perApprovedPostCents` here. ### Errors - 409: the submission is in any other state. - 409 (`invalid_resource_state`, \"This post is already approved in another campaign of yours.\"): the same post was approved in another of your campaigns, so one post never earns twice.
pub async fn approve_campaign_submission(
configuration: &configuration::Configuration,
campaign_id: &str,
submission_id: &str,
idempotency_key: Option<&str>,
) -> Result<models::ApproveCampaignSubmission200Response, Error<ApproveCampaignSubmissionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_submission_id = submission_id;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/submissions/{submissionId}/approve",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
submissionId = crate::apis::urlencode(p_path_submission_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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::ApproveCampaignSubmission200Response`"))),
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::ApproveCampaignSubmission200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ApproveCampaignSubmissionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Closes an `active` or `paused` campaign for good and fires `creator_campaign.closed`. Open tracking windows are cancelled. A pool campaign is split among participants at this moment by their approved eligible views. Closing a pool campaign therefore answers 409 while any post still awaits review. A campaign also closes by itself once `endsAt` passed and every tracking window had its final read.
pub async fn close_creator_campaign(
configuration: &configuration::Configuration,
campaign_id: &str,
) -> Result<models::CreateCreatorCampaign201Response, Error<CloseCreatorCampaignError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/close",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_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::CreateCreatorCampaign201Response`"))),
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::CreateCreatorCampaign201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CloseCreatorCampaignError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Posts a manual adjustment to a participant's payable balance against the campaign budget: a positive amount credits the participant (a bonus), a negative one claws back. `cause` is kept on the ledger entry. A claw-back larger than the payable balance answers 409.
pub async fn create_campaign_adjustment(
configuration: &configuration::Configuration,
campaign_id: &str,
create_campaign_adjustment_request: models::CreateCampaignAdjustmentRequest,
idempotency_key: Option<&str>,
) -> Result<models::CreateCampaignAdjustment201Response, Error<CreateCampaignAdjustmentError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_create_campaign_adjustment_request = create_campaign_adjustment_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/adjustments",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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_campaign_adjustment_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::CreateCampaignAdjustment201Response`"))),
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::CreateCampaignAdjustment201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCampaignAdjustmentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates the campaign's open invite link: anyone with it can join as a participant (up to `caps.maxParticipants`). Creating a new link revokes the previous one. The URL is returned only here. Answers 409 on a closed campaign.
pub async fn create_campaign_invite_link(
configuration: &configuration::Configuration,
campaign_id: &str,
) -> Result<models::CreateCampaignInviteLink201Response, Error<CreateCampaignInviteLinkError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/invite-link",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_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::CreateCampaignInviteLink201Response`"))),
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::CreateCampaignInviteLink201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCampaignInviteLinkError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Invites one creator and returns their personal invite URL. Send the URL to the creator. On that page they connect their accounts (read-only), submit posts and see their earnings. ### Invite rules - The URL is returned only here; inviting again creates no second link. - A creator is matched by email within your workspace, so the same person keeps one identity across your campaigns. ### Errors - 409: the creator is already in the campaign, or the campaign is closed. - 403 `feature_not_available`: `caps.maxParticipants` is reached.
pub async fn create_campaign_participant(
configuration: &configuration::Configuration,
campaign_id: &str,
create_campaign_participant_request: models::CreateCampaignParticipantRequest,
idempotency_key: Option<&str>,
) -> Result<models::CreateCampaignParticipant201Response, Error<CreateCampaignParticipantError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_create_campaign_participant_request = create_campaign_participant_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/participants",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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_campaign_participant_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::CreateCampaignParticipant201Response`"))),
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::CreateCampaignParticipant201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCampaignParticipantError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Pays exactly what is owed to the creators of a `treasury` campaign by charging the billing owner's saved card, with no redirect. Payouts are never paid from your balance. ### How it works 1. Every payable creator who finished payout setup (or only `participantIds`, minus `excludeParticipantIds`) is held in `settling`. 2. The saved card (the default one, or `paymentMethodId`) pays one invoice while the payer is present: the payouts, plus the fee (4%, 50 cents minimum per payout) and the VAT on the fee where it applies. 3. Card payments are held 7 days against chargebacks (`releasesAt`). Then each creator gets a transfer funded by the charge, and the batch ends `paid` or `partially_failed`. Zernio collects the payouts and pays each creator on your behalf and in your name, so the payouts carry no VAT. A creator whose payouts were disabled before the hold ended is skipped and stays payable. A charge refunded or disputed during the hold pays nobody: every amount is payable again. Preview the charge with `POST /v1/creator-campaigns/{campaignId}/payout-batches/preview`. ### 3D Secure `payment.status: requires_action` means the bank asked the payer to confirm. Complete it with Stripe.js `handleNextAction({ clientSecret })`, then call `POST /v1/payout-batches/{batchId}/confirm`. One left unfinished is cancelled after 30 minutes and every amount is payable again. Cancel it sooner with `POST /v1/payout-batches/{batchId}/cancel`. ### Limits and errors - 402 `payment_required`: no saved card. Nothing is held. - 402 `card_declined`: the bank's reason; every amount is payable again. - 402: card payouts are limited to $10,000.00 gross per rolling 30 days by default. Over it the call answers \"Over your instant payout limit for the last 30 days. Contact support to raise it.\" - 402: your balance is negative after a dispute or refund. - 400: nothing payable (\"Nothing is payable.\"). - 400 `invalid_billing_address`: Stripe cannot place your billing address, so it cannot tax the fee. Nothing is held. - 429 `payment_attempts_limited`: five card payments were declined in 24 hours. Nothing is held and nothing reaches the bank until `Retry-After` runs out. ### Access and retries Needs an owner, admin or billing admin, signed in or through a full-access key they created. Send an `Idempotency-Key` so a retry never opens a second batch.
pub async fn create_campaign_payout_batch(
configuration: &configuration::Configuration,
campaign_id: &str,
idempotency_key: Option<&str>,
create_campaign_payout_batch_request: Option<models::CreateCampaignPayoutBatchRequest>,
) -> Result<models::CreateCampaignPayoutBatch201Response, Error<CreateCampaignPayoutBatchError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_header_idempotency_key = idempotency_key;
let p_body_create_campaign_payout_batch_request = create_campaign_payout_batch_request;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/payout-batches",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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_campaign_payout_batch_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::CreateCampaignPayoutBatch201Response`"))),
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::CreateCampaignPayoutBatch201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCampaignPayoutBatchError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates a campaign in `draft`. Creators are paid for verified performance of the posts they submit: Zernio tracks each post through a tracking window, scores its authenticity and records every earning in a ledger. Activate the campaign to start accepting submissions. Creator campaigns run on usage-based billing; a workspace not on it gets 403 `feature_not_available`. `profileId` must be a profile this key can reach, otherwise 404.
pub async fn create_creator_campaign(
configuration: &configuration::Configuration,
create_creator_campaign_request: models::CreateCreatorCampaignRequest,
idempotency_key: Option<&str>,
) -> Result<models::CreateCreatorCampaign201Response, Error<CreateCreatorCampaignError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body_create_creator_campaign_request = create_creator_campaign_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!("{}/v1/creator-campaigns", 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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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_creator_campaign_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::CreateCreatorCampaign201Response`"))),
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::CreateCreatorCampaign201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCreatorCampaignError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Declines a `pending` sample request with a reason, emails the creator and fires `campaign_sample.declined`. The creator can ask for the same product again. Any other status answers 409.
pub async fn decline_campaign_sample(
configuration: &configuration::Configuration,
campaign_id: &str,
sample_id: &str,
decline_campaign_sample_request: models::DeclineCampaignSampleRequest,
idempotency_key: Option<&str>,
) -> Result<models::ApproveCampaignSample200Response, Error<DeclineCampaignSampleError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_sample_id = sample_id;
let p_body_decline_campaign_sample_request = decline_campaign_sample_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/samples/{sampleId}/decline",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
sampleId = crate::apis::urlencode(p_path_sample_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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_decline_campaign_sample_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::ApproveCampaignSample200Response`"))),
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::ApproveCampaignSample200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeclineCampaignSampleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Turns a `pending` creator away: they become `denied`, the creator is emailed and `campaign_participant.denied` fires. A denied creator cannot submit posts, drafts or sample requests. Any status other than `pending` answers 409.
pub async fn deny_campaign_participant(
configuration: &configuration::Configuration,
campaign_id: &str,
participant_id: &str,
idempotency_key: Option<&str>,
) -> Result<models::GetCampaignParticipant200Response, Error<DenyCampaignParticipantError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_participant_id = participant_id;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/participants/{participantId}/deny",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
participantId = crate::apis::urlencode(p_path_participant_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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::GetCampaignParticipant200Response`"))),
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::GetCampaignParticipant200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DenyCampaignParticipantError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// What the campaign's posts did as ads: totals, each post with its ads and launches, and the creators ranked by `rankBy`. An ad counts for a post when it was launched from the post, or when it runs the post (a boosted post, the Instagram media it shows, or a TikTok Spark item). Figures come from the ads' daily metrics; money is in the campaign currency, and ads billed in another currency are left out of money figures.
pub async fn get_campaign_ad_results(
configuration: &configuration::Configuration,
campaign_id: &str,
rank_by: Option<&str>,
from: Option<String>,
to: Option<String>,
) -> Result<models::GetCampaignAdResults200Response, Error<GetCampaignAdResultsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_query_rank_by = rank_by;
let p_query_from = from;
let p_query_to = to;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/ad-results",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_rank_by {
req_builder = req_builder.query(&[("rankBy", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_from {
req_builder = req_builder.query(&[("from", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_to {
req_builder = req_builder.query(&[("to", ¶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::GetCampaignAdResults200Response`"))),
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::GetCampaignAdResults200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCampaignAdResultsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns one draft version and every version of its chain (`versions`, newest first, including this one), each with its review comments.
pub async fn get_campaign_draft(
configuration: &configuration::Configuration,
campaign_id: &str,
draft_id: &str,
) -> Result<models::GetCampaignDraft200Response, Error<GetCampaignDraftError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_draft_id = draft_id;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/drafts/{draftId}",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
draftId = crate::apis::urlencode(p_path_draft_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::GetCampaignDraft200Response`"))),
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::GetCampaignDraft200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCampaignDraftError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns one participant with connected accounts, balances by state, flags and submission counts.
pub async fn get_campaign_participant(
configuration: &configuration::Configuration,
campaign_id: &str,
participant_id: &str,
) -> Result<models::GetCampaignParticipant200Response, Error<GetCampaignParticipantError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_participant_id = participant_id;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/participants/{participantId}",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
participantId = crate::apis::urlencode(p_path_participant_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::GetCampaignParticipant200Response`"))),
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::GetCampaignParticipant200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCampaignParticipantError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns spend against budget, views, submission counts, the top ten participants by earnings and the authenticity score distribution.
pub async fn get_campaign_report(
configuration: &configuration::Configuration,
campaign_id: &str,
) -> Result<models::GetCampaignReport200Response, Error<GetCampaignReportError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/report",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_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::GetCampaignReport200Response`"))),
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::GetCampaignReport200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCampaignReportError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns one submission with its per-sync samples (views, likes, comments, shares, saves).
pub async fn get_campaign_submission(
configuration: &configuration::Configuration,
campaign_id: &str,
submission_id: &str,
) -> Result<models::GetCampaignSubmission200Response, Error<GetCampaignSubmissionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_submission_id = submission_id;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/submissions/{submissionId}",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
submissionId = crate::apis::urlencode(p_path_submission_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::GetCampaignSubmission200Response`"))),
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::GetCampaignSubmission200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCampaignSubmissionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns the campaign with its budget consumption, participant count and submission counts.
pub async fn get_creator_campaign(
configuration: &configuration::Configuration,
campaign_id: &str,
) -> Result<models::CreateCreatorCampaign201Response, Error<GetCreatorCampaignError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_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::CreateCreatorCampaign201Response`"))),
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::CreateCreatorCampaign201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCreatorCampaignError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Runs approved posts of an active campaign as ads, each post on its own: a post that cannot run is reported in `results` and never stops the rest. A post already launched (or launching) into the same placement is reported as `already_launched` or `in_progress` and never gets a second ad, so a retry is safe. ### What each post becomes - **Meta, `identity: brand`**: a new ad from the post media in the existing ad set `adSetId`, under the brand's Page. - **Meta, `identity: creator`**: a Partnership Ad of the Instagram post under the creator's handle. Partnership Ads are a limited release while Meta reviews the permission they need (`capabilities.partnershipAds` in `GET /v1/creator-campaigns/{campaignId}/ad-results`); without it these posts fail with a message to launch them with brand identity. Facebook posts only run with brand identity. - **TikTok** (`identity: creator` only): a Spark Ad of the creator's post in its own ad group with `dailyBudget`, inside the existing campaign `existingCampaignId`. Needs the Spark code the creator pasted on their campaign page (`hasSparkCode` on the submission). One launch runs on one network: posts from the other network fail with a message to launch them separately. Needs ads access (403 `ads_addon_required`) and room in the managed ads allowance (403 `ads_allowance_exceeded`).
pub async fn launch_campaign_ads(
configuration: &configuration::Configuration,
campaign_id: &str,
launch_campaign_ads_request: models::LaunchCampaignAdsRequest,
idempotency_key: Option<&str>,
) -> Result<models::LaunchCampaignAds200Response, Error<LaunchCampaignAdsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_launch_campaign_ads_request = launch_campaign_ads_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/ads/launch",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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_launch_campaign_ads_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::LaunchCampaignAds200Response`"))),
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::LaunchCampaignAds200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<LaunchCampaignAdsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists the drafts creators uploaded for review on a campaign with `requireDraftApproval`, newest first. Each draft is a chain of versions: a revision is a new version in the same `chainId`. Only the latest version of each chain is listed, so `status` is the chain's current state and `total` counts chains. Earlier versions come with `GET /v1/creator-campaigns/{campaignId}/drafts/{draftId}`.
pub async fn list_campaign_drafts(
configuration: &configuration::Configuration,
campaign_id: &str,
status: Option<&str>,
participant_id: Option<&str>,
limit: Option<i32>,
skip: Option<i32>,
) -> Result<models::ListCampaignDrafts200Response, Error<ListCampaignDraftsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_query_status = status;
let p_query_participant_id = participant_id;
let p_query_limit = limit;
let p_query_skip = skip;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/drafts",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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_participant_id {
req_builder = req_builder.query(&[("participantId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_skip {
req_builder = req_builder.query(&[("skip", ¶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::ListCampaignDrafts200Response`"))),
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::ListCampaignDrafts200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCampaignDraftsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists ledger entries, newest first. Without `participantId` it lists every entry of the campaign: - earnings drawn from the budget (accruals, per-post payments, pool shares, adjustments) - the approvals, hold releases and settlements that move money between its participants' buckets - their reversals Pass `participantId` to narrow the list to one participant's entries.
pub async fn list_campaign_ledger(
configuration: &configuration::Configuration,
campaign_id: &str,
participant_id: Option<&str>,
kind: Option<&str>,
limit: Option<i32>,
skip: Option<i32>,
) -> Result<models::ListCampaignLedger200Response, Error<ListCampaignLedgerError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_query_participant_id = participant_id;
let p_query_kind = kind;
let p_query_limit = limit;
let p_query_skip = skip;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/ledger",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_participant_id {
req_builder = req_builder.query(&[("participantId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_kind {
req_builder = req_builder.query(&[("kind", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_skip {
req_builder = req_builder.query(&[("skip", ¶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::ListCampaignLedger200Response`"))),
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::ListCampaignLedger200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCampaignLedgerError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists the store orders a commission or smart retainer campaign credited to its creators, newest first, and every active creator's discount code and tracking link. An order is `pending` while the store is still attributing it (Shopify does so for a few minutes after checkout), `matched` once it is credited to a creator and `unmatched` when it never was. Commission is approved `holdDays` after the order was placed.
pub async fn list_campaign_orders(
configuration: &configuration::Configuration,
campaign_id: &str,
participant_id: Option<&str>,
status: Option<&str>,
limit: Option<i32>,
skip: Option<i32>,
) -> Result<models::ListCampaignOrders200Response, Error<ListCampaignOrdersError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_query_participant_id = participant_id;
let p_query_status = status;
let p_query_limit = limit;
let p_query_skip = skip;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/orders",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_participant_id {
req_builder = req_builder.query(&[("participantId", ¶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_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_skip {
req_builder = req_builder.query(&[("skip", ¶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::ListCampaignOrders200Response`"))),
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::ListCampaignOrders200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCampaignOrdersError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists the campaign's participants with their balances, flags and submission counts.
pub async fn list_campaign_participants(
configuration: &configuration::Configuration,
campaign_id: &str,
status: Option<&str>,
limit: Option<i32>,
skip: Option<i32>,
) -> Result<models::ListCampaignParticipants200Response, Error<ListCampaignParticipantsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_query_status = status;
let p_query_limit = limit;
let p_query_skip = skip;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/participants",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_skip {
req_builder = req_builder.query(&[("skip", ¶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::ListCampaignParticipants200Response`"))),
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::ListCampaignParticipants200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCampaignParticipantsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists every participant with a payable balance (earnings past their hold), with the ledger entries behind it. Pay these, then record each payout with the settle endpoint.
pub async fn list_campaign_payables(
configuration: &configuration::Configuration,
campaign_id: &str,
) -> Result<models::ListCampaignPayables200Response, Error<ListCampaignPayablesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/payables",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_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::ListCampaignPayables200Response`"))),
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::ListCampaignPayables200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCampaignPayablesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// The campaign's payout batches, newest first, with each creator's item.
pub async fn list_campaign_payout_batches(
configuration: &configuration::Configuration,
campaign_id: &str,
limit: Option<i32>,
skip: Option<i32>,
) -> Result<models::ListCampaignPayoutBatches200Response, Error<ListCampaignPayoutBatchesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_query_limit = limit;
let p_query_skip = skip;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/payout-batches",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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_skip {
req_builder = req_builder.query(&[("skip", ¶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::ListCampaignPayoutBatches200Response`"))),
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::ListCampaignPayoutBatches200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCampaignPayoutBatchesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists the free product samples creators asked for, newest first. `contentOwed` marks an approved or shipped sample whose creator submitted no post in the `sampleContentDueDays` since the approval.
pub async fn list_campaign_samples(
configuration: &configuration::Configuration,
campaign_id: &str,
status: Option<&str>,
participant_id: Option<&str>,
limit: Option<i32>,
skip: Option<i32>,
) -> Result<models::ListCampaignSamples200Response, Error<ListCampaignSamplesError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_query_status = status;
let p_query_participant_id = participant_id;
let p_query_limit = limit;
let p_query_skip = skip;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/samples",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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_participant_id {
req_builder = req_builder.query(&[("participantId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_skip {
req_builder = req_builder.query(&[("skip", ¶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::ListCampaignSamples200Response`"))),
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::ListCampaignSamples200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCampaignSamplesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists submitted posts with views, earnings, authenticity score and flags. Filter by status, participant, flag, platform or score range to build a review queue, for example `status=pending_review`.
pub async fn list_campaign_submissions(
configuration: &configuration::Configuration,
campaign_id: &str,
status: Option<&str>,
participant_id: Option<&str>,
flag: Option<&str>,
platform: Option<&str>,
min_score: Option<i32>,
max_score: Option<i32>,
q: Option<&str>,
sort: Option<&str>,
order: Option<&str>,
limit: Option<i32>,
skip: Option<i32>,
) -> Result<models::ListCampaignSubmissions200Response, Error<ListCampaignSubmissionsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_query_status = status;
let p_query_participant_id = participant_id;
let p_query_flag = flag;
let p_query_platform = platform;
let p_query_min_score = min_score;
let p_query_max_score = max_score;
let p_query_q = q;
let p_query_sort = sort;
let p_query_order = order;
let p_query_limit = limit;
let p_query_skip = skip;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/submissions",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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_participant_id {
req_builder = req_builder.query(&[("participantId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_flag {
req_builder = req_builder.query(&[("flag", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_platform {
req_builder = req_builder.query(&[("platform", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_min_score {
req_builder = req_builder.query(&[("minScore", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_max_score {
req_builder = req_builder.query(&[("maxScore", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_q {
req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_sort {
req_builder = req_builder.query(&[("sort", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_order {
req_builder = req_builder.query(&[("order", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_skip {
req_builder = req_builder.query(&[("skip", ¶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::ListCampaignSubmissions200Response`"))),
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::ListCampaignSubmissions200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCampaignSubmissionsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Lists the team's campaigns in the profiles this key can reach, newest first.
pub async fn list_creator_campaigns(
configuration: &configuration::Configuration,
status: Option<&str>,
profile_id: Option<&str>,
q: Option<&str>,
limit: Option<i32>,
skip: Option<i32>,
) -> Result<models::ListCreatorCampaigns200Response, Error<ListCreatorCampaignsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_query_status = status;
let p_query_profile_id = profile_id;
let p_query_q = q;
let p_query_limit = limit;
let p_query_skip = skip;
let uri_str = format!("{}/v1/creator-campaigns", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
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_profile_id {
req_builder = req_builder.query(&[("profileId", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_q {
req_builder = req_builder.query(&[("q", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_limit {
req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_skip {
req_builder = req_builder.query(&[("skip", ¶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::ListCreatorCampaigns200Response`"))),
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::ListCreatorCampaigns200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListCreatorCampaignsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Moves a creator invited or joined into the wrong campaign to another campaign of the same owner. The participant keeps its id, status and portal link, which now opens the target. Posts that fit the target (platform accepted, published after it started) move with it. Undecided posts that do not fit are rejected in this campaign with the reason; decided ones stay. Answers 409 when the target is closed or full, the creator is already in it, the participant was removed, or any money touched the participation (ledger entries, a payout batch or a transfer). Money never moves between campaigns. Fires `campaign_participant.removed` here and, for a creator who joined, `campaign_participant.joined` on the target.
pub async fn move_campaign_participant(
configuration: &configuration::Configuration,
campaign_id: &str,
participant_id: &str,
move_campaign_participant_request: models::MoveCampaignParticipantRequest,
) -> Result<models::MoveCampaignParticipant200Response, Error<MoveCampaignParticipantError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_participant_id = participant_id;
let p_body_move_campaign_participant_request = move_campaign_participant_request;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/participants/{participantId}/move",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
participantId = crate::apis::urlencode(p_path_participant_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_move_campaign_participant_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::MoveCampaignParticipant200Response`"))),
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::MoveCampaignParticipant200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<MoveCampaignParticipantError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Moves an `active` campaign to `paused`: no new submissions, and approvals answer 409 until the campaign is activated again.
pub async fn pause_creator_campaign(
configuration: &configuration::Configuration,
campaign_id: &str,
) -> Result<models::CreateCreatorCampaign201Response, Error<PauseCreatorCampaignError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/pause",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_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::CreateCreatorCampaign201Response`"))),
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::CreateCreatorCampaign201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PauseCreatorCampaignError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// What `POST /v1/creator-campaigns/{campaignId}/payout-batches` with the same body would charge your card now. Holds and charges nothing. The payouts carry no VAT. `taxCents` is the VAT on Zernio's fee where it applies, from Stripe Tax for your billing address: 21% in Spain, your country's rate for EU consumers, reverse charged (`reverseCharge: true`, no VAT) for EU businesses whose VAT id VIES confirms, none outside the EU. Creators who have not finished payout setup are left out, as paying would.
pub async fn preview_campaign_payout_batch(
configuration: &configuration::Configuration,
campaign_id: &str,
preview_campaign_payout_batch_request: models::PreviewCampaignPayoutBatchRequest,
) -> Result<models::PreviewCampaignPayoutBatch200Response, Error<PreviewCampaignPayoutBatchError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_preview_campaign_payout_batch_request = preview_campaign_payout_batch_request;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/payout-batches/preview",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_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_preview_campaign_payout_batch_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::PreviewCampaignPayoutBatch200Response`"))),
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::PreviewCampaignPayoutBatch200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PreviewCampaignPayoutBatchError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Raises the budget of a campaign that is `draft`, `active` or `paused`. Only the budget changes. The pay terms stay as creators joined them, which `PATCH` refuses to change once the campaign is live. - The new `budgetCents` must be above the current budget, otherwise 400 `invalid_field_value`. - When it is also above what the campaign has spent, `budgetExhaustedAt` is cleared and earnings that stopped at the old budget resume. - A closed campaign answers 409 `invalid_resource_state`.
pub async fn raise_creator_campaign_budget(
configuration: &configuration::Configuration,
campaign_id: &str,
raise_creator_campaign_budget_request: models::RaiseCreatorCampaignBudgetRequest,
idempotency_key: Option<&str>,
) -> Result<models::CreateCreatorCampaign201Response, Error<RaiseCreatorCampaignBudgetError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_raise_creator_campaign_budget_request = raise_creator_campaign_budget_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/budget",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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_raise_creator_campaign_budget_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::CreateCreatorCampaign201Response`"))),
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::CreateCreatorCampaign201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RaiseCreatorCampaignBudgetError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Reinstates a `suspended` participant: they can submit posts again. Any other status answers 409; a removed participant stays removed.
pub async fn reinstate_campaign_participant(
configuration: &configuration::Configuration,
campaign_id: &str,
participant_id: &str,
) -> Result<models::GetCampaignParticipant200Response, Error<ReinstateCampaignParticipantError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_participant_id = participant_id;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/participants/{participantId}/reinstate",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
participantId = crate::apis::urlencode(p_path_participant_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::GetCampaignParticipant200Response`"))),
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::GetCampaignParticipant200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ReinstateCampaignParticipantError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Rejects a `submitted` draft version for good, emails the creator and fires `campaign_draft.rejected`. The reason is stored as `reviewNote`. A rejected draft takes no new version and backs no post. Each version is decided once: a version that is no longer `submitted` answers 409.
pub async fn reject_campaign_draft(
configuration: &configuration::Configuration,
campaign_id: &str,
draft_id: &str,
reject_campaign_draft_request: models::RejectCampaignDraftRequest,
idempotency_key: Option<&str>,
) -> Result<models::ApproveCampaignDraft200Response, Error<RejectCampaignDraftError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_draft_id = draft_id;
let p_body_reject_campaign_draft_request = reject_campaign_draft_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/drafts/{draftId}/reject",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
draftId = crate::apis::urlencode(p_path_draft_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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_reject_campaign_draft_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::ApproveCampaignDraft200Response`"))),
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::ApproveCampaignDraft200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RejectCampaignDraftError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Rejects a submission (also one already approved) and fires `campaign_submission.rejected`. Its tracking window is cancelled and its unsettled earnings return to the campaign budget. Rejecting a rejected submission returns it unchanged; an expired or withdrawn one answers 409.
pub async fn reject_campaign_submission(
configuration: &configuration::Configuration,
campaign_id: &str,
submission_id: &str,
reject_campaign_submission_request: models::RejectCampaignSubmissionRequest,
idempotency_key: Option<&str>,
) -> Result<models::ApproveCampaignSubmission200Response, Error<RejectCampaignSubmissionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_submission_id = submission_id;
let p_body_reject_campaign_submission_request = reject_campaign_submission_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/submissions/{submissionId}/reject",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
submissionId = crate::apis::urlencode(p_path_submission_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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_reject_campaign_submission_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::ApproveCampaignSubmission200Response`"))),
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::ApproveCampaignSubmission200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RejectCampaignSubmissionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Removes the participant from the campaign. Their earnings stay in the ledger. Removing an `invited` participant revokes their invite: the link stops working. Removing an already removed participant returns it unchanged.
pub async fn remove_campaign_participant(
configuration: &configuration::Configuration,
campaign_id: &str,
participant_id: &str,
) -> Result<models::GetCampaignParticipant200Response, Error<RemoveCampaignParticipantError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_participant_id = participant_id;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/participants/{participantId}/remove",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
participantId = crate::apis::urlencode(p_path_participant_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::GetCampaignParticipant200Response`"))),
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::GetCampaignParticipant200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RemoveCampaignParticipantError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Puts a rejected submission back to `pending_review` so it can be decided again. No webhook fires. Its tracking window resumes, so it works only while that window has not ended. ### When it can't be reopened - The tracking window has ended: 409 `invalid_resource_state` (\"This post's tracking window has ended.\"). - A post that earned money which was already paid out cannot be reopened. - A post of a closed campaign cannot be reopened. - Any status other than rejected or `pending_review` answers 409. Reopening a submission that is already `pending_review` returns it unchanged.
pub async fn reopen_campaign_submission(
configuration: &configuration::Configuration,
campaign_id: &str,
submission_id: &str,
idempotency_key: Option<&str>,
) -> Result<models::ApproveCampaignSubmission200Response, Error<ReopenCampaignSubmissionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_submission_id = submission_id;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/submissions/{submissionId}/reopen",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
submissionId = crate::apis::urlencode(p_path_submission_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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::ApproveCampaignSubmission200Response`"))),
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::ApproveCampaignSubmission200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ReopenCampaignSubmissionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Marks a `submitted` draft version `revision_requested`, emails the creator and fires `campaign_draft.revision_requested`. The creator answers with one new version (`revisionOf` set to this version). Send a `note`, at least one entry in `comments`, or both; neither answers 400 `missing_required_field`. A comment with `atMs` is pinned to that moment of the video. Each version is decided once: a version that is no longer `submitted` answers 409.
pub async fn request_campaign_draft_revision(
configuration: &configuration::Configuration,
campaign_id: &str,
draft_id: &str,
request_campaign_draft_revision_request: models::RequestCampaignDraftRevisionRequest,
idempotency_key: Option<&str>,
) -> Result<models::ApproveCampaignDraft200Response, Error<RequestCampaignDraftRevisionError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_draft_id = draft_id;
let p_body_request_campaign_draft_revision_request = request_campaign_draft_revision_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/drafts/{draftId}/request-revision",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
draftId = crate::apis::urlencode(p_path_draft_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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_request_campaign_draft_revision_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::ApproveCampaignDraft200Response`"))),
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::ApproveCampaignDraft200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<RequestCampaignDraftRevisionError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Emails an `invited` participant their personal invite link again. The link does not change, so a link you already sent keeps working. The email counts toward the daily invite email cap of your workspace. Answers 409 when the participant has already joined, was suspended or removed, has no email, or the campaign is closed.
pub async fn resend_campaign_participant_invite(
configuration: &configuration::Configuration,
campaign_id: &str,
participant_id: &str,
idempotency_key: Option<&str>,
) -> Result<models::GetCampaignParticipant200Response, Error<ResendCampaignParticipantInviteError>>
{
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_participant_id = participant_id;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/participants/{participantId}/resend-invite",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
participantId = crate::apis::urlencode(p_path_participant_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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::GetCampaignParticipant200Response`"))),
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::GetCampaignParticipant200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ResendCampaignParticipantInviteError> =
serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Records a payout of the participant's payable balance and fires `campaign_payout.settled`. No money moves through Zernio. Omit `amountCents` to settle the whole payable balance. An amount above it answers 400, and nothing payable answers 409. Send an `Idempotency-Key` so a retry never records the payout twice. ### Settlement modes - `none` settlement: records a payout you made elsewhere. - `external` settlement: pay from your own rails when `campaign_payout.payable` fires, then call this with your payout id in `externalReference` (required in this mode). - `treasury` settlement: send `recordOnly: true` to record a payout you made yourself (the webhook then carries `recorded: true`). Without it the call answers 409: Zernio pays creators of these campaigns by card with `POST /v1/creator-campaigns/{campaignId}/payout-batches`, never from your balance.
pub async fn settle_campaign_participant(
configuration: &configuration::Configuration,
campaign_id: &str,
participant_id: &str,
settle_campaign_participant_request: models::SettleCampaignParticipantRequest,
idempotency_key: Option<&str>,
) -> Result<models::SettleCampaignParticipant201Response, Error<SettleCampaignParticipantError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_participant_id = participant_id;
let p_body_settle_campaign_participant_request = settle_campaign_participant_request;
let p_header_idempotency_key = idempotency_key;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/participants/{participantId}/settle",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
participantId = crate::apis::urlencode(p_path_participant_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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_settle_campaign_participant_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::SettleCampaignParticipant201Response`"))),
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::SettleCampaignParticipant201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SettleCampaignParticipantError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Records that you sent an `approved` sample yourself, with an optional tracking link, emails the creator and fires `campaign_sample.shipped`. No store call or money is involved. Any other status answers 409.
pub async fn ship_campaign_sample(
configuration: &configuration::Configuration,
campaign_id: &str,
sample_id: &str,
idempotency_key: Option<&str>,
ship_campaign_sample_request: Option<models::ShipCampaignSampleRequest>,
) -> Result<models::ApproveCampaignSample200Response, Error<ShipCampaignSampleError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_sample_id = sample_id;
let p_header_idempotency_key = idempotency_key;
let p_body_ship_campaign_sample_request = ship_campaign_sample_request;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/samples/{sampleId}/ship",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
sampleId = crate::apis::urlencode(p_path_sample_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(param_value) = p_header_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", param_value.to_string());
}
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_ship_campaign_sample_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::ApproveCampaignSample200Response`"))),
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::ApproveCampaignSample200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ShipCampaignSampleError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Suspends an `active` participant: they can no longer submit posts. Any other status answers 409.
pub async fn suspend_campaign_participant(
configuration: &configuration::Configuration,
campaign_id: &str,
participant_id: &str,
) -> Result<models::GetCampaignParticipant200Response, Error<SuspendCampaignParticipantError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_path_participant_id = participant_id;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}/participants/{participantId}/suspend",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_id),
participantId = crate::apis::urlencode(p_path_participant_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::GetCampaignParticipant200Response`"))),
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::GetCampaignParticipant200Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SuspendCampaignParticipantError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Updates any subset of the campaign's settings. `economics` (and with it the campaign type) can only change while the campaign is a draft; afterwards that answers 409, and a live campaign's budget is raised with `POST /v1/creator-campaigns/{campaignId}/budget`. An empty body answers 400.
pub async fn update_creator_campaign(
configuration: &configuration::Configuration,
campaign_id: &str,
update_creator_campaign_request: models::UpdateCreatorCampaignRequest,
) -> Result<models::CreateCreatorCampaign201Response, Error<UpdateCreatorCampaignError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_path_campaign_id = campaign_id;
let p_body_update_creator_campaign_request = update_creator_campaign_request;
let uri_str = format!(
"{}/v1/creator-campaigns/{campaignId}",
configuration.base_path,
campaignId = crate::apis::urlencode(p_path_campaign_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_creator_campaign_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::CreateCreatorCampaign201Response`"))),
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::CreateCreatorCampaign201Response`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCreatorCampaignError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}