/*
* 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.526.1
* 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_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),
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 [`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 [`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_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_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_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 [`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 [`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 `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% per creator, 50 cent minimum) 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. Top up your balance to pay more this month, or contact support to raise the limit.\" - 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. ### 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,
}))
}
}
/// 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,
}))
}
}
/// 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 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 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 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,
}))
}
}
/// 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,
}))
}
}
/// 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,
}))
}
}