//!
//! AUTO-GENERATED CODE - DO NOT EDIT!
//!
//! Loops OpenAPI Spec
//! Source: target/openapi.normalized.json
//! Version: 1.22.6
//! Generated by `oas3-gen v0.28.0`
//!
//! This is the OpenAPI Spec for the [Loops API](https://loops.so/docs/api).
use serde::{Deserialize, Serialize};
use validator::Validate;
pub const IDEMPOTENCY_KEY: http::HeaderName = http::HeaderName::from_static("idempotency-key");
pub const WEBHOOK_ID: http::HeaderName = http::HeaderName::from_static("webhook-id");
pub const WEBHOOK_TIMESTAMP: http::HeaderName = http::HeaderName::from_static("webhook-timestamp");
pub const WEBHOOK_SIGNATURE: http::HeaderName = http::HeaderName::from_static("webhook-signature");
/// All-time email engagement counters. Opens and clicks count sends, not events: a send opened five times counts once. A recipient who received the email twice is counted once per send, not once per person.
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct EmailMetricsResponse {
/// Number of sends.
pub sends: i64,
/// Number of sends that were opened at least once.
pub opens: i64,
/// Number of sends where at least one link was clicked.
pub clicks: i64,
/// Number of unsubscribes.
pub unsubscribes: i64,
/// Number of sends reported as spam.
#[serde(rename = "spamReports")]
pub spam_reports: i64,
/// Number of sends that hard bounced.
#[serde(rename = "hardBounces")]
pub hard_bounces: i64,
/// Number of sends that soft bounced.
#[serde(rename = "softBounces")]
pub soft_bounces: i64,
}
/// All-time delivery counters for a transactional email.
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct TransactionalMetricsResponse {
/// Number of sends.
pub sends: i64,
/// Number of sends delivered.
pub deliveries: i64,
/// Number of sends reported as spam.
#[serde(rename = "spamReports")]
pub spam_reports: i64,
/// Number of sends that hard bounced.
#[serde(rename = "hardBounces")]
pub hard_bounces: i64,
/// Number of sends that soft bounced.
#[serde(rename = "softBounces")]
pub soft_bounces: i64,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct Contact {
/// The contact's Loops ID.
pub id: Option<String>,
/// The contact's email address.
pub email: Option<String>,
/// The contact's first name.
#[serde(rename = "firstName")]
pub first_name: Option<String>,
/// The contact's last name.
#[serde(rename = "lastName")]
pub last_name: Option<String>,
/// The source the contact was created from.
pub source: Option<String>,
/// Whether the contact will receive campaign and workflow emails.
pub subscribed: Option<bool>,
/// The contact's user group.
#[serde(rename = "userGroup")]
pub user_group: Option<String>,
/// The contact's unique user ID.
#[serde(rename = "userId")]
pub user_id: Option<String>,
/// Mailing lists the contact is subscribed to, represented by key-value pairs of mailing list IDs and `true`.
#[serde(rename = "mailingLists")]
pub mailing_lists: Option<serde_json::Value>,
/// Double opt-in status. This will be `null` for contacts unless they are created via a form while double opt-in is enabled.
#[serde(rename = "optInStatus")]
pub opt_in_status: Option<OptInStatus>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
pub struct ContactFields {
/// The contact's email address.
pub email: Option<String>,
/// The contact's first name.
#[serde(rename = "firstName")]
pub first_name: Option<String>,
/// The contact's last name.
#[serde(rename = "lastName")]
pub last_name: Option<String>,
/// A custom source value to replace the default “API”.
pub source: Option<String>,
/// Whether the contact will receive campaign and workflow emails. All new contacts are subscribed by default.
pub subscribed: Option<bool>,
/// The contact's user group.
#[serde(rename = "userGroup")]
pub user_group: Option<String>,
/// A unique user ID (for example, from an external application).
#[serde(rename = "userId")]
pub user_id: Option<String>,
/// Manage mailing list subscriptions.
///
/// Include key-value pairs of mailing list IDs and a `boolean` denoting if the contact should be added (`true`) or removed (`false`) from the list.
#[serde(rename = "mailingLists")]
pub mailing_lists: Option<serde_json::Value>,
/// Additional properties not defined in the schema.
#[serde(flatten)]
pub additional_properties: indexmap::IndexMap<String, String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct ContactRequest {
/// The contact's email address.
#[validate(length(min = 1u64))]
pub email: String,
/// The contact's first name.
#[serde(rename = "firstName")]
pub first_name: Option<String>,
/// The contact's last name.
#[serde(rename = "lastName")]
pub last_name: Option<String>,
/// A custom source value to replace the default “API”.
pub source: Option<String>,
/// Whether the contact will receive campaign and workflow emails. All new contacts are subscribed by default.
pub subscribed: Option<bool>,
/// The contact's user group.
#[serde(rename = "userGroup")]
pub user_group: Option<String>,
/// A unique user ID (for example, from an external application).
#[serde(rename = "userId")]
pub user_id: Option<String>,
/// Manage mailing list subscriptions.
///
/// Include key-value pairs of mailing list IDs and a `boolean` denoting if the contact should be added (`true`) or removed (`false`) from the list.
#[serde(rename = "mailingLists")]
pub mailing_lists: Option<serde_json::Value>,
/// Additional properties not defined in the schema.
#[serde(flatten)]
pub additional_properties: indexmap::IndexMap<String, String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct ContactUpdateRequest {
/// The contact's email address. **Required if `userId` is not provided.**
pub email: Option<String>,
/// The contact's first name.
#[serde(rename = "firstName")]
pub first_name: Option<String>,
/// The contact's last name.
#[serde(rename = "lastName")]
pub last_name: Option<String>,
/// A custom source value to replace the default “API”.
pub source: Option<String>,
/// Whether the contact will receive campaign and workflow emails. We recommend leaving this field out of your update requests unless you specifically want to unsubscribe (`false`) or re-subscribe (`true`) a contact. All new contacts are subscribed by default.
pub subscribed: Option<bool>,
/// The contact's user group.
#[serde(rename = "userGroup")]
pub user_group: Option<String>,
/// The contact's unique user ID. **Required if `email` is not provided.**
#[serde(rename = "userId")]
pub user_id: Option<String>,
/// Manage mailing list subscriptions.
///
/// Include key-value pairs of mailing list IDs and a `boolean` denoting if the contact should be added (`true`) or removed (`false`) from the list.
#[serde(rename = "mailingLists")]
pub mailing_lists: Option<serde_json::Value>,
/// Additional properties not defined in the schema.
#[serde(flatten)]
pub additional_properties: indexmap::IndexMap<String, String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ContactSuccessResponse {
pub success: bool,
pub id: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ContactFailureResponse {
pub success: bool,
pub message: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
#[serde(untagged)]
pub enum ContactDeleteRequest {
#[default]
Email(serde_json::Value),
UserId(serde_json::Value),
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ContactDeleteResponse {
pub success: bool,
pub message: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ContactSuppressionStatusResponse {
pub contact: ContactSuppressionStatusResponseContact,
/// Whether the contact is suppressed.
#[serde(rename = "isSuppressed")]
pub is_suppressed: bool,
#[serde(rename = "removalQuota")]
pub removal_quota: ContactSuppressionRemovalQuota,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ContactSuppressionRemoveResponse {
/// Whether the suppression removal was successful.
pub success: bool,
pub message: String,
#[serde(rename = "removalQuota")]
pub removal_quota: ContactSuppressionRemovalQuota,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ContactSuppressionRemovalQuota {
/// The number of suppression removals allowed in a rolling 30 day period.
pub limit: f64,
/// The remaining number of suppression removals left in the current 30 day period.
pub remaining: f64,
}
/// There are a few [reserved names](https://loops.so/docs/contacts/properties#reserved-names) that you cannot use for contact properties.
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct ContactPropertyCreateRequest {
/// The name of the property. This should be in camelCase, like `planName` or `importDate`.
#[validate(length(min = 1u64))]
pub name: String,
/// The type of property.
#[serde(rename = "type")]
pub r#type: ContactPropertyCreateRequestType,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ContactPropertySuccessResponse {
pub success: bool,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ContactPropertyFailureResponse {
pub success: bool,
pub message: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
#[serde(untagged)]
pub enum EventRequest {
#[default]
Email(serde_json::Value),
UserId(serde_json::Value),
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct EventSuccessResponse {
pub success: bool,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct EventFailureResponse {
pub success: bool,
pub message: String,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct TransactionalRequest {
/// The recipient's email address.
#[validate(length(min = 1u64))]
pub email: String,
/// The ID of the transactional email to send.
#[serde(rename = "transactionalId")]
#[validate(length(min = 1u64))]
pub transactional_id: String,
/// If `true`, a contact will be created in your audience using the `email` value (if a matching contact doesn't already exist).
#[serde(rename = "addToAudience")]
pub add_to_audience: Option<bool>,
/// An object containing data as defined by the data variables added to the transactional email template. Values can be of type string or number.
///
/// If you have added optional data variables to your email, you can exclude them from the dataVariables object or set the value to "".
///
/// If you have added an array data variable to your email, make sure to include an array matching the data variables you added to your array block.
#[serde(rename = "dataVariables")]
pub data_variables: Option<serde_json::Value>,
/// A list containing file objects to be sent along with an email message. Attachments must be enabled by Loops support before they can be used with the API.
#[validate(nested)]
pub attachments: Option<Vec<TransactionalRequestAttachment>>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct TransactionalSuccessResponse {
pub success: bool,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct TransactionalFailureResponse {
pub message: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct TransactionalSendFailureResponse {
pub success: bool,
pub message: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct TransactionalFailure2Response {
pub success: bool,
pub message: String,
pub path: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct TransactionalFailure3Response {
pub success: bool,
pub message: String,
pub error: ResponseError,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct TransactionalFailure4Response {
pub success: bool,
pub message: String,
pub error: TransactionalFailure4ResponseError,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct TransactionalFailure5Response {
pub success: bool,
pub message: String,
pub error: ResponseError,
#[serde(rename = "transactionalId")]
pub transactional_id: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct IdempotencyKeyFailureResponse {
pub success: bool,
pub message: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct TransactionalEmail {
/// The ID of the transactional email.
pub id: String,
/// The name of the transactional email.
pub name: String,
/// The date and time the transactional email was last updated in ISO 8601 format.
#[serde(rename = "lastUpdated")]
pub last_updated: String,
/// The data variables used by the transactional email.
#[serde(rename = "dataVariables")]
pub data_variables: Vec<serde_json::Value>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ListTransactionalsResponse {
pub pagination: Option<Pagination>,
pub data: Option<Vec<TransactionalEmail>>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct TransactionalResource {
/// The ID of the transactional email.
pub id: String,
/// The URL of the transactional email in the Loops app.
pub url: String,
/// The name of the transactional email.
pub name: String,
/// The ID of the draft email message. `null` if there is no draft version.
#[serde(rename = "draftEmailMessageId")]
pub draft_email_message_id: Option<String>,
/// The ID of the published email message. `null` if there is no published version.
#[serde(rename = "publishedEmailMessageId")]
pub published_email_message_id: Option<String>,
/// The ID of the group this transactional email belongs to.
#[serde(rename = "transactionalGroupId")]
pub transactional_group_id: Option<String>,
/// ISO 8601 timestamp for when the transactional email was created.
#[serde(rename = "createdAt")]
pub created_at: chrono::DateTime<chrono::Utc>,
/// ISO 8601 timestamp for when the transactional email was last updated.
#[serde(rename = "updatedAt")]
pub updated_at: chrono::DateTime<chrono::Utc>,
/// Data variable names used by the published email. Empty for unpublished transactional emails.
#[serde(rename = "dataVariables")]
pub data_variables: Vec<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct TransactionalDraftResponse {
/// The ID of the transactional email.
pub id: String,
/// The URL of the transactional email in the Loops app.
pub url: String,
/// The name of the transactional email.
pub name: String,
/// The ID of the draft email message.
#[serde(rename = "draftEmailMessageId")]
pub draft_email_message_id: Option<String>,
/// The `contentRevisionId` of the draft email message. Pass this as `expectedRevisionId` on your first update via `POST /v1/email-messages/{emailMessageId}`.
#[serde(rename = "draftEmailMessageContentRevisionId")]
pub draft_email_message_content_revision_id: Option<String>,
/// The ID of the published email message. `null` if there is no published version.
#[serde(rename = "publishedEmailMessageId")]
pub published_email_message_id: Option<String>,
/// The ID of the group this transactional email belongs to. Returned when creating a transactional email.
#[serde(rename = "transactionalGroupId")]
pub transactional_group_id: Option<String>,
/// ISO 8601 timestamp for when the transactional email was created.
#[serde(rename = "createdAt")]
pub created_at: chrono::DateTime<chrono::Utc>,
/// ISO 8601 timestamp for when the transactional email was last updated.
#[serde(rename = "updatedAt")]
pub updated_at: chrono::DateTime<chrono::Utc>,
/// Data variable names used by the published email. Empty for unpublished transactional emails.
#[serde(rename = "dataVariables")]
pub data_variables: Vec<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ListTransactionalsResourceResponse {
pub pagination: Pagination,
pub data: Vec<TransactionalResource>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct CreateTransactionalRequest {
/// The name of the transactional email.
#[validate(length(min = 1u64))]
pub name: String,
/// The ID of the group to add this transactional email to. Defaults to the team's Unsorted group when omitted.
#[serde(rename = "transactionalGroupId")]
pub transactional_group_id: Option<String>,
}
/// At least one field must be provided.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct UpdateTransactionalRequest {
pub name: Option<String>,
/// The ID of the group to move this transactional email to.
#[serde(rename = "transactionalGroupId")]
pub transactional_group_id: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ContactProperty {
/// The key of the contact property.
pub key: String,
/// The human-friendly label for this property.
pub label: String,
/// The type of property.
#[serde(rename = "type")]
pub r#type: ContactPropertyCreateRequestType,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct MailingList {
/// The ID of the mailing list.
pub id: String,
/// The name of the mailing list.
pub name: String,
/// The description of the mailing list. `null` if no description is set.
pub description: Option<String>,
/// Whether the mailing list is public (`true`) or private (`false`).
#[serde(rename = "isPublic")]
pub is_public: bool,
}
/// Manage mailing list subscriptions.
///
/// Include key-value pairs of mailing list IDs and a `boolean` denoting if the contact should be added (`true`) or removed (`false`) from the list.
pub type MailingListSubscriptions = serde_json::Value;
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct Theme {
/// The ID of the theme.
pub id: String,
/// The name of the theme.
pub name: String,
/// Flat map of style attributes, matching the attribute names accepted by the LMX `<Style />` tag.
pub styles: ThemeStyles,
/// Whether this theme is the team's default.
#[serde(rename = "isDefault")]
pub is_default: bool,
/// ISO 8601 timestamp for when the theme was created.
#[serde(rename = "createdAt")]
pub created_at: String,
/// ISO 8601 timestamp for when the theme was last updated.
#[serde(rename = "updatedAt")]
pub updated_at: String,
}
/// Flat map of style attributes, matching the attribute names accepted by the LMX `<Style />` tag.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
pub struct ThemeStyles {
#[serde(rename = "backgroundColor")]
pub background_color: Option<String>,
#[serde(rename = "backgroundXPadding")]
pub background_xpadding: Option<f64>,
#[serde(rename = "backgroundYPadding")]
pub background_ypadding: Option<f64>,
#[serde(rename = "bodyColor")]
pub body_color: Option<String>,
#[serde(rename = "bodyXPadding")]
pub body_xpadding: Option<f64>,
#[serde(rename = "bodyYPadding")]
pub body_ypadding: Option<f64>,
#[serde(rename = "bodyFontFamily")]
pub body_font_family: Option<String>,
#[serde(rename = "bodyFontCategory")]
pub body_font_category: Option<String>,
#[serde(rename = "borderColor")]
pub border_color: Option<String>,
#[serde(rename = "borderWidth")]
pub border_width: Option<f64>,
#[serde(rename = "borderRadius")]
pub border_radius: Option<f64>,
#[serde(rename = "buttonBodyColor")]
pub button_body_color: Option<String>,
#[serde(rename = "buttonBodyXPadding")]
pub button_body_xpadding: Option<f64>,
#[serde(rename = "buttonBodyYPadding")]
pub button_body_ypadding: Option<f64>,
#[serde(rename = "buttonBorderColor")]
pub button_border_color: Option<String>,
#[serde(rename = "buttonBorderWidth")]
pub button_border_width: Option<f64>,
#[serde(rename = "buttonBorderRadius")]
pub button_border_radius: Option<f64>,
#[serde(rename = "buttonTextColor")]
pub button_text_color: Option<String>,
#[serde(rename = "buttonTextFormat")]
pub button_text_format: Option<f64>,
#[serde(rename = "buttonTextFontSize")]
pub button_text_font_size: Option<f64>,
#[serde(rename = "dividerColor")]
pub divider_color: Option<String>,
#[serde(rename = "dividerBorderWidth")]
pub divider_border_width: Option<f64>,
#[serde(rename = "textBaseColor")]
pub text_base_color: Option<String>,
#[serde(rename = "textBaseFontSize")]
pub text_base_font_size: Option<f64>,
#[serde(rename = "textBaseLineHeight")]
pub text_base_line_height: Option<f64>,
#[serde(rename = "textBaseLetterSpacing")]
pub text_base_letter_spacing: Option<f64>,
#[serde(rename = "textLinkColor")]
pub text_link_color: Option<String>,
#[serde(rename = "heading1Color")]
pub heading1color: Option<String>,
#[serde(rename = "heading1FontSize")]
pub heading1font_size: Option<f64>,
#[serde(rename = "heading1LineHeight")]
pub heading1line_height: Option<f64>,
#[serde(rename = "heading1LetterSpacing")]
pub heading1letter_spacing: Option<f64>,
#[serde(rename = "heading2Color")]
pub heading2color: Option<String>,
#[serde(rename = "heading2FontSize")]
pub heading2font_size: Option<f64>,
#[serde(rename = "heading2LineHeight")]
pub heading2line_height: Option<f64>,
#[serde(rename = "heading2LetterSpacing")]
pub heading2letter_spacing: Option<f64>,
#[serde(rename = "heading3Color")]
pub heading3color: Option<String>,
#[serde(rename = "heading3FontSize")]
pub heading3font_size: Option<f64>,
#[serde(rename = "heading3LineHeight")]
pub heading3line_height: Option<f64>,
#[serde(rename = "heading3LetterSpacing")]
pub heading3letter_spacing: Option<f64>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ListThemesResponse {
pub pagination: Pagination,
pub data: Vec<Theme>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ThemeResponse {
/// The ID of the theme.
pub id: String,
/// The name of the theme.
pub name: String,
/// Flat map of style attributes, matching the attribute names accepted by the LMX `<Style />` tag.
pub styles: ThemeStyles,
/// Whether this theme is the team's default.
#[serde(rename = "isDefault")]
pub is_default: bool,
/// ISO 8601 timestamp for when the theme was created.
#[serde(rename = "createdAt")]
pub created_at: String,
/// ISO 8601 timestamp for when the theme was last updated.
#[serde(rename = "updatedAt")]
pub updated_at: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ThemeFailureResponse {
pub message: String,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct CreateThemeBody {
/// The theme name.
#[validate(length(min = 1u64))]
pub name: String,
/// Flat map of style attributes, matching the attribute names accepted by the LMX `<Style />` tag.
pub styles: Option<ThemeStyles>,
}
/// At least one of `name` or `styles` must be provided.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct UpdateThemeBody {
pub name: Option<String>,
/// Flat map of style attributes, matching the attribute names accepted by the LMX `<Style />` tag.
pub styles: Option<ThemeStyles>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct UpdateThemeResponse {
/// The ID of the theme.
pub id: String,
/// The name of the theme.
pub name: String,
/// Flat map of style attributes, matching the attribute names accepted by the LMX `<Style />` tag.
pub styles: ThemeStyles,
/// Whether this theme is the team's default.
#[serde(rename = "isDefault")]
pub is_default: bool,
/// ISO 8601 timestamp for when the theme was created.
#[serde(rename = "createdAt")]
pub created_at: String,
/// ISO 8601 timestamp for when the theme was last updated.
#[serde(rename = "updatedAt")]
pub updated_at: String,
/// The number of emails using this theme that are affected by the style change. `0` when only the name changed.
#[serde(rename = "affectedEmailCount")]
pub affected_email_count: f64,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct Component {
pub id: String,
pub name: String,
/// The component body serialized as LMX.
pub lmx: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ListComponentsResponse {
pub pagination: Pagination,
pub data: Vec<Component>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ComponentResponse {
/// The ID of the component.
pub id: String,
/// The name of the component.
pub name: String,
/// The component body serialized as LMX.
pub lmx: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ComponentFailureResponse {
pub message: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ComponentValidationFailureResponse {
pub message: String,
/// The dynamic variables that the change would push into an email that cannot use them. Present only when the update was rejected for that reason.
#[serde(rename = "invalidTags")]
pub invalid_tags: Option<Vec<String>>,
}
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct CreateComponentBody {
/// The component name.
#[validate(length(min = 1u64))]
pub name: String,
/// The component body as an LMX string.
#[validate(length(min = 1u64))]
pub lmx: String,
}
/// At least one of `name` or `lmx` must be provided.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct UpdateComponentBody {
pub name: Option<String>,
/// The component body as an LMX string.
pub lmx: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct UpdateComponentResponse {
/// The ID of the component.
pub id: String,
/// The name of the component.
pub name: String,
/// The component body serialized as LMX.
pub lmx: String,
/// The number of emails using this component that were updated by the body change. `0` when only the name changed.
#[serde(rename = "affectedEmailCount")]
pub affected_email_count: f64,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct AudienceSegment {
/// The ID of the audience segment.
pub id: String,
/// The name of the audience segment.
pub name: String,
/// An optional description of the audience segment.
pub description: Option<String>,
/// ISO 8601 timestamp for when the audience segment was created.
#[serde(rename = "createdAt")]
pub created_at: String,
/// ISO 8601 timestamp for when the audience segment was last updated.
#[serde(rename = "updatedAt")]
pub updated_at: String,
pub filter: Option<AudienceFilter>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ListAudienceSegmentsResponse {
pub pagination: Pagination,
pub data: Vec<AudienceSegment>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct AudienceSegmentResponse {
/// The ID of the audience segment.
pub id: String,
/// The name of the audience segment.
pub name: String,
/// An optional description of the audience segment.
pub description: Option<String>,
/// ISO 8601 timestamp for when the audience segment was created.
#[serde(rename = "createdAt")]
pub created_at: String,
/// ISO 8601 timestamp for when the audience segment was last updated.
#[serde(rename = "updatedAt")]
pub updated_at: String,
pub filter: Option<AudienceFilter>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct CreateAudienceSegmentRequest {
/// The name of the audience segment. Must be unique within the team.
#[validate(length(max = 255u64))]
pub name: String,
/// An optional description of the audience segment.
#[validate(length(max = 1_000u64))]
pub description: Option<String>,
/// A tree of audience conditions combined with `match`.
#[validate(nested)]
pub filter: CreateAudienceSegmentRequestFilter,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct AudienceSegmentFailureResponse {
pub message: String,
}
/// When the campaign is scheduled to send.
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct CampaignScheduling {
pub method: Method,
/// ISO 8601 send time. Null when the method is `now`.
pub timestamp: Option<chrono::DateTime<chrono::Utc>>,
}
/// When the campaign should send. `timestamp` is required and must be in the future when `method` is `schedule`, and must be omitted when `method` is `now`.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct CampaignSchedulingRequest {
pub method: Method,
pub timestamp: Option<chrono::DateTime<chrono::Utc>>,
}
/// A tree of audience conditions combined with `match`.
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
pub struct AudienceFilter {
#[serde(rename = "match")]
pub r#match: Match,
#[validate(length(min = 1u64))]
pub conditions: Vec<AudienceFilterCondition>,
}
/// A tree of audience conditions combined with `match`. Setting this without also providing `audienceSegmentId` clears any existing `audienceSegmentId`. When both are provided, this filter is applied on top of the segment's filter.
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct AudienceFilterInRequest {
#[serde(rename = "match")]
pub r#match: Match,
#[validate(length(min = 1u64))]
pub conditions: Vec<AudienceFilterCondition>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum AudienceFilterCondition {
Property(PropertyCondition),
OptIn(OptInCondition),
Activity(ActivityCondition),
}
impl AudienceFilterCondition {
pub const DISCRIMINATOR_FIELD: &'static str = "type";
}
impl Default for AudienceFilterCondition {
fn default() -> Self {
Self::Property(<PropertyCondition>::default())
}
}
impl serde::Serialize for AudienceFilterCondition {
fn serialize<S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Property(v) => v.serialize(serializer),
Self::OptIn(v) => v.serialize(serializer),
Self::Activity(v) => v.serialize(serializer),
}
}
}
impl<'de> serde::Deserialize<'de> for AudienceFilterCondition {
fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let value = serde_json::Value::deserialize(deserializer)?;
match value
.get(Self::DISCRIMINATOR_FIELD)
.and_then(|v| v.as_str())
{
Some("property") => serde_json::from_value(value)
.map(Self::Property)
.map_err(serde::de::Error::custom),
Some("optIn") => serde_json::from_value(value)
.map(Self::OptIn)
.map_err(serde::de::Error::custom),
Some("activity") => serde_json::from_value(value)
.map(Self::Activity)
.map_err(serde::de::Error::custom),
None => Err(serde::de::Error::missing_field(Self::DISCRIMINATOR_FIELD)),
Some(other) => Err(serde::de::Error::custom(format!(
"Unknown discriminator value '{}' for field '{}'",
other, "type"
))),
}
}
}
/// Matches contacts by a property value.
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct PropertyCondition {
#[doc(hidden)]
#[serde(default, rename = "type", skip_deserializing)]
#[default(Some("property"))]
pub r#type: Option<&'static str>,
/// The contact property name.
#[validate(length(min = 1u64))]
pub key: String,
pub operator: PropertyConditionOperator,
/// The comparison value. Omitted for value-less operators (e.g. `isTrue`, `empty`). A `{ from, to }` object for `between`.
pub value: Option<PropertyConditionValue>,
}
/// Matches contacts by mailing list opt-in status.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct OptInCondition {
#[doc(hidden)]
#[serde(default, rename = "type", skip_deserializing)]
#[default(Some("optIn"))]
pub r#type: Option<&'static str>,
pub status: Option<Status>,
}
/// Matches contacts by their activity on a campaign or workflow.
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct ActivityCondition {
#[doc(hidden)]
#[serde(default, rename = "type", skip_deserializing)]
#[default(Some("activity"))]
pub r#type: Option<&'static str>,
pub action: ActivityConditionAction,
pub negate: bool,
pub target: ActivityConditionTarget,
/// The ID of the campaign, workflow, or workflow email.
#[validate(length(min = 1u64))]
pub id: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ListCampaignsResponse {
pub pagination: Pagination,
pub data: Vec<CampaignResponse>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct CreateCampaignRequest {
/// The campaign name.
#[validate(length(min = 1u64))]
pub name: String,
/// The ID of the group to add this campaign to. Defaults to the team's Unsorted group when omitted.
#[serde(rename = "campaignGroupId")]
pub campaign_group_id: Option<String>,
/// The ID of the mailing list to send to.
#[serde(rename = "mailingListId")]
pub mailing_list_id: Option<String>,
/// The ID of an audience segment. Setting this without also providing `audienceFilter` clears any existing `audienceFilter`. If both are provided, the filter is applied on top of the segment's filter.
#[serde(rename = "audienceSegmentId")]
pub audience_segment_id: Option<String>,
#[serde(rename = "audienceFilter")]
#[validate(nested)]
pub audience_filter: Option<AudienceFilterInRequest>,
/// When the campaign should send. `timestamp` is required and must be in the future when `method` is `schedule`, and must be omitted when `method` is `now`.
pub scheduling: Option<CampaignSchedulingRequest>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct CreateCampaignResponse {
/// The ID of the campaign.
pub id: String,
/// The URL of the campaign in the Loops app.
pub url: String,
/// The name of the campaign.
pub name: String,
/// The status of the campaign (always `Draft` for new campaigns).
#[default("Draft".to_string())]
pub status: String,
/// ISO 8601 timestamp for when the campaign was created.
#[serde(rename = "createdAt")]
pub created_at: chrono::DateTime<chrono::Utc>,
/// ISO 8601 timestamp for when the campaign was last updated.
#[serde(rename = "updatedAt")]
pub updated_at: chrono::DateTime<chrono::Utc>,
/// The ID of the empty email message created for this campaign. Use `POST /v1/email-messages/{emailMessageId}` to set its fields and LMX content.
#[serde(rename = "emailMessageId")]
pub email_message_id: Option<String>,
/// The `contentRevisionId` of the newly created email message. Pass this as `expectedRevisionId` on your first update.
#[serde(rename = "emailMessageContentRevisionId")]
pub email_message_content_revision_id: Option<String>,
/// The ID of the campaign group this campaign belongs to, if set.
#[serde(rename = "campaignGroupId")]
pub campaign_group_id: Option<String>,
/// The ID of the mailing list this campaign sends to, if set.
#[serde(rename = "mailingListId")]
pub mailing_list_id: Option<String>,
/// The ID of the audience segment this campaign targets, if set.
#[serde(rename = "audienceSegmentId")]
pub audience_segment_id: Option<String>,
/// The filter rules that define the audience for this campaign, if set.
#[serde(rename = "audienceFilter")]
pub audience_filter: Option<AudienceFilter>,
/// When the campaign is scheduled to send.
pub scheduling: CampaignScheduling,
}
/// At least one field must be provided.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateCampaignRequest {
/// The updated campaign name.
pub name: Option<String>,
/// The ID of the group to move this campaign to.
#[serde(rename = "campaignGroupId")]
pub campaign_group_id: Option<String>,
/// The ID of the mailing list to send to.
#[serde(rename = "mailingListId")]
pub mailing_list_id: Option<String>,
/// The ID of an audience segment. Setting this without also providing `audienceFilter` clears any existing `audienceFilter`. If both are provided, the filter is applied on top of the segment's filter.
#[serde(rename = "audienceSegmentId")]
pub audience_segment_id: Option<String>,
#[serde(rename = "audienceFilter")]
#[validate(nested)]
pub audience_filter: Option<AudienceFilterInRequest>,
/// When the campaign should send. `timestamp` is required and must be in the future when `method` is `schedule`, and must be omitted when `method` is `now`.
pub scheduling: Option<CampaignSchedulingRequest>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct CampaignResponse {
/// The ID of the campaign.
pub id: String,
/// The URL of the campaign in the Loops app.
pub url: String,
/// The name of the campaign.
pub name: String,
/// The status of the campaign.
pub status: Status2,
/// ISO 8601 timestamp for when the campaign was created.
#[serde(rename = "createdAt")]
pub created_at: chrono::DateTime<chrono::Utc>,
/// ISO 8601 timestamp for when the campaign was last updated.
#[serde(rename = "updatedAt")]
pub updated_at: chrono::DateTime<chrono::Utc>,
/// The associated email message ID.
#[serde(rename = "emailMessageId")]
pub email_message_id: Option<String>,
/// The ID of the campaign group this campaign belongs to.
#[serde(rename = "campaignGroupId")]
pub campaign_group_id: Option<String>,
/// The ID of the mailing list this campaign sends to, if set.
#[serde(rename = "mailingListId")]
pub mailing_list_id: Option<String>,
/// The ID of the audience segment this campaign targets, if set.
#[serde(rename = "audienceSegmentId")]
pub audience_segment_id: Option<String>,
/// The filter rules that define the audience for this campaign, if set.
#[serde(rename = "audienceFilter")]
pub audience_filter: Option<AudienceFilter>,
/// When the campaign is scheduled to send.
pub scheduling: CampaignScheduling,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct CampaignFailureResponse {
pub message: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct WorkflowSummary {
/// The ID of the workflow.
pub id: String,
/// The URL of the workflow in the Loops app.
pub url: String,
/// The name of the workflow.
pub name: String,
/// The ID of the workflow group this workflow belongs to.
#[serde(rename = "workflowGroupId")]
pub workflow_group_id: String,
/// ISO 8601 timestamp for when the workflow was created.
#[serde(rename = "createdAt")]
pub created_at: chrono::DateTime<chrono::Utc>,
/// ISO 8601 timestamp for when the workflow was last updated.
#[serde(rename = "updatedAt")]
pub updated_at: chrono::DateTime<chrono::Utc>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ListWorkflowsResponse {
pub pagination: Pagination,
pub data: Vec<WorkflowSummary>,
}
/// The current workflow revision token. Pass the latest value as `expectedRevisionId` on the next workflow mutation.
pub type WorkflowRevisionId = serde_json::Value;
/// The current workflow revision token. Pass the latest value as `expectedRevisionId` on the next workflow mutation. Will be `null` for workflows without a revision token yet.
pub type NullableWorkflowRevisionId = Option<String>;
/// If `true`, the contacts will be able to enter this workflow every time the trigger is matched. If `false`, contacts will only ever enter this workflow once. Matches the "Trigger frequency" option in the UI.
pub type WorkflowReEligible = bool;
/// The IDs of the nodes that are downstream of this node.
pub type WorkflowNextNodeIds = Vec<String>;
/// The workflow revision token returned by the latest workflow read or mutation. Older workflows may return `null` before their first revision-aware mutation; pass `null` back as `expectedRevisionId` in that case. If the token is stale, the API returns a `409 Conflict` error.
pub type WorkflowExpectedRevisionId = Option<String>;
/// `fail` returns queued-contact impact instead of mutating. `discard` confirms that matching queued contacts should be discarded. Defaults to `fail` when omitted.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, oas3_gen_support::Default)]
pub enum WorkflowQueuedContactPolicy {
#[serde(rename = "fail")]
#[default]
Fail,
#[serde(rename = "discard")]
Discard,
}
impl core::fmt::Display for WorkflowQueuedContactPolicy {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Fail => write!(f, "fail"),
Self::Discard => write!(f, "discard"),
}
}
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct SimplifiedWorkflow {
/// The ID of the workflow.
pub id: String,
/// The URL of the workflow in the Loops app.
pub url: String,
#[serde(rename = "workflowRevisionId")]
pub workflow_revision_id: Option<NullableWorkflowRevisionId>,
pub status: SimplifiedWorkflowStatus,
/// The name of the workflow.
pub name: Option<String>,
/// The description of the workflow.
pub description: Option<String>,
/// The ID of the workflow group this workflow belongs to.
#[serde(rename = "workflowGroupId")]
pub workflow_group_id: String,
/// The ID of the mailing list the workflow sends to.
#[serde(rename = "mailingListId")]
pub mailing_list_id: Option<String>,
/// The ID of the root node in the workflow graph.
#[serde(rename = "rootNodeId")]
pub root_node_id: String,
/// A map of node IDs to simplified node objects. Each node includes `typeName` and `nextNodeIds`, plus type-specific fields when present. To get the full node object, use the `GET /v1/workflows/{workflowId}/nodes/{nodeId}` endpoint.
/// - Example: `{"cf16k73gq014h3mmj5b6jdi9r":{"typeName":"SignupTrigger","nextNodeIds":["cf16k73gq014h3mmj5b4jdifg","cf16k73gq014h3mmj5b4jdifh"]}}`
pub nodes: indexmap::IndexMap<String, Box<SimplifiedWorkflowNode>>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct CreateWorkflowRequest {
/// The name of the workflow.
#[validate(length(min = 1u64))]
pub name: String,
/// The description of the workflow.
pub description: Option<String>,
/// The ID of a mailing list the workflow sends to. After creation, the mailing list can be changed with the `/v1/workflows/{workflowId}/mailing-list` endpoint.
#[serde(rename = "mailingListId")]
pub mailing_list_id: Option<String>,
/// The ID of the workflow group to create this workflow in. Defaults to the team's Unsorted group when omitted.
#[serde(rename = "workflowGroupId")]
pub workflow_group_id: Option<String>,
}
/// At least one property must be provided.
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
#[serde(untagged)]
pub enum UpdateWorkflowPropertiesRequest {
#[default]
Name(serde_json::Value),
Description(serde_json::Value),
WorkflowGroup(serde_json::Value),
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct DeleteWorkflowRequest {
#[serde(rename = "expectedRevisionId")]
pub expected_revision_id: Option<WorkflowExpectedRevisionId>,
/// Set to `true` after a confirmation-required `409 Conflict` response to confirm deleting a sending workflow or a workflow with queued contacts.
#[serde(rename = "confirmDelete")]
pub confirm_delete: Option<bool>,
}
/// Detailed workflow node returned from create and update mutations. The exact fields depend on `typeName`.
#[derive(Debug, Clone, PartialEq)]
pub enum WorkflowMutationNode {
SignupTrigger(SignupTriggerWorkflowMutationNode),
EventTrigger(EventTriggerWorkflowMutationNode),
ContactPropertyTrigger(ContactPropertyTriggerWorkflowMutationNode),
AddToListTrigger(AddToListTriggerWorkflowMutationNode),
BlankTrigger(BlankTriggerWorkflowMutationNode),
AudienceFilter(AudienceFilterWorkflowMutationNode),
TimerAction(TimerActionWorkflowMutationNode),
SendEmailAction(SendEmailActionWorkflowMutationNode),
ExitAction(ExitActionWorkflowMutationNode),
Branch(BranchWorkflowMutationNode),
ExperimentBranch(ExperimentBranchWorkflowMutationNode),
Variant(VariantWorkflowMutationNode),
}
impl WorkflowMutationNode {
pub const DISCRIMINATOR_FIELD: &'static str = "typeName";
}
impl Default for WorkflowMutationNode {
fn default() -> Self {
Self::SignupTrigger(<SignupTriggerWorkflowMutationNode>::default())
}
}
impl<'de> serde::Deserialize<'de> for WorkflowMutationNode {
fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let value = serde_json::Value::deserialize(deserializer)?;
match value
.get(Self::DISCRIMINATOR_FIELD)
.and_then(|v| v.as_str())
{
Some("SignupTrigger") => serde_json::from_value(value)
.map(Self::SignupTrigger)
.map_err(serde::de::Error::custom),
Some("EventTrigger") => serde_json::from_value(value)
.map(Self::EventTrigger)
.map_err(serde::de::Error::custom),
Some("ContactPropertyTrigger") => serde_json::from_value(value)
.map(Self::ContactPropertyTrigger)
.map_err(serde::de::Error::custom),
Some("AddToListTrigger") => serde_json::from_value(value)
.map(Self::AddToListTrigger)
.map_err(serde::de::Error::custom),
Some("BlankTrigger") => serde_json::from_value(value)
.map(Self::BlankTrigger)
.map_err(serde::de::Error::custom),
Some("AudienceFilter") => serde_json::from_value(value)
.map(Self::AudienceFilter)
.map_err(serde::de::Error::custom),
Some("TimerAction") => serde_json::from_value(value)
.map(Self::TimerAction)
.map_err(serde::de::Error::custom),
Some("SendEmailAction") => serde_json::from_value(value)
.map(Self::SendEmailAction)
.map_err(serde::de::Error::custom),
Some("ExitAction") => serde_json::from_value(value)
.map(Self::ExitAction)
.map_err(serde::de::Error::custom),
Some("BranchNode") => serde_json::from_value(value)
.map(Self::Branch)
.map_err(serde::de::Error::custom),
Some("ExperimentBranchNode") => serde_json::from_value(value)
.map(Self::ExperimentBranch)
.map_err(serde::de::Error::custom),
Some("VariantNode") => serde_json::from_value(value)
.map(Self::Variant)
.map_err(serde::de::Error::custom),
None => Err(serde::de::Error::missing_field(Self::DISCRIMINATOR_FIELD)),
Some(other) => Err(serde::de::Error::custom(format!(
"Unknown discriminator value '{}' for field '{}'",
other, "typeName"
))),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
pub struct WorkflowMutationNodeRevision {
/// The current workflow revision token. Pass the latest value as `expectedRevisionId` on the next workflow mutation.
#[serde(rename = "workflowRevisionId")]
pub workflow_revision_id: serde_json::Value,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct SignupTriggerWorkflowMutationNode {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("SignupTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct EventTriggerWorkflowMutationNode {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("EventTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The name of the event pattern that triggers this node.
#[serde(rename = "eventName")]
pub event_name: Option<String>,
/// The properties of the event pattern, which can be used in emails.
#[serde(rename = "eventProperties")]
pub event_properties: Option<Vec<WorkflowEventProperty>>,
/// If `true`, the contacts will be able to enter this workflow every time the trigger is matched. If `false`, contacts will only ever enter this workflow once. Matches the "Trigger frequency" option in the UI.
#[serde(rename = "reEligible")]
pub re_eligible: bool,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct ContactPropertyTriggerWorkflowMutationNode {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("ContactPropertyTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
#[serde(rename = "contactPropertyQuery")]
pub contact_property_query: Option<WorkflowContactPropertyQuery>,
/// If `true`, the contacts will be able to enter this workflow every time the trigger is matched. If `false`, contacts will only ever enter this workflow once. Matches the "Trigger frequency" option in the UI.
#[serde(rename = "reEligible")]
pub re_eligible: bool,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct AddToListTriggerWorkflowMutationNode {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("AddToListTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The ID of the mailing list this trigger sends to, if set.
#[serde(rename = "mailingListId")]
pub mailing_list_id: Option<String>,
/// If `true`, the contacts will be able to enter this workflow every time the trigger is matched. If `false`, contacts will only ever enter this workflow once. Matches the "Trigger frequency" option in the UI.
#[serde(rename = "reEligible")]
pub re_eligible: bool,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct BlankTriggerWorkflowMutationNode {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("BlankTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct AudienceFilterWorkflowMutationNode {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("AudienceFilter"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
#[serde(rename = "audienceFilter")]
pub audience_filter: Option<AudienceFilter>,
/// The ID of the audience segment this trigger targets.
#[serde(rename = "audienceSegmentId")]
pub audience_segment_id: Option<String>,
/// If `true`, the audience filter will apply to all downstream nodes. If `false`, the audience filter will only apply to the current node. Matches the "Filter scope" option in the UI.
#[serde(rename = "appliesDownstream")]
pub applies_downstream: bool,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct TimerActionWorkflowMutationNode {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("TimerAction"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The amount of time to wait before triggering the next node. Set to `0` to move to the next node immediately.
pub amount: f64,
/// The unit of time for the timer action node. m = minutes, h = hours, d = days.
pub unit: WorkflowTimerUnit,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct SendEmailActionWorkflowMutationNode {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("SendEmailAction"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The ID of the email message to send. To edit this email, use the `POST /v1/email-messages/{emailMessageId}` endpoint.
#[serde(rename = "emailMessageId")]
pub email_message_id: String,
pub subject: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct ExitActionWorkflowMutationNode {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("ExitAction"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct BranchWorkflowMutationNode {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("BranchNode"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct ExperimentBranchWorkflowMutationNode {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("ExperimentBranchNode"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The percentage of contacts that will be sent to variant branches, between `0` and `100`. The remaining percentage will be sent to the control branch. `100` sends all contacts to variant branches.
#[serde(rename = "samplingRate")]
pub sampling_rate: f64,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct VariantWorkflowMutationNode {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("VariantNode"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// Whether this is the control variant of an experiment.
#[serde(rename = "isControl")]
pub is_control: Option<bool>,
}
/// Node-type-specific fields to update. The allowed fields depend on the existing node type. Trigger node updates may include `typeName` when changing one trigger node type to another trigger node type.
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
#[serde(untagged)]
pub enum UpdateWorkflowNodePayload {
/// Changes an existing trigger node to a signup trigger.
#[default]
SignupTrigger(WorkflowSignupTriggerPayload),
/// Updates an event trigger, or changes an existing trigger node to an event trigger. Assign the event pattern with either `eventPatternId` or `eventName`, not both. Set either field to `null` to clear the event-pattern relationship.
EventTrigger(WorkflowEventTriggerPayload),
/// Updates a contact-property trigger, or changes an existing trigger node to a contact-property trigger.
ContactPropertyTrigger(WorkflowContactPropertyTriggerPayload),
/// Updates an add-to-list trigger, or changes an existing trigger node to an add-to-list trigger.
AddToListTrigger(WorkflowAddToListTriggerPayload),
/// Configuration for the audience filter node.
AudienceFilter(WorkflowAudienceFilterPayload),
/// Configuration for the timer action node.
TimerAction(WorkflowTimerActionPayload),
/// Configuration for the experiment branch node.
ExperimentBranch(WorkflowExperimentBranchPayload),
/// Configuration for the variant node.
Variant(WorkflowVariantPayload),
}
/// Changes an existing trigger node to a signup trigger.
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct WorkflowSignupTriggerPayload {
#[serde(rename = "typeName")]
#[default("SignupTrigger".to_string())]
pub type_name: String,
}
/// Updates an event trigger, or changes an existing trigger node to an event trigger. Assign the event pattern with either `eventPatternId` or `eventName`, not both. Set either field to `null` to clear the event-pattern relationship.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct WorkflowEventTriggerPayload {
#[serde(rename = "typeName")]
#[default(Some("EventTrigger".to_string()))]
pub type_name: Option<String>,
/// The ID of the event pattern to trigger on. Use either `eventPatternId` or `eventName`, not both. Set to `null` to clear the event-pattern relationship.
#[serde(rename = "eventPatternId")]
pub event_pattern_id: Option<String>,
/// The name of the event pattern to trigger on. Use this when you know the event name but not the internal event pattern ID. Use either `eventName` or `eventPatternId`, not both. Set to `null` to clear the event-pattern relationship.
#[serde(rename = "eventName")]
pub event_name: Option<String>,
/// If `true`, the contacts will be able to enter this workflow every time the trigger is matched. If `false`, contacts will only ever enter this workflow once. Matches the "Trigger frequency" option in the UI.
#[serde(rename = "reEligible")]
pub re_eligible: Option<bool>,
}
/// Updates a contact-property trigger, or changes an existing trigger node to a contact-property trigger.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct WorkflowContactPropertyTriggerPayload {
#[serde(rename = "typeName")]
#[default(Some("ContactPropertyTrigger".to_string()))]
pub type_name: Option<String>,
/// Define the contact property change that triggers the workflow. In update requests, `key` must resolve to an existing contact property that is available for Contact Updated triggers. Hidden or unsupported fields, such as `createdAt`, `notes`, and computed contact properties, are rejected.
#[serde(rename = "contactPropertyQuery")]
#[validate(nested)]
pub contact_property_query: Option<WorkflowContactPropertyQuery>,
/// If `true`, the contacts will be able to enter this workflow every time the trigger is matched. If `false`, contacts will only ever enter this workflow once. Matches the "Trigger frequency" option in the UI.
#[serde(rename = "reEligible")]
pub re_eligible: Option<bool>,
}
/// Updates an add-to-list trigger, or changes an existing trigger node to an add-to-list trigger.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct WorkflowAddToListTriggerPayload {
#[serde(rename = "typeName")]
#[default(Some("AddToListTrigger".to_string()))]
pub type_name: Option<String>,
/// If `true`, the contacts will be able to enter this workflow every time the trigger is matched. If `false`, contacts will only ever enter this workflow once. Matches the "Trigger frequency" option in the UI.
#[serde(rename = "reEligible")]
pub re_eligible: Option<bool>,
}
/// Configuration for the audience filter node.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct WorkflowAudienceFilterPayload {
/// The ID of an audience segment. Setting this without also providing `audienceFilter` clears any existing `audienceFilter`. If both are provided, the filter is applied on top of the segment's filter.
#[serde(rename = "audienceSegmentId")]
pub audience_segment_id: Option<String>,
#[serde(rename = "audienceFilter")]
#[validate(nested)]
pub audience_filter: Option<AudienceFilterInRequest>,
/// If `true`, the audience filter will apply to all downstream nodes. If `false`, the audience filter will only apply to the current node. Matches the "Filter scope" option in the UI.
#[serde(rename = "appliesDownstream")]
pub applies_downstream: Option<bool>,
}
/// Configuration for the timer action node.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct WorkflowTimerActionPayload {
/// The amount of time to wait before triggering the next node. Set to `0` to move to the next node immediately.
pub amount: Option<f64>,
/// The unit of time for the timer action node. m = minutes, h = hours, d = days.
pub unit: Option<WorkflowTimerUnit>,
}
/// Configuration for the experiment branch node.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct WorkflowExperimentBranchPayload {
/// The percentage of contacts that will be sent to variant branches, between `0` and `100`. The remaining percentage will be sent to the control branch. `100` sends all contacts to variant branches.
#[serde(rename = "samplingRate")]
pub sampling_rate: Option<f64>,
}
/// Configuration for the variant node.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct WorkflowVariantPayload {
/// Use `true` to set this variant as the control of the experiment. This will set `false` on the existing control, if one exists. Experiments do not require a control variant.
#[serde(rename = "isControl")]
pub is_control: Option<bool>,
}
/// Node types that can be created with the API. `*Trigger` nodes and `ExitAction` nodes cannot be created.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, oas3_gen_support::Default)]
pub enum CreateWorkflowNodeTypeName {
#[default]
AudienceFilter,
BranchNode,
ExperimentBranchNode,
TimerAction,
SendEmailAction,
VariantNode,
}
impl core::fmt::Display for CreateWorkflowNodeTypeName {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::AudienceFilter => write!(f, "AudienceFilter"),
Self::BranchNode => write!(f, "BranchNode"),
Self::ExperimentBranchNode => write!(f, "ExperimentBranchNode"),
Self::TimerAction => write!(f, "TimerAction"),
Self::SendEmailAction => write!(f, "SendEmailAction"),
Self::VariantNode => write!(f, "VariantNode"),
}
}
}
/// Insert a new node between two existing nodes, `fromNodeId` and `toNodeId`. When `fromNodeId` is an `ExperimentBranchNode`, `nodeTypeName` must be `VariantNode`, and `toNodeId` cannot already be a `VariantNode`; use add-branch to add sibling variants. Branch paths can be edited with create-node, but a workflow cannot be started unless each direct `BranchNode` child is an `AudienceFilter`.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct CreateWorkflowNodeBetweenRequest {
#[serde(rename = "expectedRevisionId")]
pub expected_revision_id: Option<WorkflowExpectedRevisionId>,
#[doc(hidden)]
#[serde(default, rename = "insertMode", skip_deserializing)]
#[default(Some("between"))]
pub insert_mode: Option<&'static str>,
/// Node types that can be created with the API. `*Trigger` nodes and `ExitAction` nodes cannot be created.
#[serde(rename = "nodeTypeName")]
pub node_type_name: CreateWorkflowNodeTypeName,
/// The node to insert after. This node must currently point to `toNodeId`. If this is an `ExperimentBranchNode`, `nodeTypeName` must be `VariantNode` and `toNodeId` cannot already be a `VariantNode`.
#[serde(rename = "fromNodeId")]
#[validate(length(min = 1u64))]
pub from_node_id: String,
/// The node to insert before.
#[serde(rename = "toNodeId")]
#[validate(length(min = 1u64))]
pub to_node_id: String,
}
/// Insert a new node before `toNodeId`. `VariantNode` cannot use `insertMode: "before"`; to restore a missing variant path, use `insertMode: "between"` with the experiment branch as `fromNodeId`.
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
#[serde(untagged)]
pub enum CreateWorkflowNodeBeforeRequest {
#[default]
TargetNode(CreateWorkflowNodeBeforeRequestTargetNode),
Deprecated(CreateWorkflowNodeBeforeRequestTargetNodeDeprecated),
}
/// Insert a new node after `fromNodeId`. This is valid only when `fromNodeId` has exactly one outgoing node. It is invalid when `fromNodeId` has no outgoing nodes, multiple outgoing nodes, or is an exit node. When the source has multiple outgoing nodes, use `between` with the exact `toNodeId` instead.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct CreateWorkflowNodeAfterRequest {
#[serde(rename = "expectedRevisionId")]
pub expected_revision_id: Option<WorkflowExpectedRevisionId>,
#[doc(hidden)]
#[serde(default, rename = "insertMode", skip_deserializing)]
#[default(Some("after"))]
pub insert_mode: Option<&'static str>,
/// Node types that can be created with the API. `*Trigger` nodes and `ExitAction` nodes cannot be created.
#[serde(rename = "nodeTypeName")]
pub node_type_name: CreateWorkflowNodeTypeName,
/// The node to insert after. This node must currently have exactly one outgoing node.
#[serde(rename = "fromNodeId")]
#[validate(length(min = 1u64))]
pub from_node_id: String,
}
/// Create a new workflow node with an explicit `insertMode`. To configure the node after creation, use the `POST /v1/workflows/{workflowId}/nodes/{nodeId}` endpoint.
#[derive(Debug, Clone, PartialEq)]
pub enum CreateWorkflowNodeRequest {
Between(CreateWorkflowNodeBetweenRequest),
Before(CreateWorkflowNodeBeforeRequest),
After(CreateWorkflowNodeAfterRequest),
}
impl CreateWorkflowNodeRequest {
pub const DISCRIMINATOR_FIELD: &'static str = "insertMode";
}
impl Default for CreateWorkflowNodeRequest {
fn default() -> Self {
Self::Between(<CreateWorkflowNodeBetweenRequest>::default())
}
}
impl serde::Serialize for CreateWorkflowNodeRequest {
fn serialize<S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::Between(v) => v.serialize(serializer),
Self::Before(v) => v.serialize(serializer),
Self::After(v) => v.serialize(serializer),
}
}
}
/// Detailed workflow node returned from a mutation, plus the latest workflow revision token.
#[derive(Debug, Clone, PartialEq)]
pub enum WorkflowMutationNodeWithRevision {
SignupTrigger(SignupTriggerWorkflowMutationNodeWithRevision),
EventTrigger(EventTriggerWorkflowMutationNodeWithRevision),
ContactPropertyTrigger(ContactPropertyTriggerWorkflowMutationNodeWithRevision),
AddToListTrigger(AddToListTriggerWorkflowMutationNodeWithRevision),
BlankTrigger(BlankTriggerWorkflowMutationNodeWithRevision),
AudienceFilter(AudienceFilterWorkflowMutationNodeWithRevision),
TimerAction(TimerActionWorkflowMutationNodeWithRevision),
SendEmailAction(SendEmailActionWorkflowMutationNodeWithRevision),
ExitAction(ExitActionWorkflowMutationNodeWithRevision),
Branch(BranchWorkflowMutationNodeWithRevision),
ExperimentBranch(ExperimentBranchWorkflowMutationNodeWithRevision),
Variant(VariantWorkflowMutationNodeWithRevision),
}
impl WorkflowMutationNodeWithRevision {
pub const DISCRIMINATOR_FIELD: &'static str = "typeName";
}
impl Default for WorkflowMutationNodeWithRevision {
fn default() -> Self {
Self::SignupTrigger(<SignupTriggerWorkflowMutationNodeWithRevision>::default())
}
}
impl<'de> serde::Deserialize<'de> for WorkflowMutationNodeWithRevision {
fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let value = serde_json::Value::deserialize(deserializer)?;
match value
.get(Self::DISCRIMINATOR_FIELD)
.and_then(|v| v.as_str())
{
Some("SignupTrigger") => serde_json::from_value(value)
.map(Self::SignupTrigger)
.map_err(serde::de::Error::custom),
Some("EventTrigger") => serde_json::from_value(value)
.map(Self::EventTrigger)
.map_err(serde::de::Error::custom),
Some("ContactPropertyTrigger") => serde_json::from_value(value)
.map(Self::ContactPropertyTrigger)
.map_err(serde::de::Error::custom),
Some("AddToListTrigger") => serde_json::from_value(value)
.map(Self::AddToListTrigger)
.map_err(serde::de::Error::custom),
Some("BlankTrigger") => serde_json::from_value(value)
.map(Self::BlankTrigger)
.map_err(serde::de::Error::custom),
Some("AudienceFilter") => serde_json::from_value(value)
.map(Self::AudienceFilter)
.map_err(serde::de::Error::custom),
Some("TimerAction") => serde_json::from_value(value)
.map(Self::TimerAction)
.map_err(serde::de::Error::custom),
Some("SendEmailAction") => serde_json::from_value(value)
.map(Self::SendEmailAction)
.map_err(serde::de::Error::custom),
Some("ExitAction") => serde_json::from_value(value)
.map(Self::ExitAction)
.map_err(serde::de::Error::custom),
Some("BranchNode") => serde_json::from_value(value)
.map(Self::Branch)
.map_err(serde::de::Error::custom),
Some("ExperimentBranchNode") => serde_json::from_value(value)
.map(Self::ExperimentBranch)
.map_err(serde::de::Error::custom),
Some("VariantNode") => serde_json::from_value(value)
.map(Self::Variant)
.map_err(serde::de::Error::custom),
None => Err(serde::de::Error::missing_field(Self::DISCRIMINATOR_FIELD)),
Some(other) => Err(serde::de::Error::custom(format!(
"Unknown discriminator value '{}' for field '{}'",
other, "typeName"
))),
}
}
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct SignupTriggerWorkflowMutationNodeWithRevision {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("SignupTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The current workflow revision token. Pass the latest value as `expectedRevisionId` on the next workflow mutation.
#[serde(rename = "workflowRevisionId")]
pub workflow_revision_id: serde_json::Value,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct EventTriggerWorkflowMutationNodeWithRevision {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("EventTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The name of the event pattern that triggers this node.
#[serde(rename = "eventName")]
pub event_name: Option<String>,
/// The properties of the event pattern, which can be used in emails.
#[serde(rename = "eventProperties")]
pub event_properties: Option<Vec<WorkflowEventProperty>>,
/// If `true`, the contacts will be able to enter this workflow every time the trigger is matched. If `false`, contacts will only ever enter this workflow once. Matches the "Trigger frequency" option in the UI.
#[serde(rename = "reEligible")]
pub re_eligible: bool,
/// The current workflow revision token. Pass the latest value as `expectedRevisionId` on the next workflow mutation.
#[serde(rename = "workflowRevisionId")]
pub workflow_revision_id: serde_json::Value,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct ContactPropertyTriggerWorkflowMutationNodeWithRevision {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("ContactPropertyTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
#[serde(rename = "contactPropertyQuery")]
pub contact_property_query: Option<WorkflowContactPropertyQuery>,
/// If `true`, the contacts will be able to enter this workflow every time the trigger is matched. If `false`, contacts will only ever enter this workflow once. Matches the "Trigger frequency" option in the UI.
#[serde(rename = "reEligible")]
pub re_eligible: bool,
/// The current workflow revision token. Pass the latest value as `expectedRevisionId` on the next workflow mutation.
#[serde(rename = "workflowRevisionId")]
pub workflow_revision_id: serde_json::Value,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct AddToListTriggerWorkflowMutationNodeWithRevision {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("AddToListTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The ID of the mailing list this trigger sends to, if set.
#[serde(rename = "mailingListId")]
pub mailing_list_id: Option<String>,
/// If `true`, the contacts will be able to enter this workflow every time the trigger is matched. If `false`, contacts will only ever enter this workflow once. Matches the "Trigger frequency" option in the UI.
#[serde(rename = "reEligible")]
pub re_eligible: bool,
/// The current workflow revision token. Pass the latest value as `expectedRevisionId` on the next workflow mutation.
#[serde(rename = "workflowRevisionId")]
pub workflow_revision_id: serde_json::Value,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct BlankTriggerWorkflowMutationNodeWithRevision {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("BlankTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The current workflow revision token. Pass the latest value as `expectedRevisionId` on the next workflow mutation.
#[serde(rename = "workflowRevisionId")]
pub workflow_revision_id: serde_json::Value,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct AudienceFilterWorkflowMutationNodeWithRevision {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("AudienceFilter"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
#[serde(rename = "audienceFilter")]
pub audience_filter: Option<AudienceFilter>,
/// The ID of the audience segment this trigger targets.
#[serde(rename = "audienceSegmentId")]
pub audience_segment_id: Option<String>,
/// If `true`, the audience filter will apply to all downstream nodes. If `false`, the audience filter will only apply to the current node. Matches the "Filter scope" option in the UI.
#[serde(rename = "appliesDownstream")]
pub applies_downstream: bool,
/// The current workflow revision token. Pass the latest value as `expectedRevisionId` on the next workflow mutation.
#[serde(rename = "workflowRevisionId")]
pub workflow_revision_id: serde_json::Value,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct TimerActionWorkflowMutationNodeWithRevision {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("TimerAction"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The amount of time to wait before triggering the next node. Set to `0` to move to the next node immediately.
pub amount: f64,
/// The unit of time for the timer action node. m = minutes, h = hours, d = days.
pub unit: WorkflowTimerUnit,
/// The current workflow revision token. Pass the latest value as `expectedRevisionId` on the next workflow mutation.
#[serde(rename = "workflowRevisionId")]
pub workflow_revision_id: serde_json::Value,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct SendEmailActionWorkflowMutationNodeWithRevision {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("SendEmailAction"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The ID of the email message to send. To edit this email, use the `POST /v1/email-messages/{emailMessageId}` endpoint.
#[serde(rename = "emailMessageId")]
pub email_message_id: String,
pub subject: String,
/// The current workflow revision token. Pass the latest value as `expectedRevisionId` on the next workflow mutation.
#[serde(rename = "workflowRevisionId")]
pub workflow_revision_id: serde_json::Value,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct ExitActionWorkflowMutationNodeWithRevision {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("ExitAction"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The current workflow revision token. Pass the latest value as `expectedRevisionId` on the next workflow mutation.
#[serde(rename = "workflowRevisionId")]
pub workflow_revision_id: serde_json::Value,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct BranchWorkflowMutationNodeWithRevision {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("BranchNode"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The current workflow revision token. Pass the latest value as `expectedRevisionId` on the next workflow mutation.
#[serde(rename = "workflowRevisionId")]
pub workflow_revision_id: serde_json::Value,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct ExperimentBranchWorkflowMutationNodeWithRevision {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("ExperimentBranchNode"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The percentage of contacts that will be sent to variant branches, between `0` and `100`. The remaining percentage will be sent to the control branch. `100` sends all contacts to variant branches.
#[serde(rename = "samplingRate")]
pub sampling_rate: f64,
/// The current workflow revision token. Pass the latest value as `expectedRevisionId` on the next workflow mutation.
#[serde(rename = "workflowRevisionId")]
pub workflow_revision_id: serde_json::Value,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct VariantWorkflowMutationNodeWithRevision {
pub id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("VariantNode"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// Whether this is the control variant of an experiment.
#[serde(rename = "isControl")]
pub is_control: Option<bool>,
/// The current workflow revision token. Pass the latest value as `expectedRevisionId` on the next workflow mutation.
#[serde(rename = "workflowRevisionId")]
pub workflow_revision_id: serde_json::Value,
}
#[derive(Debug, Clone, PartialEq)]
pub enum CreatedWorkflowNode {
SignupTriggerWorkflowMutationNodeWithRevision(
Box<SignupTriggerWorkflowMutationNodeWithRevision>,
),
EventTriggerWorkflowMutationNodeWithRevision(Box<EventTriggerWorkflowMutationNodeWithRevision>),
ContactPropertyTriggerWorkflowMutationNodeWithRevision(
Box<ContactPropertyTriggerWorkflowMutationNodeWithRevision>,
),
AddToListTriggerWorkflowMutationNodeWithRevision(
Box<AddToListTriggerWorkflowMutationNodeWithRevision>,
),
BlankTriggerWorkflowMutationNodeWithRevision(Box<BlankTriggerWorkflowMutationNodeWithRevision>),
AudienceFilterWorkflowMutationNodeWithRevision(
Box<AudienceFilterWorkflowMutationNodeWithRevision>,
),
TimerActionWorkflowMutationNodeWithRevision(Box<TimerActionWorkflowMutationNodeWithRevision>),
SendEmailActionWorkflowMutationNodeWithRevision(
Box<SendEmailActionWorkflowMutationNodeWithRevision>,
),
ExitActionWorkflowMutationNodeWithRevision(Box<ExitActionWorkflowMutationNodeWithRevision>),
BranchWorkflowMutationNodeWithRevision(Box<BranchWorkflowMutationNodeWithRevision>),
ExperimentBranchWorkflowMutationNodeWithRevision(
Box<ExperimentBranchWorkflowMutationNodeWithRevision>,
),
VariantWorkflowMutationNodeWithRevision(Box<VariantWorkflowMutationNodeWithRevision>),
Node(Box<CreatedWorkflowNodeBase>),
}
impl CreatedWorkflowNode {
pub const DISCRIMINATOR_FIELD: &'static str = "typeName";
}
impl Default for CreatedWorkflowNode {
fn default() -> Self {
Self::Node(<Box<CreatedWorkflowNodeBase>>::default())
}
}
impl<'de> serde::Deserialize<'de> for CreatedWorkflowNode {
fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let value = serde_json::Value::deserialize(deserializer)?;
match value
.get(Self::DISCRIMINATOR_FIELD)
.and_then(|v| v.as_str())
{
Some("SignupTrigger") => serde_json::from_value(value)
.map(Self::SignupTriggerWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("EventTrigger") => serde_json::from_value(value)
.map(Self::EventTriggerWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("ContactPropertyTrigger") => serde_json::from_value(value)
.map(Self::ContactPropertyTriggerWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("AddToListTrigger") => serde_json::from_value(value)
.map(Self::AddToListTriggerWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("BlankTrigger") => serde_json::from_value(value)
.map(Self::BlankTriggerWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("AudienceFilter") => serde_json::from_value(value)
.map(Self::AudienceFilterWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("TimerAction") => serde_json::from_value(value)
.map(Self::TimerActionWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("SendEmailAction") => serde_json::from_value(value)
.map(Self::SendEmailActionWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("ExitAction") => serde_json::from_value(value)
.map(Self::ExitActionWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("BranchNode") => serde_json::from_value(value)
.map(Self::BranchWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("ExperimentBranchNode") => serde_json::from_value(value)
.map(Self::ExperimentBranchWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("VariantNode") => serde_json::from_value(value)
.map(Self::VariantWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
None => serde_json::from_value(value)
.map(Self::Node)
.map_err(serde::de::Error::custom),
Some(other) => Err(serde::de::Error::custom(format!(
"Unknown discriminator value '{}' for field '{}'",
other, "typeName"
))),
}
}
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct CreatedWorkflowNodeBase {
/// Default child nodes created along with the requested node. BranchNode creation returns two AudienceFilter children. ExperimentBranchNode creation returns two regular VariantNode children and one control VariantNode.
#[serde(rename = "createdChildNodes")]
pub created_child_nodes: Option<Vec<WorkflowMutationNode>>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct CreateWorkflowNodeResponse {
pub node: CreatedWorkflowNode,
pub workflow: SimplifiedWorkflow,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct AddWorkflowBranchRequest {
#[serde(rename = "expectedRevisionId")]
pub expected_revision_id: Option<WorkflowExpectedRevisionId>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct AddWorkflowBranchResponse {
/// Detailed workflow node returned from a mutation, plus the latest workflow revision token.
pub node: Box<WorkflowMutationNodeWithRevision>,
pub workflow: SimplifiedWorkflow,
}
/// Reroute the source node's only outgoing connection to `newTargetNodeId`.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct RerouteNodeConnectionRequest {
#[serde(rename = "expectedRevisionId")]
pub expected_revision_id: Option<WorkflowExpectedRevisionId>,
/// The valid workflow node that should receive the connection from the source node.
#[serde(rename = "newTargetNodeId")]
#[validate(length(min = 1u64))]
pub new_target_node_id: String,
}
/// The updated source node, plus the latest workflow.
#[derive(Debug, Clone, PartialEq)]
pub enum RerouteNodeConnectionResponse {
SignupTriggerWorkflowMutationNodeWithRevision(
Box<SignupTriggerWorkflowMutationNodeWithRevision>,
),
EventTriggerWorkflowMutationNodeWithRevision(Box<EventTriggerWorkflowMutationNodeWithRevision>),
ContactPropertyTriggerWorkflowMutationNodeWithRevision(
Box<ContactPropertyTriggerWorkflowMutationNodeWithRevision>,
),
AddToListTriggerWorkflowMutationNodeWithRevision(
Box<AddToListTriggerWorkflowMutationNodeWithRevision>,
),
BlankTriggerWorkflowMutationNodeWithRevision(Box<BlankTriggerWorkflowMutationNodeWithRevision>),
AudienceFilterWorkflowMutationNodeWithRevision(
Box<AudienceFilterWorkflowMutationNodeWithRevision>,
),
TimerActionWorkflowMutationNodeWithRevision(Box<TimerActionWorkflowMutationNodeWithRevision>),
SendEmailActionWorkflowMutationNodeWithRevision(
Box<SendEmailActionWorkflowMutationNodeWithRevision>,
),
ExitActionWorkflowMutationNodeWithRevision(Box<ExitActionWorkflowMutationNodeWithRevision>),
BranchWorkflowMutationNodeWithRevision(Box<BranchWorkflowMutationNodeWithRevision>),
ExperimentBranchWorkflowMutationNodeWithRevision(
Box<ExperimentBranchWorkflowMutationNodeWithRevision>,
),
VariantWorkflowMutationNodeWithRevision(Box<VariantWorkflowMutationNodeWithRevision>),
Response(Box<RerouteNodeConnectionResponseBase>),
}
impl RerouteNodeConnectionResponse {
pub const DISCRIMINATOR_FIELD: &'static str = "typeName";
}
impl Default for RerouteNodeConnectionResponse {
fn default() -> Self {
Self::Response(<Box<RerouteNodeConnectionResponseBase>>::default())
}
}
impl<'de> serde::Deserialize<'de> for RerouteNodeConnectionResponse {
fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let value = serde_json::Value::deserialize(deserializer)?;
match value
.get(Self::DISCRIMINATOR_FIELD)
.and_then(|v| v.as_str())
{
Some("SignupTrigger") => serde_json::from_value(value)
.map(Self::SignupTriggerWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("EventTrigger") => serde_json::from_value(value)
.map(Self::EventTriggerWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("ContactPropertyTrigger") => serde_json::from_value(value)
.map(Self::ContactPropertyTriggerWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("AddToListTrigger") => serde_json::from_value(value)
.map(Self::AddToListTriggerWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("BlankTrigger") => serde_json::from_value(value)
.map(Self::BlankTriggerWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("AudienceFilter") => serde_json::from_value(value)
.map(Self::AudienceFilterWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("TimerAction") => serde_json::from_value(value)
.map(Self::TimerActionWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("SendEmailAction") => serde_json::from_value(value)
.map(Self::SendEmailActionWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("ExitAction") => serde_json::from_value(value)
.map(Self::ExitActionWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("BranchNode") => serde_json::from_value(value)
.map(Self::BranchWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("ExperimentBranchNode") => serde_json::from_value(value)
.map(Self::ExperimentBranchWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("VariantNode") => serde_json::from_value(value)
.map(Self::VariantWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
None => serde_json::from_value(value)
.map(Self::Response)
.map_err(serde::de::Error::custom),
Some(other) => Err(serde::de::Error::custom(format!(
"Unknown discriminator value '{}' for field '{}'",
other, "typeName"
))),
}
}
}
/// The updated source node, plus the latest workflow.
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct RerouteNodeConnectionResponseBase {
pub workflow: SimplifiedWorkflow,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct UpdateWorkflowNodeRequest {
#[serde(rename = "expectedRevisionId")]
pub expected_revision_id: Option<WorkflowExpectedRevisionId>,
/// Node-type-specific fields to update. The allowed fields depend on the existing node type. Trigger node updates may include `typeName` when changing one trigger node type to another trigger node type.
pub payload: Box<UpdateWorkflowNodePayload>,
}
/// The updated workflow node, plus the latest simplified workflow.
#[derive(Debug, Clone, PartialEq)]
pub enum UpdateWorkflowNodeResponse {
SignupTriggerWorkflowMutationNodeWithRevision(
Box<SignupTriggerWorkflowMutationNodeWithRevision>,
),
EventTriggerWorkflowMutationNodeWithRevision(Box<EventTriggerWorkflowMutationNodeWithRevision>),
ContactPropertyTriggerWorkflowMutationNodeWithRevision(
Box<ContactPropertyTriggerWorkflowMutationNodeWithRevision>,
),
AddToListTriggerWorkflowMutationNodeWithRevision(
Box<AddToListTriggerWorkflowMutationNodeWithRevision>,
),
BlankTriggerWorkflowMutationNodeWithRevision(Box<BlankTriggerWorkflowMutationNodeWithRevision>),
AudienceFilterWorkflowMutationNodeWithRevision(
Box<AudienceFilterWorkflowMutationNodeWithRevision>,
),
TimerActionWorkflowMutationNodeWithRevision(Box<TimerActionWorkflowMutationNodeWithRevision>),
SendEmailActionWorkflowMutationNodeWithRevision(
Box<SendEmailActionWorkflowMutationNodeWithRevision>,
),
ExitActionWorkflowMutationNodeWithRevision(Box<ExitActionWorkflowMutationNodeWithRevision>),
BranchWorkflowMutationNodeWithRevision(Box<BranchWorkflowMutationNodeWithRevision>),
ExperimentBranchWorkflowMutationNodeWithRevision(
Box<ExperimentBranchWorkflowMutationNodeWithRevision>,
),
VariantWorkflowMutationNodeWithRevision(Box<VariantWorkflowMutationNodeWithRevision>),
Response(Box<UpdateWorkflowNodeResponseBase>),
}
impl UpdateWorkflowNodeResponse {
pub const DISCRIMINATOR_FIELD: &'static str = "typeName";
}
impl Default for UpdateWorkflowNodeResponse {
fn default() -> Self {
Self::Response(<Box<UpdateWorkflowNodeResponseBase>>::default())
}
}
impl<'de> serde::Deserialize<'de> for UpdateWorkflowNodeResponse {
fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let value = serde_json::Value::deserialize(deserializer)?;
match value
.get(Self::DISCRIMINATOR_FIELD)
.and_then(|v| v.as_str())
{
Some("SignupTrigger") => serde_json::from_value(value)
.map(Self::SignupTriggerWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("EventTrigger") => serde_json::from_value(value)
.map(Self::EventTriggerWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("ContactPropertyTrigger") => serde_json::from_value(value)
.map(Self::ContactPropertyTriggerWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("AddToListTrigger") => serde_json::from_value(value)
.map(Self::AddToListTriggerWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("BlankTrigger") => serde_json::from_value(value)
.map(Self::BlankTriggerWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("AudienceFilter") => serde_json::from_value(value)
.map(Self::AudienceFilterWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("TimerAction") => serde_json::from_value(value)
.map(Self::TimerActionWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("SendEmailAction") => serde_json::from_value(value)
.map(Self::SendEmailActionWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("ExitAction") => serde_json::from_value(value)
.map(Self::ExitActionWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("BranchNode") => serde_json::from_value(value)
.map(Self::BranchWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("ExperimentBranchNode") => serde_json::from_value(value)
.map(Self::ExperimentBranchWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
Some("VariantNode") => serde_json::from_value(value)
.map(Self::VariantWorkflowMutationNodeWithRevision)
.map_err(serde::de::Error::custom),
None => serde_json::from_value(value)
.map(Self::Response)
.map_err(serde::de::Error::custom),
Some(other) => Err(serde::de::Error::custom(format!(
"Unknown discriminator value '{}' for field '{}'",
other, "typeName"
))),
}
}
}
/// The updated workflow node, plus the latest simplified workflow.
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct UpdateWorkflowNodeResponseBase {
pub workflow: SimplifiedWorkflow,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct DeleteWorkflowNodeRequest {
#[serde(rename = "expectedRevisionId")]
pub expected_revision_id: Option<WorkflowExpectedRevisionId>,
/// If `true`, the request will be validated but the workflow will not be modified.
#[serde(rename = "dryRun")]
pub dry_run: Option<bool>,
/// `fail` returns queued-contact impact instead of mutating. `discard` confirms that matching queued contacts should be discarded. Defaults to `fail` when omitted.
#[serde(rename = "queuedContactPolicy")]
#[default(Some(Default::default()))]
pub queued_contact_policy: Option<WorkflowQueuedContactPolicy>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct WorkflowQueuedContactDeletePreview {
pub status: PreviewStatus,
/// The IDs of the nodes that would be deleted.
#[serde(rename = "nodeIds")]
pub node_ids: Vec<String>,
/// The number of queued contacts that would be removed from the workflow due to the node deletion.
#[serde(rename = "queuedContactCount")]
pub queued_contact_count: f64,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct WorkflowDeletedResponse {
#[default("deleted".to_string())]
pub status: String,
#[serde(rename = "nodeIds")]
pub node_ids: Vec<String>,
/// The current workflow revision token. Pass the latest value as `expectedRevisionId` on the next workflow mutation.
#[serde(rename = "workflowRevisionId")]
pub workflow_revision_id: serde_json::Value,
/// The number of queued contacts that were removed from the workflow due to the node deletion.
#[serde(rename = "queuedContactCount")]
pub queued_contact_count: f64,
pub workflow: SimplifiedWorkflow,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(untagged)]
pub enum DeleteWorkflowNodeResponse {
#[default]
QueuedContactDeletePreview(WorkflowQueuedContactDeletePreview),
DeletedResponse(WorkflowDeletedResponse),
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct ChangeWorkflowMailingListRequest {
#[serde(rename = "expectedRevisionId")]
pub expected_revision_id: Option<WorkflowExpectedRevisionId>,
/// The mailing list to use for the workflow. When assigning a mailing list, queued contacts excluded by the new list can return `queuedContactsFound`; retry with `queuedContactPolicy: "discard"` to apply the change and discard those contacts. Use `null` to clear the workflow mailing list; clearing does not discard queued contacts.
#[serde(rename = "mailingListId")]
pub mailing_list_id: Option<String>,
/// If `true`, the request will be validated but the workflow will not be modified.
#[serde(rename = "dryRun")]
pub dry_run: Option<bool>,
/// `fail` returns queued-contact impact instead of mutating. `discard` confirms that matching queued contacts should be discarded. Defaults to `fail` when omitted.
#[serde(rename = "queuedContactPolicy")]
#[default(Some(Default::default()))]
pub queued_contact_policy: Option<WorkflowQueuedContactPolicy>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct WorkflowMailingListPreview {
pub status: PreviewStatus,
#[serde(rename = "mailingListId")]
pub mailing_list_id: Option<String>,
/// The number of queued contacts that would be removed from the workflow due to the mailing list changing.
#[serde(rename = "queuedContactCount")]
pub queued_contact_count: f64,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct WorkflowMailingListUpdatedResponse {
#[default("updated".to_string())]
pub status: String,
#[serde(rename = "mailingListId")]
pub mailing_list_id: Option<String>,
/// The current workflow revision token. Pass the latest value as `expectedRevisionId` on the next workflow mutation.
#[serde(rename = "workflowRevisionId")]
pub workflow_revision_id: serde_json::Value,
/// The number of queued contacts that were removed from the workflow due to the mailing list changing.
#[serde(rename = "queuedContactCount")]
pub queued_contact_count: f64,
pub workflow: SimplifiedWorkflow,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(untagged)]
pub enum ChangeWorkflowMailingListResponse {
#[default]
Preview(WorkflowMailingListPreview),
UpdatedResponse(WorkflowMailingListUpdatedResponse),
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct EventPatternSummary {
/// The ID of the event pattern.
pub id: String,
/// The name of the event pattern. Use this when sending events with the API.
#[serde(rename = "eventName")]
pub event_name: String,
/// The platform that sent this event pattern, if the event pattern is from an incoming webhook. Will be `null` for custom events.
#[serde(rename = "incomingWebhookPlatform")]
pub incoming_webhook_platform: Option<IncomingWebhookPlatform>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ListEventPatternsResponse {
pub pagination: ListEventPatternsResponsePagination,
pub data: Vec<EventPatternSummary>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct EventPattern {
pub id: String,
/// The name of the event pattern. Use this when sending events with the API.
#[serde(rename = "eventName")]
pub event_name: String,
/// The properties of the event pattern, which can be used in emails.
#[serde(rename = "eventProperties")]
pub event_properties: Vec<WorkflowEventProperty>,
/// The platform that sent this event pattern, if the event pattern is from an incoming webhook. Will be `null` for custom events.
#[serde(rename = "incomingWebhookPlatform")]
pub incoming_webhook_platform: Option<IncomingWebhookPlatform>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct EventPatternFailureResponse {
pub message: String,
}
#[derive(Debug, Clone, PartialEq)]
pub enum SimplifiedWorkflowNode {
SignupTrigger(SimplifiedSignupTriggerWorkflowNode),
EventTrigger(SimplifiedEventTriggerWorkflowNode),
ContactPropertyTrigger(SimplifiedContactPropertyTriggerWorkflowNode),
AddToListTrigger(SimplifiedAddToListTriggerWorkflowNode),
BlankTrigger(SimplifiedBlankTriggerWorkflowNode),
AudienceFilter(SimplifiedAudienceFilterWorkflowNode),
TimerAction(SimplifiedTimerActionWorkflowNode),
SendEmailAction(SimplifiedSendEmailActionWorkflowNode),
ExitAction(SimplifiedExitActionWorkflowNode),
Branch(SimplifiedBranchWorkflowNode),
ExperimentBranch(SimplifiedExperimentBranchWorkflowNode),
Variant(SimplifiedVariantWorkflowNode),
}
impl SimplifiedWorkflowNode {
pub const DISCRIMINATOR_FIELD: &'static str = "typeName";
}
impl Default for SimplifiedWorkflowNode {
fn default() -> Self {
Self::SignupTrigger(<SimplifiedSignupTriggerWorkflowNode>::default())
}
}
impl serde::Serialize for SimplifiedWorkflowNode {
fn serialize<S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::SignupTrigger(v) => v.serialize(serializer),
Self::EventTrigger(v) => v.serialize(serializer),
Self::ContactPropertyTrigger(v) => v.serialize(serializer),
Self::AddToListTrigger(v) => v.serialize(serializer),
Self::BlankTrigger(v) => v.serialize(serializer),
Self::AudienceFilter(v) => v.serialize(serializer),
Self::TimerAction(v) => v.serialize(serializer),
Self::SendEmailAction(v) => v.serialize(serializer),
Self::ExitAction(v) => v.serialize(serializer),
Self::Branch(v) => v.serialize(serializer),
Self::ExperimentBranch(v) => v.serialize(serializer),
Self::Variant(v) => v.serialize(serializer),
}
}
}
impl<'de> serde::Deserialize<'de> for SimplifiedWorkflowNode {
fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let value = serde_json::Value::deserialize(deserializer)?;
match value
.get(Self::DISCRIMINATOR_FIELD)
.and_then(|v| v.as_str())
{
Some("SignupTrigger") => serde_json::from_value(value)
.map(Self::SignupTrigger)
.map_err(serde::de::Error::custom),
Some("EventTrigger") => serde_json::from_value(value)
.map(Self::EventTrigger)
.map_err(serde::de::Error::custom),
Some("ContactPropertyTrigger") => serde_json::from_value(value)
.map(Self::ContactPropertyTrigger)
.map_err(serde::de::Error::custom),
Some("AddToListTrigger") => serde_json::from_value(value)
.map(Self::AddToListTrigger)
.map_err(serde::de::Error::custom),
Some("BlankTrigger") => serde_json::from_value(value)
.map(Self::BlankTrigger)
.map_err(serde::de::Error::custom),
Some("AudienceFilter") => serde_json::from_value(value)
.map(Self::AudienceFilter)
.map_err(serde::de::Error::custom),
Some("TimerAction") => serde_json::from_value(value)
.map(Self::TimerAction)
.map_err(serde::de::Error::custom),
Some("SendEmailAction") => serde_json::from_value(value)
.map(Self::SendEmailAction)
.map_err(serde::de::Error::custom),
Some("ExitAction") => serde_json::from_value(value)
.map(Self::ExitAction)
.map_err(serde::de::Error::custom),
Some("BranchNode") => serde_json::from_value(value)
.map(Self::Branch)
.map_err(serde::de::Error::custom),
Some("ExperimentBranchNode") => serde_json::from_value(value)
.map(Self::ExperimentBranch)
.map_err(serde::de::Error::custom),
Some("VariantNode") => serde_json::from_value(value)
.map(Self::Variant)
.map_err(serde::de::Error::custom),
None => Err(serde::de::Error::missing_field(Self::DISCRIMINATOR_FIELD)),
Some(other) => Err(serde::de::Error::custom(format!(
"Unknown discriminator value '{}' for field '{}'",
other, "typeName"
))),
}
}
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct SimplifiedSignupTriggerWorkflowNode {
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("SignupTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct SimplifiedEventTriggerWorkflowNode {
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("EventTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The name of the event that triggers the workflow.
#[serde(rename = "eventName")]
pub event_name: Option<String>,
/// If `true`, the contacts will be able to enter this workflow every time the trigger is matched. If `false`, contacts will only ever enter this workflow once. Matches the "Trigger frequency" option in the UI.
#[serde(rename = "reEligible")]
pub re_eligible: bool,
}
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct SimplifiedContactPropertyTriggerWorkflowNode {
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("ContactPropertyTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
#[serde(rename = "contactPropertyQuery")]
#[validate(nested)]
pub contact_property_query: Option<WorkflowContactPropertyQuery>,
/// If `true`, the contacts will be able to enter this workflow every time the trigger is matched. If `false`, contacts will only ever enter this workflow once. Matches the "Trigger frequency" option in the UI.
#[serde(rename = "reEligible")]
pub re_eligible: bool,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct SimplifiedAddToListTriggerWorkflowNode {
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("AddToListTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The ID of the mailing list that triggers the workflow.
#[serde(rename = "mailingListId")]
pub mailing_list_id: Option<String>,
/// If `true`, the contacts will be able to enter this workflow every time the trigger is matched. If `false`, contacts will only ever enter this workflow once. Matches the "Trigger frequency" option in the UI.
#[serde(rename = "reEligible")]
pub re_eligible: bool,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct SimplifiedBlankTriggerWorkflowNode {
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("BlankTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct SimplifiedAudienceFilterWorkflowNode {
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("AudienceFilter"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct SimplifiedTimerActionWorkflowNode {
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("TimerAction"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The amount of time to wait before triggering the next node. Set to `0` to move to the next node immediately.
pub amount: f64,
/// The unit of time for the timer action node. m = minutes, h = hours, d = days.
pub unit: WorkflowTimerUnit,
}
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct SimplifiedSendEmailActionWorkflowNode {
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("SendEmailAction"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The ID of the email message to send. To edit this email, use the `POST /v1/email-messages/{emailMessageId}` endpoint.
#[serde(rename = "emailMessageId")]
pub email_message_id: Option<String>,
/// The subject of the email message (reference only).
#[validate(length(min = 1u64))]
pub subject: String,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct SimplifiedExitActionWorkflowNode {
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("ExitAction"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct SimplifiedBranchWorkflowNode {
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("BranchNode"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct SimplifiedExperimentBranchWorkflowNode {
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("ExperimentBranchNode"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The percentage of contacts that will be sent to variant branches, between `0` and `100`. The remaining percentage will be sent to the control branch.
#[serde(rename = "samplingRate")]
pub sampling_rate: f64,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct SimplifiedVariantWorkflowNode {
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("VariantNode"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// Whether this is the control variant of an experiment.
#[serde(rename = "isControl")]
pub is_control: bool,
}
#[derive(Debug, Clone, PartialEq)]
pub enum WorkflowNode {
SignupTrigger(SignupTriggerWorkflowNode),
EventTrigger(EventTriggerWorkflowNode),
ContactPropertyTrigger(ContactPropertyTriggerWorkflowNode),
AddToListTrigger(AddToListTriggerWorkflowNode),
BlankTrigger(BlankTriggerWorkflowNode),
AudienceFilter(AudienceFilterWorkflowNode),
TimerAction(TimerActionWorkflowNode),
SendEmailAction(SendEmailActionWorkflowNode),
ExitAction(ExitActionWorkflowNode),
Branch(BranchWorkflowNode),
ExperimentBranch(ExperimentBranchWorkflowNode),
Variant(VariantWorkflowNode),
}
impl WorkflowNode {
pub const DISCRIMINATOR_FIELD: &'static str = "typeName";
}
impl Default for WorkflowNode {
fn default() -> Self {
Self::SignupTrigger(<SignupTriggerWorkflowNode>::default())
}
}
impl serde::Serialize for WorkflowNode {
fn serialize<S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
Self::SignupTrigger(v) => v.serialize(serializer),
Self::EventTrigger(v) => v.serialize(serializer),
Self::ContactPropertyTrigger(v) => v.serialize(serializer),
Self::AddToListTrigger(v) => v.serialize(serializer),
Self::BlankTrigger(v) => v.serialize(serializer),
Self::AudienceFilter(v) => v.serialize(serializer),
Self::TimerAction(v) => v.serialize(serializer),
Self::SendEmailAction(v) => v.serialize(serializer),
Self::ExitAction(v) => v.serialize(serializer),
Self::Branch(v) => v.serialize(serializer),
Self::ExperimentBranch(v) => v.serialize(serializer),
Self::Variant(v) => v.serialize(serializer),
}
}
}
impl<'de> serde::Deserialize<'de> for WorkflowNode {
fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let value = serde_json::Value::deserialize(deserializer)?;
match value
.get(Self::DISCRIMINATOR_FIELD)
.and_then(|v| v.as_str())
{
Some("SignupTrigger") => serde_json::from_value(value)
.map(Self::SignupTrigger)
.map_err(serde::de::Error::custom),
Some("EventTrigger") => serde_json::from_value(value)
.map(Self::EventTrigger)
.map_err(serde::de::Error::custom),
Some("ContactPropertyTrigger") => serde_json::from_value(value)
.map(Self::ContactPropertyTrigger)
.map_err(serde::de::Error::custom),
Some("AddToListTrigger") => serde_json::from_value(value)
.map(Self::AddToListTrigger)
.map_err(serde::de::Error::custom),
Some("BlankTrigger") => serde_json::from_value(value)
.map(Self::BlankTrigger)
.map_err(serde::de::Error::custom),
Some("AudienceFilter") => serde_json::from_value(value)
.map(Self::AudienceFilter)
.map_err(serde::de::Error::custom),
Some("TimerAction") => serde_json::from_value(value)
.map(Self::TimerAction)
.map_err(serde::de::Error::custom),
Some("SendEmailAction") => serde_json::from_value(value)
.map(Self::SendEmailAction)
.map_err(serde::de::Error::custom),
Some("ExitAction") => serde_json::from_value(value)
.map(Self::ExitAction)
.map_err(serde::de::Error::custom),
Some("BranchNode") => serde_json::from_value(value)
.map(Self::Branch)
.map_err(serde::de::Error::custom),
Some("ExperimentBranchNode") => serde_json::from_value(value)
.map(Self::ExperimentBranch)
.map_err(serde::de::Error::custom),
Some("VariantNode") => serde_json::from_value(value)
.map(Self::Variant)
.map_err(serde::de::Error::custom),
None => Err(serde::de::Error::missing_field(Self::DISCRIMINATOR_FIELD)),
Some(other) => Err(serde::de::Error::custom(format!(
"Unknown discriminator value '{}' for field '{}'",
other, "typeName"
))),
}
}
}
/// Detailed workflow node returned from read operations. The exact fields depend on `typeName`.
#[derive(Debug, Clone, PartialEq)]
pub enum WorkflowNodeWithRevision {
SignupTriggerWorkflowNode(Box<SignupTriggerWorkflowNode>),
EventTriggerWorkflowNode(Box<EventTriggerWorkflowNode>),
ContactPropertyTriggerWorkflowNode(Box<ContactPropertyTriggerWorkflowNode>),
AddToListTriggerWorkflowNode(Box<AddToListTriggerWorkflowNode>),
BlankTriggerWorkflowNode(Box<BlankTriggerWorkflowNode>),
AudienceFilterWorkflowNode(Box<AudienceFilterWorkflowNode>),
TimerActionWorkflowNode(Box<TimerActionWorkflowNode>),
SendEmailActionWorkflowNode(Box<SendEmailActionWorkflowNode>),
ExitActionWorkflowNode(Box<ExitActionWorkflowNode>),
BranchWorkflowNode(Box<BranchWorkflowNode>),
ExperimentBranchWorkflowNode(Box<ExperimentBranchWorkflowNode>),
VariantWorkflowNode(Box<VariantWorkflowNode>),
Revision(Box<WorkflowNodeWithRevisionBase>),
}
impl WorkflowNodeWithRevision {
pub const DISCRIMINATOR_FIELD: &'static str = "typeName";
}
impl Default for WorkflowNodeWithRevision {
fn default() -> Self {
Self::Revision(<Box<WorkflowNodeWithRevisionBase>>::default())
}
}
impl<'de> serde::Deserialize<'de> for WorkflowNodeWithRevision {
fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let value = serde_json::Value::deserialize(deserializer)?;
match value
.get(Self::DISCRIMINATOR_FIELD)
.and_then(|v| v.as_str())
{
Some("SignupTrigger") => serde_json::from_value(value)
.map(Self::SignupTriggerWorkflowNode)
.map_err(serde::de::Error::custom),
Some("EventTrigger") => serde_json::from_value(value)
.map(Self::EventTriggerWorkflowNode)
.map_err(serde::de::Error::custom),
Some("ContactPropertyTrigger") => serde_json::from_value(value)
.map(Self::ContactPropertyTriggerWorkflowNode)
.map_err(serde::de::Error::custom),
Some("AddToListTrigger") => serde_json::from_value(value)
.map(Self::AddToListTriggerWorkflowNode)
.map_err(serde::de::Error::custom),
Some("BlankTrigger") => serde_json::from_value(value)
.map(Self::BlankTriggerWorkflowNode)
.map_err(serde::de::Error::custom),
Some("AudienceFilter") => serde_json::from_value(value)
.map(Self::AudienceFilterWorkflowNode)
.map_err(serde::de::Error::custom),
Some("TimerAction") => serde_json::from_value(value)
.map(Self::TimerActionWorkflowNode)
.map_err(serde::de::Error::custom),
Some("SendEmailAction") => serde_json::from_value(value)
.map(Self::SendEmailActionWorkflowNode)
.map_err(serde::de::Error::custom),
Some("ExitAction") => serde_json::from_value(value)
.map(Self::ExitActionWorkflowNode)
.map_err(serde::de::Error::custom),
Some("BranchNode") => serde_json::from_value(value)
.map(Self::BranchWorkflowNode)
.map_err(serde::de::Error::custom),
Some("ExperimentBranchNode") => serde_json::from_value(value)
.map(Self::ExperimentBranchWorkflowNode)
.map_err(serde::de::Error::custom),
Some("VariantNode") => serde_json::from_value(value)
.map(Self::VariantWorkflowNode)
.map_err(serde::de::Error::custom),
None => serde_json::from_value(value)
.map(Self::Revision)
.map_err(serde::de::Error::custom),
Some(other) => Err(serde::de::Error::custom(format!(
"Unknown discriminator value '{}' for field '{}'",
other, "typeName"
))),
}
}
}
/// Detailed workflow node returned from read operations. The exact fields depend on `typeName`.
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct WorkflowNodeWithRevisionBase {
#[serde(rename = "workflowRevisionId")]
pub workflow_revision_id: Option<NullableWorkflowRevisionId>,
}
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct SignupTriggerWorkflowNode {
#[validate(length(min = 1u64))]
pub id: String,
#[serde(rename = "workflowId")]
#[validate(length(min = 1u64))]
pub workflow_id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("SignupTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
}
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct EventTriggerWorkflowNode {
#[validate(length(min = 1u64))]
pub id: String,
#[serde(rename = "workflowId")]
#[validate(length(min = 1u64))]
pub workflow_id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("EventTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The name of the event pattern that triggers this node.
#[serde(rename = "eventName")]
pub event_name: Option<String>,
/// The properties of the event pattern, which can be used in emails.
#[serde(rename = "eventProperties")]
#[validate(nested)]
pub event_properties: Option<Vec<WorkflowEventProperty>>,
/// If `true`, the contacts will be able to enter this workflow every time the trigger is matched. If `false`, contacts will only ever enter this workflow once. Matches the "Trigger frequency" option in the UI.
#[serde(rename = "reEligible")]
pub re_eligible: bool,
}
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct ContactPropertyTriggerWorkflowNode {
#[validate(length(min = 1u64))]
pub id: String,
#[serde(rename = "workflowId")]
#[validate(length(min = 1u64))]
pub workflow_id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("ContactPropertyTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
#[serde(rename = "contactPropertyQuery")]
#[validate(nested)]
pub contact_property_query: Option<WorkflowContactPropertyQuery>,
/// If `true`, the contacts will be able to enter this workflow every time the trigger is matched. If `false`, contacts will only ever enter this workflow once. Matches the "Trigger frequency" option in the UI.
#[serde(rename = "reEligible")]
pub re_eligible: bool,
}
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct AddToListTriggerWorkflowNode {
#[validate(length(min = 1u64))]
pub id: String,
#[serde(rename = "workflowId")]
#[validate(length(min = 1u64))]
pub workflow_id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("AddToListTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The ID of the mailing list that triggers the workflow.
#[serde(rename = "mailingListId")]
pub mailing_list_id: Option<String>,
/// If `true`, the contacts will be able to enter this workflow every time the trigger is matched. If `false`, contacts will only ever enter this workflow once. Matches the "Trigger frequency" option in the UI.
#[serde(rename = "reEligible")]
pub re_eligible: bool,
}
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct BlankTriggerWorkflowNode {
#[validate(length(min = 1u64))]
pub id: String,
#[serde(rename = "workflowId")]
#[validate(length(min = 1u64))]
pub workflow_id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("BlankTrigger"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
}
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct AudienceFilterWorkflowNode {
#[validate(length(min = 1u64))]
pub id: String,
#[serde(rename = "workflowId")]
#[validate(length(min = 1u64))]
pub workflow_id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("AudienceFilter"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
#[serde(rename = "audienceFilter")]
#[validate(nested)]
pub audience_filter: Option<AudienceFilter>,
#[serde(rename = "audienceSegmentId")]
pub audience_segment_id: Option<String>,
/// If `true`, the audience filter will apply to all downstream nodes. If `false`, the audience filter will only apply to the current node. Matches the "Filter scope" option in the UI.
#[serde(rename = "appliesDownstream")]
pub applies_downstream: bool,
}
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct TimerActionWorkflowNode {
#[validate(length(min = 1u64))]
pub id: String,
#[serde(rename = "workflowId")]
#[validate(length(min = 1u64))]
pub workflow_id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("TimerAction"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The amount of time to wait before triggering the next node. Set to `0` to move to the next node immediately.
pub amount: f64,
/// The unit of time for the timer action node. m = minutes, h = hours, d = days.
pub unit: WorkflowTimerUnit,
}
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct SendEmailActionWorkflowNode {
#[validate(length(min = 1u64))]
pub id: String,
#[serde(rename = "workflowId")]
#[validate(length(min = 1u64))]
pub workflow_id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("SendEmailAction"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The ID of the email message to send. To edit this email, use the `POST /v1/email-messages/{emailMessageId}` endpoint.
#[serde(rename = "emailMessageId")]
#[validate(length(min = 1u64))]
pub email_message_id: String,
#[validate(length(min = 1u64))]
pub subject: String,
}
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct ExitActionWorkflowNode {
#[validate(length(min = 1u64))]
pub id: String,
#[serde(rename = "workflowId")]
#[validate(length(min = 1u64))]
pub workflow_id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("ExitAction"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
}
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct BranchWorkflowNode {
#[validate(length(min = 1u64))]
pub id: String,
#[serde(rename = "workflowId")]
#[validate(length(min = 1u64))]
pub workflow_id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("BranchNode"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
}
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct ExperimentBranchWorkflowNode {
#[validate(length(min = 1u64))]
pub id: String,
#[serde(rename = "workflowId")]
#[validate(length(min = 1u64))]
pub workflow_id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("ExperimentBranchNode"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// The percentage of contacts that will be sent to variant branches, between `0` and `100`. The remaining percentage will be sent to the control branch. `100` sends all contacts to variant branches.
#[serde(rename = "samplingRate")]
pub sampling_rate: f64,
}
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct VariantWorkflowNode {
#[validate(length(min = 1u64))]
pub id: String,
#[serde(rename = "workflowId")]
#[validate(length(min = 1u64))]
pub workflow_id: String,
#[doc(hidden)]
#[serde(default, rename = "typeName", skip_deserializing)]
#[default(Some("VariantNode"))]
pub type_name: Option<&'static str>,
/// The IDs of the nodes that are downstream of this node.
#[serde(rename = "nextNodeIds")]
pub next_node_ids: Vec<String>,
/// Whether this is the control variant of an experiment.
#[serde(rename = "isControl")]
pub is_control: Option<bool>,
}
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
pub struct WorkflowEventProperty {
#[validate(length(min = 1u64))]
pub name: String,
#[serde(rename = "type")]
pub r#type: ContactPropertyCreateRequestType,
}
/// Define the contact property change that triggers the workflow. In update requests, `key` must resolve to an existing contact property that is available for Contact Updated triggers. Hidden or unsupported fields, such as `createdAt`, `notes`, and computed contact properties, are rejected.
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
pub struct WorkflowContactPropertyQuery {
/// The camel-cased `key` of the contact property to query. The property must exist for the team and must be available for Contact Updated triggers.
#[validate(length(min = 1u64))]
pub key: String,
/// For Contact Updated triggers, the API validates `operator` against the selected contact property's type and the side of the comparison. The `was` comparison can use any operator supported by the selected property type. The `is` comparison uses the same operators, except number and boolean properties cannot use `empty`. String properties support `any`, `equal`, `not_equal`, `contains`, `not_contains`, `empty`, and `not_empty`. Number properties support `any`, `greater_than`, `less_than`, `numeric_equal`, `numeric_not_equal`, `empty`, and `not_empty`. Boolean properties support `any`, `true`, `false`, `empty`, and `not_empty`. Date properties support `any`, `empty`, `not_empty`, `after`, `before`, and `between`.
pub is: WorkflowContactPropertyComparison,
/// For Contact Updated triggers, the API validates `operator` against the selected contact property's type and the side of the comparison. The `was` comparison can use any operator supported by the selected property type. The `is` comparison uses the same operators, except number and boolean properties cannot use `empty`. String properties support `any`, `equal`, `not_equal`, `contains`, `not_contains`, `empty`, and `not_empty`. Number properties support `any`, `greater_than`, `less_than`, `numeric_equal`, `numeric_not_equal`, `empty`, and `not_empty`. Boolean properties support `any`, `true`, `false`, `empty`, and `not_empty`. Date properties support `any`, `empty`, `not_empty`, `after`, `before`, and `between`.
pub was: WorkflowContactPropertyComparison,
}
/// For Contact Updated triggers, the API validates `operator` against the selected contact property's type and the side of the comparison. The `was` comparison can use any operator supported by the selected property type. The `is` comparison uses the same operators, except number and boolean properties cannot use `empty`. String properties support `any`, `equal`, `not_equal`, `contains`, `not_contains`, `empty`, and `not_empty`. Number properties support `any`, `greater_than`, `less_than`, `numeric_equal`, `numeric_not_equal`, `empty`, and `not_empty`. Boolean properties support `any`, `true`, `false`, `empty`, and `not_empty`. Date properties support `any`, `empty`, `not_empty`, `after`, `before`, and `between`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
pub struct WorkflowContactPropertyComparison {
pub value: WorkflowContactPropertyComparisonValue,
/// The comparison operator. It must be valid for the selected contact property's type and for the `is` or `was` side of the comparison. Number and boolean properties allow `empty` on `was`, but not on `is`.
pub operator: WorkflowContactPropertyComparisonOperator,
}
/// The amount of time to wait before triggering the next node. Set to `0` to move to the next node immediately.
pub type WorkflowTimerAmount = f64;
/// The unit of time for the timer action node. m = minutes, h = hours, d = days.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, oas3_gen_support::Default)]
pub enum WorkflowTimerUnit {
#[serde(rename = "m")]
#[default]
M,
#[serde(rename = "h")]
H,
#[serde(rename = "d")]
D,
}
impl core::fmt::Display for WorkflowTimerUnit {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::M => write!(f, "m"),
Self::H => write!(f, "h"),
Self::D => write!(f, "d"),
}
}
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct WorkflowFailureResponse {
pub message: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct GroupResponse {
/// The ID of the group.
pub id: String,
/// The name of the group.
pub name: String,
/// The description of the group.
pub description: String,
/// ISO 8601 timestamp for when the group was created.
#[serde(rename = "createdAt")]
pub created_at: chrono::DateTime<chrono::Utc>,
/// ISO 8601 timestamp for when the group was last updated.
#[serde(rename = "updatedAt")]
pub updated_at: chrono::DateTime<chrono::Utc>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ListGroupsResponse {
pub pagination: Pagination,
pub data: Vec<GroupResponse>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct CreateGroupRequest {
/// The group name. Cannot be the reserved name "Unsorted".
#[validate(length(min = 1u64))]
pub name: String,
/// An optional description for the group.
pub description: Option<String>,
}
/// At least one field must be provided.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct UpdateGroupRequest {
/// The group name. Cannot be the reserved name "Unsorted".
pub name: Option<String>,
/// A description for the group.
pub description: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct GroupFailureResponse {
pub message: String,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct UpdateEmailMessageRequest {
/// The `contentRevisionId` you last fetched, or the `emailMessageContentRevisionId` you received when creating the campaign.
#[serde(rename = "expectedRevisionId")]
pub expected_revision_id: Option<String>,
pub subject: Option<String>,
#[serde(rename = "previewText")]
pub preview_text: Option<String>,
#[serde(rename = "fromName")]
pub from_name: Option<String>,
/// The email sender email address, without the team's sending domain.
#[serde(rename = "fromEmail")]
pub from_email: Option<String>,
/// Reply-to email. Must be empty or a valid email address.
#[serde(rename = "replyToEmail")]
pub reply_to_email: Option<String>,
/// CC email address. Requires the team to have CC/BCC enabled. Not supported for campaign emails.
#[serde(rename = "ccEmail")]
pub cc_email: Option<String>,
/// BCC email address. Requires the team to have CC/BCC enabled. Not supported for campaign emails.
#[serde(rename = "bccEmail")]
pub bcc_email: Option<String>,
/// ISO 639-1 language code for the email, e.g. `en` or `fr`.
#[serde(rename = "languageCode")]
pub language_code: Option<String>,
/// The rendering format of the email.
#[serde(rename = "emailFormat")]
pub email_format: Option<EmailFormat>,
/// The email body serialized as LMX. Styles must be embedded in the LMX `<Style />` tag.
pub lmx: Option<String>,
/// Fallback values for contact properties, keyed by property name. Per-key merge: a string value sets the fallback, a null value deletes it, and keys omitted from the map are left unchanged.
#[serde(rename = "contactPropertiesFallbacks")]
pub contact_properties_fallbacks: Option<indexmap::IndexMap<String, Option<String>>>,
/// Fallback values for event properties, keyed by property name. Per-key merge: a string value sets the fallback, a null value deletes it, and keys omitted from the map are left unchanged.
#[serde(rename = "eventPropertiesFallbacks")]
pub event_properties_fallbacks: Option<indexmap::IndexMap<String, Option<String>>>,
/// Fallback values for data variables, keyed by variable name. Per-key merge: a string value sets the fallback, a null value deletes it, and keys omitted from the map are left unchanged.
#[serde(rename = "dataVariablesFallbacks")]
pub data_variables_fallbacks: Option<indexmap::IndexMap<String, Option<String>>>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct EmailMessageResponse {
/// The ID of the email message.
pub id: String,
/// The campaign this email message belongs to. Present only when the message belongs to a campaign (mutually exclusive with `transactionalId`).
#[serde(rename = "campaignId")]
pub campaign_id: Option<String>,
/// The transactional email this email message belongs to. Present only when the message belongs to a transactional email (mutually exclusive with `campaignId`).
#[serde(rename = "transactionalId")]
pub transactional_id: Option<String>,
/// The email subject.
pub subject: String,
/// The email preview text.
#[serde(rename = "previewText")]
pub preview_text: String,
/// The email sender name.
#[serde(rename = "fromName")]
pub from_name: String,
/// The email sender email address, without the team's sending domain.
#[serde(rename = "fromEmail")]
pub from_email: String,
/// The email reply-to address.
#[serde(rename = "replyToEmail")]
pub reply_to_email: String,
/// The email CC address. Only present when set.
#[serde(rename = "ccEmail")]
pub cc_email: Option<String>,
/// The email BCC address. Only present when set.
#[serde(rename = "bccEmail")]
pub bcc_email: Option<String>,
/// ISO 639-1 language code for the email, e.g. `en` or `fr`. Only present when set.
#[serde(rename = "languageCode")]
pub language_code: Option<String>,
/// The rendering format of the email.
#[serde(rename = "emailFormat")]
pub email_format: EmailFormat,
/// The email body serialized as LMX.
pub lmx: String,
/// The current content revision. Pass this as `expectedRevisionId` on your next update.
#[serde(rename = "contentRevisionId")]
pub content_revision_id: Option<String>,
#[serde(rename = "updatedAt")]
pub updated_at: chrono::DateTime<chrono::Utc>,
/// Fallback values for contact properties. Only present when set.
#[serde(rename = "contactPropertiesFallbacks")]
pub contact_properties_fallbacks: Option<indexmap::IndexMap<String, String>>,
/// Fallback values for event properties. Only present when set.
#[serde(rename = "eventPropertiesFallbacks")]
pub event_properties_fallbacks: Option<indexmap::IndexMap<String, String>>,
/// Fallback values for data variables. Only present when set.
#[serde(rename = "dataVariablesFallbacks")]
pub data_variables_fallbacks: Option<indexmap::IndexMap<String, String>>,
/// Non-fatal issues raised while compiling the submitted LMX. Only present on update responses when warnings were produced.
pub warnings: Option<Vec<EmailMessageResponseWarning>>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct EmailMessageFailureResponse {
pub message: String,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct EmailMessagePreviewRequest {
/// One or more addresses to send the preview to.
#[validate(length(min = 1u64))]
pub emails: Vec<String>,
/// Contact property values to render. Accepted for campaign and workflow previews.
/// - Example: `Some({"firstName":"Alex"})`
#[serde(rename = "contactProperties")]
pub contact_properties: Option<indexmap::IndexMap<String, String>>,
/// Event property values to render. Accepted for workflow previews only.
/// - Example: `Some({"planName":"Pro"})`
#[serde(rename = "eventProperties")]
pub event_properties: Option<indexmap::IndexMap<String, String>>,
/// Transactional data variables to render. Accepted for transactional previews only.
/// - Example: `Some({"loginUrl":"https://app.company.com/login"})`
#[serde(rename = "dataVariables")]
pub data_variables: Option<indexmap::IndexMap<String, String>>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct EmailMessagePreviewResponse {
/// The ID of the email message the preview was sent for.
pub id: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct EmailMessageGuardianResponse {
/// Validation errors. These must be resolved before the email can be published.
pub errors: Vec<GuardianRule>,
/// Validation warnings. These are advisory and do not block publishing.
pub warnings: Vec<GuardianRule>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct GuardianRule {
/// The identifier of the Guardian rule that fired.
pub rule: GuardianRuleRule,
/// A short summary of the rule.
pub title: String,
/// A longer explanation of why the issue matters.
pub description: String,
/// The specific elements that triggered the rule.
pub items: Vec<GuardianRuleItem>,
}
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct CreateUploadRequest {
/// The MIME type of the file to upload. Supported types are `image/jpeg`, `image/png`, `image/gif` and `image/webp`.
#[serde(rename = "contentType")]
#[validate(length(min = 1u64))]
pub content_type: String,
/// The size of the file in bytes. Must be a positive integer no greater than 4,000,000 bytes.
#[serde(rename = "contentLength")]
pub content_length: i64,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct CreateUploadResponse {
/// The ID of the created asset. Pass this as `emailAssetId` to `POST /v1/uploads/{emailAssetId}/complete` once the file has been uploaded.
#[serde(rename = "emailAssetId")]
pub email_asset_id: String,
/// The pre-signed URL to upload the file to with an HTTP `PUT` request. Send the same `Content-Type` and `Content-Length` used in the create request.
#[serde(rename = "presignedUrl")]
pub presigned_url: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct CompleteUploadResponse {
/// The ID of the created asset.
#[serde(rename = "emailAssetId")]
pub email_asset_id: String,
/// The public URL of the uploaded asset.
#[serde(rename = "finalUrl")]
pub final_url: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct UploadLimitExceededFailureResponse {
pub message: Option<String>,
/// The maximum number of uploads allowed per window.
#[serde(rename = "maxUploads")]
pub max_uploads: Option<i64>,
/// The number of hours in the upload limit window.
#[serde(rename = "windowHours")]
pub window_hours: Option<i64>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct UploadFailureResponse {
pub message: String,
/// Present when the request was rejected for an unsupported `contentType`. Lists the accepted MIME types.
#[serde(rename = "supportedContentTypes")]
pub supported_content_types: Option<Vec<String>>,
/// Present when the upload exceeds the size limit. The maximum allowed size in bytes.
#[serde(rename = "maxBytes")]
pub max_bytes: Option<i64>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct Pagination {
#[serde(rename = "totalResults")]
pub total_results: f64,
#[serde(rename = "returnedResults")]
pub returned_results: f64,
#[serde(rename = "perPage")]
pub per_page: f64,
#[serde(rename = "totalPages")]
pub total_pages: f64,
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
#[serde(rename = "nextPage")]
pub next_page: Option<String>,
}
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
pub struct WebhookContactIdentity {
#[validate(length(min = 1u64))]
pub id: String,
#[validate(length(min = 1u64))]
pub email: String,
#[serde(rename = "userId")]
pub user_id: Option<String>,
}
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct WebhookBasePayload {
#[serde(rename = "eventName")]
#[validate(length(min = 1u64))]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
}
/// Full contact object, including custom properties.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookContact {
#[validate(length(min = 1u64))]
pub id: String,
#[validate(length(min = 1u64))]
pub email: String,
#[serde(rename = "firstName")]
pub first_name: Option<String>,
#[serde(rename = "lastName")]
pub last_name: Option<String>,
#[validate(length(min = 1u64))]
pub source: String,
pub subscribed: bool,
#[serde(rename = "userGroup")]
#[validate(length(min = 1u64))]
pub user_group: String,
#[serde(rename = "userId")]
pub user_id: Option<String>,
pub notes: Option<String>,
/// An object of mailing list IDs and boolean subscription statuses.
#[serde(rename = "mailingLists")]
pub mailing_lists: indexmap::IndexMap<String, bool>,
/// Double opt-in status.
#[serde(rename = "optInStatus")]
pub opt_in_status: Option<OptInStatus>,
/// Additional properties not defined in the schema.
#[serde(flatten)]
pub additional_properties: indexmap::IndexMap<String, serde_json::Value>,
}
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
pub struct WebhookEmail {
/// The ID of the email.
#[validate(length(min = 1u64))]
pub id: String,
/// The ID of the sent version of the campaign, workflow or transactional email.
#[serde(rename = "emailMessageId")]
#[validate(length(min = 1u64))]
pub email_message_id: String,
/// The subject of the email.
#[validate(length(min = 1u64))]
pub subject: String,
}
/// Details of the mailing list.
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookMailingList {
#[validate(length(min = 1u64))]
pub id: String,
#[validate(length(min = 1u64))]
pub name: String,
pub description: Option<String>,
#[serde(rename = "isPublic")]
pub is_public: bool,
}
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct WebhookEmailMetricPayload {
#[serde(rename = "eventName")]
#[validate(length(min = 1u64))]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
#[validate(nested)]
pub email: WebhookEmail,
/// The type of email this event relates to. Workflow emails use `loop`.
#[serde(rename = "sourceType")]
pub source_type: WebhookEmailMetricPayloadSourceType,
/// The ID of the campaign if `sourceType` is `campaign`.
#[serde(rename = "campaignId")]
pub campaign_id: Option<String>,
/// The ID of the workflow if `sourceType` is `loop`.
#[serde(rename = "loopId")]
pub loop_id: Option<String>,
/// The ID of the transactional email if `sourceType` is `transactional`.
#[serde(rename = "transactionalId")]
pub transactional_id: Option<String>,
}
#[serde_with::skip_serializing_none]
#[derive(
Debug, Clone, PartialEq, Serialize, Deserialize, validator::Validate, oas3_gen_support::Default,
)]
#[serde(default)]
pub struct WebhookMarketingEmailMetricPayload {
#[serde(rename = "eventName")]
#[validate(length(min = 1u64))]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
#[validate(nested)]
pub email: WebhookEmail,
/// The type of email this event relates to. Workflow emails use `loop`. Not available for transactional emails.
#[serde(rename = "sourceType")]
pub source_type: WebhookMarketingEmailMetricPayloadSourceType,
/// The ID of the campaign if `sourceType` is `campaign`.
#[serde(rename = "campaignId")]
pub campaign_id: Option<String>,
/// The ID of the workflow if `sourceType` is `loop`.
#[serde(rename = "loopId")]
pub loop_id: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct WebhookContactUnsubscribedPayload {
#[serde(rename = "eventName")]
#[default("contact.unsubscribed".to_string())]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
}
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct WebhookContactCreatedPayload {
#[serde(rename = "eventName")]
#[default("contact.created".to_string())]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
/// Full contact object, including custom properties.
#[validate(nested)]
pub contact: WebhookContact,
}
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct WebhookContactDeletedPayload {
#[serde(rename = "eventName")]
#[default("contact.deleted".to_string())]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
}
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct WebhookContactMailingListSubscribedPayload {
#[serde(rename = "eventName")]
#[default("contact.mailingList.subscribed".to_string())]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
/// Details of the mailing list.
#[serde(rename = "mailingList")]
#[validate(nested)]
pub mailing_list: WebhookMailingList,
}
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct WebhookContactMailingListUnsubscribedPayload {
#[serde(rename = "eventName")]
#[default("contact.mailingList.unsubscribed".to_string())]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
/// Details of the mailing list.
#[serde(rename = "mailingList")]
#[validate(nested)]
pub mailing_list: WebhookMailingList,
}
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct WebhookTransactionalEmailSentPayload {
#[serde(rename = "eventName")]
#[default("transactional.email.sent".to_string())]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
#[serde(rename = "transactionalId")]
#[validate(length(min = 1u64))]
pub transactional_id: String,
#[serde(rename = "transactionalName")]
#[validate(length(min = 1u64))]
pub transactional_name: String,
#[validate(nested)]
pub email: WebhookEmail,
}
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct WebhookCampaignEmailSentPayload {
#[serde(rename = "eventName")]
#[default("campaign.email.sent".to_string())]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
#[serde(rename = "campaignId")]
#[validate(length(min = 1u64))]
pub campaign_id: String,
#[serde(rename = "campaignName")]
#[validate(length(min = 1u64))]
pub campaign_name: String,
#[validate(nested)]
pub email: WebhookEmail,
/// The mailing list(s) the email was sent to, or an empty array.
#[serde(rename = "mailingLists")]
#[validate(nested)]
pub mailing_lists: Vec<WebhookMailingList>,
}
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct WebhookLoopEmailSentPayload {
#[serde(rename = "eventName")]
#[default("loop.email.sent".to_string())]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
/// The ID of the workflow.
#[serde(rename = "loopId")]
#[validate(length(min = 1u64))]
pub loop_id: String,
/// The name of the workflow.
#[serde(rename = "loopName")]
#[validate(length(min = 1u64))]
pub loop_name: String,
#[validate(nested)]
pub email: WebhookEmail,
/// The mailing list(s) the email was sent to, or an empty array.
#[serde(rename = "mailingLists")]
#[validate(nested)]
pub mailing_lists: Vec<WebhookMailingList>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct WebhookEmailDeliveredPayload {
#[serde(rename = "eventName")]
#[default("email.delivered".to_string())]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
#[validate(nested)]
pub email: WebhookEmail,
/// The type of email this event relates to. Workflow emails use `loop`.
#[serde(rename = "sourceType")]
pub source_type: WebhookEmailMetricPayloadSourceType,
/// The ID of the campaign if `sourceType` is `campaign`.
#[serde(rename = "campaignId")]
pub campaign_id: Option<String>,
/// The ID of the workflow if `sourceType` is `loop`.
#[serde(rename = "loopId")]
pub loop_id: Option<String>,
/// The ID of the transactional email if `sourceType` is `transactional`.
#[serde(rename = "transactionalId")]
pub transactional_id: Option<String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct WebhookEmailSoftBouncedPayload {
#[serde(rename = "eventName")]
#[default("email.softBounced".to_string())]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
#[validate(nested)]
pub email: WebhookEmail,
/// The type of email this event relates to. Workflow emails use `loop`.
#[serde(rename = "sourceType")]
pub source_type: WebhookEmailMetricPayloadSourceType,
/// The ID of the campaign if `sourceType` is `campaign`.
#[serde(rename = "campaignId")]
pub campaign_id: Option<String>,
/// The ID of the workflow if `sourceType` is `loop`.
#[serde(rename = "loopId")]
pub loop_id: Option<String>,
/// The ID of the transactional email if `sourceType` is `transactional`.
#[serde(rename = "transactionalId")]
pub transactional_id: Option<String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct WebhookEmailHardBouncedPayload {
#[serde(rename = "eventName")]
#[default("email.hardBounced".to_string())]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
#[validate(nested)]
pub email: WebhookEmail,
/// The type of email this event relates to. Workflow emails use `loop`.
#[serde(rename = "sourceType")]
pub source_type: WebhookEmailMetricPayloadSourceType,
/// The ID of the campaign if `sourceType` is `campaign`.
#[serde(rename = "campaignId")]
pub campaign_id: Option<String>,
/// The ID of the workflow if `sourceType` is `loop`.
#[serde(rename = "loopId")]
pub loop_id: Option<String>,
/// The ID of the transactional email if `sourceType` is `transactional`.
#[serde(rename = "transactionalId")]
pub transactional_id: Option<String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct WebhookEmailClickedPayload {
#[serde(rename = "eventName")]
#[default("email.clicked".to_string())]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
#[validate(nested)]
pub email: WebhookEmail,
/// The type of email this event relates to. Workflow emails use `loop`. Not available for transactional emails.
#[serde(rename = "sourceType")]
pub source_type: WebhookMarketingEmailMetricPayloadSourceType,
/// The ID of the campaign if `sourceType` is `campaign`.
#[serde(rename = "campaignId")]
pub campaign_id: Option<String>,
/// The ID of the workflow if `sourceType` is `loop`.
#[serde(rename = "loopId")]
pub loop_id: Option<String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct WebhookEmailUnsubscribedPayload {
#[serde(rename = "eventName")]
#[default("email.unsubscribed".to_string())]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
#[validate(nested)]
pub email: WebhookEmail,
/// The type of email this event relates to. Workflow emails use `loop`. Not available for transactional emails.
#[serde(rename = "sourceType")]
pub source_type: WebhookMarketingEmailMetricPayloadSourceType,
/// The ID of the campaign if `sourceType` is `campaign`.
#[serde(rename = "campaignId")]
pub campaign_id: Option<String>,
/// The ID of the workflow if `sourceType` is `loop`.
#[serde(rename = "loopId")]
pub loop_id: Option<String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct WebhookEmailResubscribedPayload {
#[serde(rename = "eventName")]
#[default("email.resubscribed".to_string())]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
#[validate(nested)]
pub email: WebhookEmail,
/// The type of email this event relates to. Workflow emails use `loop`. Not available for transactional emails.
#[serde(rename = "sourceType")]
pub source_type: WebhookMarketingEmailMetricPayloadSourceType,
/// The ID of the campaign if `sourceType` is `campaign`.
#[serde(rename = "campaignId")]
pub campaign_id: Option<String>,
/// The ID of the workflow if `sourceType` is `loop`.
#[serde(rename = "loopId")]
pub loop_id: Option<String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct WebhookEmailOpenedPayload {
#[serde(rename = "eventName")]
#[default("email.opened".to_string())]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
#[validate(nested)]
pub email: WebhookEmail,
/// The type of email this event relates to. Workflow emails use `loop`. Not available for transactional emails.
#[serde(rename = "sourceType")]
pub source_type: WebhookMarketingEmailMetricPayloadSourceType,
/// The ID of the campaign if `sourceType` is `campaign`.
#[serde(rename = "campaignId")]
pub campaign_id: Option<String>,
/// The ID of the workflow if `sourceType` is `loop`.
#[serde(rename = "loopId")]
pub loop_id: Option<String>,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
#[serde(default)]
pub struct WebhookEmailSpamReportedPayload {
#[serde(rename = "eventName")]
#[default("email.spamReported".to_string())]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
#[serde(rename = "contactIdentity")]
#[validate(nested)]
pub contact_identity: WebhookContactIdentity,
#[validate(nested)]
pub email: WebhookEmail,
/// The type of email this event relates to. Workflow emails use `loop`.
#[serde(rename = "sourceType")]
pub source_type: WebhookEmailMetricPayloadSourceType,
/// The ID of the campaign if `sourceType` is `campaign`.
#[serde(rename = "campaignId")]
pub campaign_id: Option<String>,
/// The ID of the workflow if `sourceType` is `loop`.
#[serde(rename = "loopId")]
pub loop_id: Option<String>,
/// The ID of the transactional email if `sourceType` is `transactional`.
#[serde(rename = "transactionalId")]
pub transactional_id: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct WebhookTestingTestEventPayload {
#[serde(rename = "eventName")]
#[default("testing.testEvent".to_string())]
pub event_name: String,
/// Unix timestamp in seconds.
#[serde(rename = "eventTime")]
pub event_time: i64,
#[default("test".to_string())]
pub message: String,
#[serde(rename = "webhookSchemaVersion")]
#[default("1.0.0".to_string())]
pub webhook_schema_version: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, oas3_gen_support::Default)]
pub enum OptInStatus {
#[serde(rename = "accepted")]
#[default]
Accepted,
#[serde(rename = "pending")]
Pending,
#[serde(rename = "rejected")]
Rejected,
}
impl core::fmt::Display for OptInStatus {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Accepted => write!(f, "accepted"),
Self::Pending => write!(f, "pending"),
Self::Rejected => write!(f, "rejected"),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, oas3_gen_support::Default)]
pub enum Status {
#[serde(rename = "accepted")]
#[default]
Accepted,
#[serde(rename = "pending")]
Pending,
#[serde(rename = "rejected")]
Rejected,
}
impl core::fmt::Display for Status {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Accepted => write!(f, "accepted"),
Self::Pending => write!(f, "pending"),
Self::Rejected => write!(f, "rejected"),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, oas3_gen_support::Default)]
pub enum IncomingWebhookPlatform {
#[serde(rename = "clerk")]
#[default]
Clerk,
#[serde(rename = "polar")]
Polar,
#[serde(rename = "stripe")]
Stripe,
#[serde(rename = "supabase")]
Supabase,
}
impl core::fmt::Display for IncomingWebhookPlatform {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Clerk => write!(f, "clerk"),
Self::Polar => write!(f, "polar"),
Self::Stripe => write!(f, "stripe"),
Self::Supabase => write!(f, "supabase"),
}
}
}
/// Test your API key and get team context.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct TestApiKeyRequest {}
impl TestApiKeyRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<TestApiKeyResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<ApiKey200Response>::json_with_diagnostics(req)
.await?;
return Ok(TestApiKeyResponse::Ok(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let data =
oas3_gen_support::Diagnostics::<ApiKey401Response>::json_with_diagnostics(req)
.await?;
return Ok(TestApiKeyResponse::Unauthorized(data));
}
let _ = req.bytes().await?;
return Ok(TestApiKeyResponse::Unknown);
}
}
/// Response types for testApiKey
#[derive(Debug, Clone)]
pub enum TestApiKeyResponse {
///200: Success
Ok(ApiKey200Response),
///401: Invalid API key
Unauthorized(ApiKey401Response),
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct GetAudienceSegmentRequestPath {
/// The ID of the audience segment.
#[validate(length(min = 1u64))]
pub audience_segment_id: String,
}
/// Retrieve a single audience segment by ID.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetAudienceSegmentRequest {
#[validate(nested)]
pub path: GetAudienceSegmentRequestPath,
}
impl GetAudienceSegmentRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<GetAudienceSegmentResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<AudienceSegmentResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(GetAudienceSegmentResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
AudienceSegmentFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetAudienceSegmentResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetAudienceSegmentResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data = oas3_gen_support::Diagnostics::<
AudienceSegmentFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetAudienceSegmentResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetAudienceSegmentResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetAudienceSegmentResponse::Unknown);
}
}
/// Response types for getAudienceSegment
#[derive(Debug, Clone)]
pub enum GetAudienceSegmentResponse {
///200: Successful.
Ok(AudienceSegmentResponse),
///400: Invalid `audienceSegmentId`.
BadRequest(AudienceSegmentFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///404: Audience segment not found.
NotFound(AudienceSegmentFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct ListAudienceSegmentsRequestQuery {
/// How many results to return in each request. Must be between 10 and 50. Default is 20.
#[serde(rename = "perPage")]
pub per_page: Option<String>,
/// A cursor to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response.
pub cursor: Option<String>,
}
/// Retrieve a paginated list of audience segments, most recently created first.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct ListAudienceSegmentsRequest {
pub query: ListAudienceSegmentsRequestQuery,
}
impl ListAudienceSegmentsRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<ListAudienceSegmentsResponseEnum> {
let status = req.status();
if status == http::StatusCode::OK {
let data = oas3_gen_support::Diagnostics::<
ListAudienceSegmentsResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(ListAudienceSegmentsResponseEnum::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
AudienceSegmentFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(ListAudienceSegmentsResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(ListAudienceSegmentsResponseEnum::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(ListAudienceSegmentsResponseEnum::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(ListAudienceSegmentsResponseEnum::Unknown);
}
}
/// Response types for listAudienceSegments
#[derive(Debug, Clone)]
pub enum ListAudienceSegmentsResponseEnum {
///200: Successful.
Ok(ListAudienceSegmentsResponse),
///400: Invalid `perPage` value.
BadRequest(AudienceSegmentFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
/// Create a new audience segment.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct CreateAudienceSegmentRequestParams {
#[validate(nested)]
pub body: CreateAudienceSegmentRequest,
}
impl CreateAudienceSegmentRequestParams {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<GetAudienceSegmentResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<AudienceSegmentResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(GetAudienceSegmentResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
AudienceSegmentFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetAudienceSegmentResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetAudienceSegmentResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data = oas3_gen_support::Diagnostics::<
AudienceSegmentFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetAudienceSegmentResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetAudienceSegmentResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetAudienceSegmentResponse::Unknown);
}
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct ListCampaignsRequestQuery {
/// How many results to return in each request. Must be between 10 and 50. Default is 20.
#[serde(rename = "perPage")]
pub per_page: Option<String>,
/// A cursor to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response.
pub cursor: Option<String>,
}
/// Retrieve a paginated list of campaigns.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct ListCampaignsRequest {
pub query: ListCampaignsRequestQuery,
}
impl ListCampaignsRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<ListCampaignsResponseEnum> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<ListCampaignsResponse>::json_with_diagnostics(req)
.await?;
return Ok(ListCampaignsResponseEnum::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<CampaignFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(ListCampaignsResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(ListCampaignsResponseEnum::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(ListCampaignsResponseEnum::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(ListCampaignsResponseEnum::Unknown);
}
}
/// Response types for listCampaigns
#[derive(Debug, Clone)]
pub enum ListCampaignsResponseEnum {
///200: Successful.
Ok(ListCampaignsResponse),
///400: Invalid `perPage` value.
BadRequest(CampaignFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
/// Create a new draft campaign. An empty email message is created automatically and its `emailMessageId` is returned. Use the `/email-messages/{emailMessageId}` endpoint to set subject, sender, preview text, and LMX content. The audience (mailing list, segment, or filter), group, and scheduling can be set on create or later via update.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct CreateCampaignRequestParams {
#[validate(nested)]
pub body: CreateCampaignRequest,
}
impl CreateCampaignRequestParams {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<CreateCampaignResponseEnum> {
let status = req.status();
if status == http::StatusCode::CREATED {
let data =
oas3_gen_support::Diagnostics::<CreateCampaignResponse>::json_with_diagnostics(req)
.await?;
return Ok(CreateCampaignResponseEnum::Created(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<CampaignFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(CreateCampaignResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(CreateCampaignResponseEnum::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<CampaignFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(CreateCampaignResponseEnum::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(CreateCampaignResponseEnum::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(CreateCampaignResponseEnum::Unknown);
}
}
/// Response types for createCampaign
#[derive(Debug, Clone)]
pub enum CreateCampaignResponseEnum {
///201: Campaign created.
Created(CreateCampaignResponse),
///400: Invalid request body, campaign group not found, or no sending domain configured.
BadRequest(CampaignFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///404: Referenced mailing list or audience segment not found.
NotFound(CampaignFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct GetCampaignRequestPath {
/// The ID of the campaign.
#[validate(length(min = 1u64))]
pub campaign_id: String,
}
/// Retrieve a single campaign by ID.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetCampaignRequest {
#[validate(nested)]
pub path: GetCampaignRequestPath,
}
impl GetCampaignRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<GetCampaignResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<CampaignResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetCampaignResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<CampaignFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(GetCampaignResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetCampaignResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<CampaignFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(GetCampaignResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetCampaignResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetCampaignResponse::Unknown);
}
}
/// Response types for getCampaign
#[derive(Debug, Clone)]
pub enum GetCampaignResponse {
///200: Successful.
Ok(CampaignResponse),
///400: Invalid `campaignId`.
BadRequest(CampaignFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///404: Campaign not found.
NotFound(CampaignFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateCampaignRequestParamsPath {
/// The ID of the campaign.
#[validate(length(min = 1u64))]
pub campaign_id: String,
}
/// Update a draft campaign's name, group, audience (mailing list, segment, or filter), or scheduling. At least one field must be provided. Once a campaign has been sent, only its `name` and `campaignGroupId` can be updated.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateCampaignRequestParams {
#[validate(nested)]
pub path: UpdateCampaignRequestParamsPath,
#[validate(nested)]
pub body: UpdateCampaignRequest,
}
impl UpdateCampaignRequestParams {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<UpdateCampaignResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<CampaignResponse>::json_with_diagnostics(req)
.await?;
return Ok(UpdateCampaignResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<CampaignFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(UpdateCampaignResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(UpdateCampaignResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<CampaignFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(UpdateCampaignResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(UpdateCampaignResponse::MethodNotAllowed);
}
if status == http::StatusCode::CONFLICT {
let data =
oas3_gen_support::Diagnostics::<CampaignFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(UpdateCampaignResponse::Conflict(data));
}
let _ = req.bytes().await?;
return Ok(UpdateCampaignResponse::Unknown);
}
}
/// Response types for updateCampaign
#[derive(Debug, Clone)]
pub enum UpdateCampaignResponse {
///200: Campaign updated.
Ok(CampaignResponse),
///400: Invalid request body or campaign group not found.
BadRequest(CampaignFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///404: Campaign, mailing list, or audience segment not found.
NotFound(CampaignFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///409: Campaign has been sent and the request updates a field other than `name` or `campaignGroupId`.
Conflict(CampaignFailureResponse),
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct GetCampaignMetricsRequestPath {
/// The ID of the campaign.
#[validate(length(min = 1u64))]
pub campaign_id: String,
}
/// Retrieve all-time email engagement metrics for a campaign.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetCampaignMetricsRequest {
#[validate(nested)]
pub path: GetCampaignMetricsRequestPath,
}
impl GetCampaignMetricsRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<GetCampaignMetricsResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<EmailMetricsResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetCampaignMetricsResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<CampaignFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(GetCampaignMetricsResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetCampaignMetricsResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<CampaignFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(GetCampaignMetricsResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetCampaignMetricsResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetCampaignMetricsResponse::Unknown);
}
}
/// Response types for getCampaignMetrics
#[derive(Debug, Clone)]
pub enum GetCampaignMetricsResponse {
///200: Successful.
Ok(EmailMetricsResponse),
///400: Invalid `campaignId`, the campaign has not been sent yet, or the campaign has no email message.
BadRequest(CampaignFailureResponse),
///401: Invalid API key.
Unauthorized,
///404: Campaign not found.
NotFound(CampaignFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct ListCampaignGroupsRequestQuery {
/// How many results to return in each request. Must be between 10 and 50. Default is 20.
#[serde(rename = "perPage")]
pub per_page: Option<String>,
/// A cursor to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response.
pub cursor: Option<String>,
}
/// Retrieve a paginated list of campaign groups, most recently created first.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct ListCampaignGroupsRequest {
pub query: ListCampaignGroupsRequestQuery,
}
impl ListCampaignGroupsRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<ListCampaignGroupsResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<ListGroupsResponse>::json_with_diagnostics(req)
.await?;
return Ok(ListCampaignGroupsResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(ListCampaignGroupsResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(ListCampaignGroupsResponse::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(ListCampaignGroupsResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(ListCampaignGroupsResponse::Unknown);
}
}
/// Response types for listCampaignGroups
#[derive(Debug, Clone)]
pub enum ListCampaignGroupsResponse {
///200: Successful.
Ok(ListGroupsResponse),
///400: Invalid `perPage` value.
BadRequest(GroupFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
/// Create a new campaign group.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct CreateCampaignGroupRequest {
#[validate(nested)]
pub body: CreateGroupRequest,
}
impl CreateCampaignGroupRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<CreateCampaignGroupResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<GroupResponse>::json_with_diagnostics(req).await?;
return Ok(CreateCampaignGroupResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(CreateCampaignGroupResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(CreateCampaignGroupResponse::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(CreateCampaignGroupResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(CreateCampaignGroupResponse::Unknown);
}
}
/// Response types for createCampaignGroup
#[derive(Debug, Clone)]
pub enum CreateCampaignGroupResponse {
///200: Campaign group created.
Ok(GroupResponse),
///400: Invalid request body or reserved group name.
BadRequest(GroupFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct GetCampaignGroupRequestPath {
/// The ID of the campaign group.
#[validate(length(min = 1u64))]
pub campaign_group_id: String,
}
/// Retrieve a single campaign group by ID.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetCampaignGroupRequest {
#[validate(nested)]
pub path: GetCampaignGroupRequestPath,
}
impl GetCampaignGroupRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<GetCampaignGroupResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<GroupResponse>::json_with_diagnostics(req).await?;
return Ok(GetCampaignGroupResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetCampaignGroupResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetCampaignGroupResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::Unknown);
}
}
/// Response types for getCampaignGroup
#[derive(Debug, Clone)]
pub enum GetCampaignGroupResponse {
///200: Successful.
Ok(GroupResponse),
///400: Invalid `campaignGroupId`.
BadRequest(GroupFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///404: Campaign group not found.
NotFound(GroupFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateCampaignGroupRequestPath {
/// The ID of the campaign group.
#[validate(length(min = 1u64))]
pub campaign_group_id: String,
}
/// Update a campaign group's name or description. At least one field must be provided. The reserved "Unsorted" group cannot be edited.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateCampaignGroupRequest {
#[validate(nested)]
pub path: UpdateCampaignGroupRequestPath,
pub body: UpdateGroupRequest,
}
impl UpdateCampaignGroupRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<GetCampaignGroupResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<GroupResponse>::json_with_diagnostics(req).await?;
return Ok(GetCampaignGroupResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetCampaignGroupResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetCampaignGroupResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::Unknown);
}
}
/// Retrieve a list of Loops' dedicated sending IP addresses.
///
/// This endpoint is provided for the rare instances where you may need to whitelist our sending IPs. Please note that this list is subject to change and will not include shared IPs used for sending mail.
///
/// Unless you are sure you need this and are comfortable watching for changes, we strongly recommend you _do not_ whitelist these IPs.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct ListDedicatedSendingIpsRequest {}
impl ListDedicatedSendingIpsRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<ListDedicatedSendingIpsResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<Vec<String>>::json_with_diagnostics(req).await?;
return Ok(ListDedicatedSendingIpsResponse::Ok(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(ListDedicatedSendingIpsResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(ListDedicatedSendingIpsResponse::Unknown);
}
}
/// Response types for listDedicatedSendingIps
#[derive(Debug, Clone)]
pub enum ListDedicatedSendingIpsResponse {
///200: Successful.
Ok(Vec<String>),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
/// Add a contact to your audience.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct CreateContactRequest {
/// You can add custom contact properties as keys in this request (of type `string`, `number`, `boolean` or `date`. [See available date formats](https://loops.so/docs/contacts/properties#dates)). Make sure to create the properties in Loops before using them in API calls.
#[validate(nested)]
pub body: ContactRequest,
}
impl CreateContactRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<CreateContactResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<ContactSuccessResponse>::json_with_diagnostics(req)
.await?;
return Ok(CreateContactResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<ContactFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(CreateContactResponse::BadRequest(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(CreateContactResponse::MethodNotAllowed);
}
if status == http::StatusCode::CONFLICT {
let data =
oas3_gen_support::Diagnostics::<ContactFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(CreateContactResponse::Conflict(data));
}
let _ = req.bytes().await?;
return Ok(CreateContactResponse::Unknown);
}
}
/// Response types for createContact
#[derive(Debug, Clone)]
pub enum CreateContactResponse {
///200: Successful create.
Ok(ContactSuccessResponse),
///400: Bad request (e.g. invalid email address).
BadRequest(ContactFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///409: Email or `userId` already exists.
Conflict(ContactFailureResponse),
///default: Unknown response
Unknown,
}
/// Update a contact by `email` or `userId`. You must provide one of these parameters.
///
/// If you want to update a contact's email address, the contact will first need a `userId` value. You can then make a request containing the `userId` field along with an updated email address.
///
/// This endpoint will create a contact if a matching contact does not already exist in your audience.
///
/// Provide either `email` or `userId` to identify the contact you want to update. If both are provided, the system will look for a contact with either a matching `email` or `userId` value. If a contact is found for one of the values (e.g. `email`), the other value (e.g. `userId`) will be updated. If a contact is not found, a new contact will be created using both `email` and `userId` values.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateContactRequest {
/// You can add custom contact properties as keys in this request (of type `string`, `number`, `boolean` or `date`. [See available date formats](https://loops.so/docs/contacts/properties#dates)). Make sure to create the properties in Loops before using them in API calls.
pub body: ContactUpdateRequest,
}
impl UpdateContactRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<UpdateContactResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<ContactSuccessResponse>::json_with_diagnostics(req)
.await?;
return Ok(UpdateContactResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<ContactFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(UpdateContactResponse::BadRequest(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(UpdateContactResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(UpdateContactResponse::Unknown);
}
}
/// Response types for updateContact
#[derive(Debug, Clone)]
pub enum UpdateContactResponse {
///200: Successful update.
Ok(ContactSuccessResponse),
///400: Bad request (e.g. `email` or `userId` are missing).
BadRequest(ContactFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct FindContactRequestQuery {
/// Email address (URI-encoded)
pub email: Option<String>,
#[serde(rename = "userId")]
pub user_id: Option<String>,
}
/// Search for a contact by `email` or `userId`. Only one parameter is allowed.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct FindContactRequest {
pub query: FindContactRequestQuery,
}
impl FindContactRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<FindContactResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data = oas3_gen_support::Diagnostics::<Find200Response>::json_with_diagnostics(req)
.await?;
return Ok(FindContactResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<ContactFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(FindContactResponse::BadRequest(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(FindContactResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(FindContactResponse::Unknown);
}
}
/// Response types for findContact
#[derive(Debug, Clone)]
pub enum FindContactResponse {
///200: List of contacts (or an empty array if no contact was found). Contact objects will include any custom properties.
Ok(Find200Response),
///400: Bad request (e.g. invalid email address).
BadRequest(ContactFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
/// Delete a contact by `email` or `userId`.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct DeleteContactRequest {
/// Include only one of `email` or `userId`.
pub body: ContactDeleteRequest,
}
impl DeleteContactRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<DeleteContactResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<ContactDeleteResponse>::json_with_diagnostics(req)
.await?;
return Ok(DeleteContactResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<ContactFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(DeleteContactResponse::BadRequest(data));
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<ContactFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(DeleteContactResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(DeleteContactResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(DeleteContactResponse::Unknown);
}
}
/// Response types for deleteContact
#[derive(Debug, Clone)]
pub enum DeleteContactResponse {
///200: Successful delete.
Ok(ContactDeleteResponse),
///400: Bad request (e.g. `email` and `userId` are both provided).
BadRequest(ContactFailureResponse),
///404: Contact not found.
NotFound(ContactFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct GetContactSuppressionRequestQuery {
/// Email address (URI-encoded)
pub email: Option<String>,
#[serde(rename = "userId")]
pub user_id: Option<String>,
}
/// Retrieve suppression status and removal quota for a contact by `email` or `userId`. Include only one query parameter.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetContactSuppressionRequest {
pub query: GetContactSuppressionRequestQuery,
}
impl GetContactSuppressionRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<GetContactSuppressionResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data = oas3_gen_support::Diagnostics::<
ContactSuppressionStatusResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetContactSuppressionResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<ContactFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetContactSuppressionResponse::BadRequest(data));
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<ContactFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetContactSuppressionResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetContactSuppressionResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetContactSuppressionResponse::Unknown);
}
}
/// Response types for getContactSuppression
#[derive(Debug, Clone)]
pub enum GetContactSuppressionResponse {
///200: Successful.
Ok(ContactSuppressionStatusResponse),
///400: Bad request (e.g. invalid email address).
BadRequest(ContactFailureResponse),
///404: Contact not found.
NotFound(ContactFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct RemoveContactSuppressionRequestQuery {
/// Email address (URI-encoded)
pub email: Option<String>,
#[serde(rename = "userId")]
pub user_id: Option<String>,
}
/// Remove a suppressed contact from the suppression list by `email` or `userId`. Include only one query parameter.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct RemoveContactSuppressionRequest {
pub query: RemoveContactSuppressionRequestQuery,
}
impl RemoveContactSuppressionRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<RemoveContactSuppressionResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data = oas3_gen_support::Diagnostics::<
ContactSuppressionRemoveResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(RemoveContactSuppressionResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<ContactFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(RemoveContactSuppressionResponse::BadRequest(data));
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<ContactFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(RemoveContactSuppressionResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(RemoveContactSuppressionResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(RemoveContactSuppressionResponse::Unknown);
}
}
/// Response types for removeContactSuppression
#[derive(Debug, Clone)]
pub enum RemoveContactSuppressionResponse {
///200: Successful removal.
Ok(ContactSuppressionRemoveResponse),
///400: Bad request (e.g. contact is not suppressed).
BadRequest(ContactFailureResponse),
///404: Contact not found.
NotFound(ContactFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct ListContactPropertiesRequestQuery {
/// `all` (default) or `custom` (only custom contact properties)
pub list: Option<String>,
}
/// Retrieve a list of your account's contact properties.<br>Use the `list` parameter to query "all" or "custom" properties.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct ListContactPropertiesRequest {
pub query: ListContactPropertiesRequestQuery,
}
impl ListContactPropertiesRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<ListContactPropertiesResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<Property200Response>::json_with_diagnostics(req)
.await?;
return Ok(ListContactPropertiesResponse::Ok(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(ListContactPropertiesResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(ListContactPropertiesResponse::Unknown);
}
}
/// Response types for listContactProperties
#[derive(Debug, Clone)]
pub enum ListContactPropertiesResponse {
///200: Successful.
Ok(Property200Response),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
/// Create a custom contact property.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct CreateContactPropertyRequest {
#[validate(nested)]
pub body: ContactPropertyCreateRequest,
}
impl CreateContactPropertyRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<CreateContactPropertyResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data = oas3_gen_support::Diagnostics::<
ContactPropertySuccessResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(CreateContactPropertyResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
ContactPropertyFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(CreateContactPropertyResponse::BadRequest(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(CreateContactPropertyResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(CreateContactPropertyResponse::Unknown);
}
}
/// Response types for createContactProperty
#[derive(Debug, Clone)]
pub enum CreateContactPropertyResponse {
///200: Successful create.
Ok(ContactPropertySuccessResponse),
///400: Bad request (e.g. invalid type).
BadRequest(ContactPropertyFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct GetComponentRequestPath {
/// The ID of the component.
#[validate(length(min = 1u64))]
pub component_id: String,
}
/// Retrieve a single component by ID.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetComponentRequest {
#[validate(nested)]
pub path: GetComponentRequestPath,
}
impl GetComponentRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<GetComponentResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<ComponentResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetComponentResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<ComponentFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(GetComponentResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetComponentResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<ComponentFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(GetComponentResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetComponentResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetComponentResponse::Unknown);
}
}
/// Response types for getComponent
#[derive(Debug, Clone)]
pub enum GetComponentResponse {
///200: Successful.
Ok(ComponentResponse),
///400: Invalid `componentId`.
BadRequest(ComponentFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///404: Component not found.
NotFound(ComponentFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateComponentRequestPath {
/// The ID of the component.
#[validate(length(min = 1u64))]
pub component_id: String,
}
/// Update a component's name and/or body. When the `lmx` body changes, the update cascades to every email using this component, and `affectedEmailCount` reports how many were affected. A change that would introduce a dynamic variable an email using the component cannot use is rejected.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateComponentRequest {
#[validate(nested)]
pub path: UpdateComponentRequestPath,
pub body: UpdateComponentBody,
}
impl UpdateComponentRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<UpdateComponentResponseEnum> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<UpdateComponentResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(UpdateComponentResponseEnum::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<ComponentFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(UpdateComponentResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(UpdateComponentResponseEnum::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<ComponentFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(UpdateComponentResponseEnum::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(UpdateComponentResponseEnum::MethodNotAllowed);
}
if status == http::StatusCode::PAYLOAD_TOO_LARGE {
let data =
oas3_gen_support::Diagnostics::<ComponentFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(UpdateComponentResponseEnum::ContentTooLarge(data));
}
if status == http::StatusCode::UNPROCESSABLE_ENTITY {
let data = oas3_gen_support::Diagnostics::<
ComponentValidationFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(UpdateComponentResponseEnum::UnprocessableEntity(data));
}
let _ = req.bytes().await?;
return Ok(UpdateComponentResponseEnum::Unknown);
}
}
/// Response types for updateComponent
#[derive(Debug, Clone)]
pub enum UpdateComponentResponseEnum {
///200: Successful.
Ok(UpdateComponentResponse),
///400: Invalid `componentId` or request body.
BadRequest(ComponentFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///404: Component not found.
NotFound(ComponentFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///413: LMX body exceeds the size limit.
ContentTooLarge(ComponentFailureResponse),
///422: Invalid LMX, or a body change that would break emails using the component.
UnprocessableEntity(ComponentValidationFailureResponse),
///default: Unknown response
Unknown,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct ListComponentsRequestQuery {
/// How many results to return in each request. Must be between 10 and 50. Default is 20.
#[serde(rename = "perPage")]
pub per_page: Option<String>,
/// A cursor to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response.
pub cursor: Option<String>,
}
/// Retrieve a paginated list of email components.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct ListComponentsRequest {
pub query: ListComponentsRequestQuery,
}
impl ListComponentsRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<ListComponentsResponseEnum> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<ListComponentsResponse>::json_with_diagnostics(req)
.await?;
return Ok(ListComponentsResponseEnum::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<ComponentFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(ListComponentsResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(ListComponentsResponseEnum::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(ListComponentsResponseEnum::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(ListComponentsResponseEnum::Unknown);
}
}
/// Response types for listComponents
#[derive(Debug, Clone)]
pub enum ListComponentsResponseEnum {
///200: Successful.
Ok(ListComponentsResponse),
///400: Invalid `perPage` value.
BadRequest(ComponentFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
/// Create a new email component from an LMX body.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct CreateComponentRequest {
#[validate(nested)]
pub body: CreateComponentBody,
}
impl CreateComponentRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<CreateComponentResponse> {
let status = req.status();
if status == http::StatusCode::CREATED {
let data =
oas3_gen_support::Diagnostics::<ComponentResponse>::json_with_diagnostics(req)
.await?;
return Ok(CreateComponentResponse::Created(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<ComponentFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(CreateComponentResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(CreateComponentResponse::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(CreateComponentResponse::MethodNotAllowed);
}
if status == http::StatusCode::PAYLOAD_TOO_LARGE {
let data =
oas3_gen_support::Diagnostics::<ComponentFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(CreateComponentResponse::ContentTooLarge(data));
}
if status == http::StatusCode::UNPROCESSABLE_ENTITY {
let data =
oas3_gen_support::Diagnostics::<ComponentFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(CreateComponentResponse::UnprocessableEntity(data));
}
let _ = req.bytes().await?;
return Ok(CreateComponentResponse::Unknown);
}
}
/// Response types for createComponent
#[derive(Debug, Clone)]
pub enum CreateComponentResponse {
///201: Component created.
Created(ComponentResponse),
///400: Invalid request body.
BadRequest(ComponentFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///405: Wrong HTTP request method.
MethodNotAllowed,
///413: LMX body exceeds the size limit.
ContentTooLarge(ComponentFailureResponse),
///422: Invalid LMX.
UnprocessableEntity(ComponentFailureResponse),
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct GetEmailMessageRequestPath {
/// The ID of the email message.
#[validate(length(min = 1u64))]
pub email_message_id: String,
}
/// Retrieve an email message, including its compiled LMX content.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetEmailMessageRequest {
#[validate(nested)]
pub path: GetEmailMessageRequestPath,
}
impl GetEmailMessageRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<GetEmailMessageResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<EmailMessageResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetEmailMessageResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
EmailMessageFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetEmailMessageResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetEmailMessageResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data = oas3_gen_support::Diagnostics::<
EmailMessageFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetEmailMessageResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetEmailMessageResponse::MethodNotAllowed);
}
if status == http::StatusCode::CONFLICT {
let data = oas3_gen_support::Diagnostics::<
EmailMessageFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetEmailMessageResponse::Conflict(data));
}
let _ = req.bytes().await?;
return Ok(GetEmailMessageResponse::Unknown);
}
}
/// Response types for getEmailMessage
#[derive(Debug, Clone)]
pub enum GetEmailMessageResponse {
///200: Successful.
Ok(EmailMessageResponse),
///400: Invalid `emailMessageId` or no sending domain configured.
BadRequest(EmailMessageFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///404: Email message not found.
NotFound(EmailMessageFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///409: Email message uses MJML format or content cannot be parsed.
Conflict(EmailMessageFailureResponse),
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateEmailMessageRequestParamsPath {
/// The ID of the email message.
#[validate(length(min = 1u64))]
pub email_message_id: String,
}
/// Update fields on an email message (subject, preview text, sender, LMX content). The campaign must be in draft status. Supply `expectedRevisionId` matching the current `contentRevisionId` — the server rejects mismatched revisions with 409.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateEmailMessageRequestParams {
#[validate(nested)]
pub path: UpdateEmailMessageRequestParamsPath,
pub body: UpdateEmailMessageRequest,
}
impl UpdateEmailMessageRequestParams {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<UpdateEmailMessageResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<EmailMessageResponse>::json_with_diagnostics(req)
.await?;
return Ok(UpdateEmailMessageResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
EmailMessageFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(UpdateEmailMessageResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(UpdateEmailMessageResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data = oas3_gen_support::Diagnostics::<
EmailMessageFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(UpdateEmailMessageResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(UpdateEmailMessageResponse::MethodNotAllowed);
}
if status == http::StatusCode::CONFLICT {
let data = oas3_gen_support::Diagnostics::<
EmailMessageFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(UpdateEmailMessageResponse::Conflict(data));
}
if status == http::StatusCode::PAYLOAD_TOO_LARGE {
let data = oas3_gen_support::Diagnostics::<
EmailMessageFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(UpdateEmailMessageResponse::ContentTooLarge(data));
}
if status == http::StatusCode::UNPROCESSABLE_ENTITY {
let data = oas3_gen_support::Diagnostics::<
EmailMessageFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(UpdateEmailMessageResponse::UnprocessableEntity(data));
}
let _ = req.bytes().await?;
return Ok(UpdateEmailMessageResponse::Unknown);
}
}
/// Response types for updateEmailMessage
#[derive(Debug, Clone)]
pub enum UpdateEmailMessageResponse {
///200: Email message updated.
Ok(EmailMessageResponse),
///400: Invalid request body.
BadRequest(EmailMessageFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///404: Email message not found.
NotFound(EmailMessageFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///409: Campaign is not in draft status, `contentRevisionId` is stale, content cannot be parsed, or email message uses MJML format.
Conflict(EmailMessageFailureResponse),
///413: LMX payload exceeds the 100KB limit.
ContentTooLarge(EmailMessageFailureResponse),
///422: LMX failed to compile.
UnprocessableEntity(EmailMessageFailureResponse),
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct PreviewEmailMessageRequestPath {
/// The ID of the email message.
#[validate(length(min = 1u64))]
pub email_message_id: String,
}
/// Send a test preview of an email message to one or more addresses. The accepted variable fields depend on the parent's type - campaign previews accept `contactProperties`, workflow previews accept `contactProperties` and `eventProperties`, and transactional previews accept `dataVariables`. Supplying a field the parent cannot reference is rejected with 400.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct PreviewEmailMessageRequest {
#[validate(nested)]
pub path: PreviewEmailMessageRequestPath,
#[validate(nested)]
pub body: EmailMessagePreviewRequest,
}
impl PreviewEmailMessageRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<PreviewEmailMessageResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data = oas3_gen_support::Diagnostics::<
EmailMessagePreviewResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(PreviewEmailMessageResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
EmailMessageFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(PreviewEmailMessageResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(PreviewEmailMessageResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data = oas3_gen_support::Diagnostics::<
EmailMessageFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(PreviewEmailMessageResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(PreviewEmailMessageResponse::MethodNotAllowed);
}
if status == http::StatusCode::TOO_MANY_REQUESTS {
let data = oas3_gen_support::Diagnostics::<
EmailMessageFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(PreviewEmailMessageResponse::TooManyRequests(data));
}
let _ = req.bytes().await?;
return Ok(PreviewEmailMessageResponse::Unknown);
}
}
/// Response types for previewEmailMessage
#[derive(Debug, Clone)]
pub enum PreviewEmailMessageResponse {
///200: Preview scheduled.
Ok(EmailMessagePreviewResponse),
///400: Invalid request body, or a variable field the parent cannot reference.
BadRequest(EmailMessageFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///404: Email message not found.
NotFound(EmailMessageFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///429: The daily preview limit was reached.
TooManyRequests(EmailMessageFailureResponse),
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct GetEmailMessageGuardianRequestPath {
/// The ID of the email message.
#[validate(length(min = 1u64))]
pub email_message_id: String,
}
/// Validate an email message's content against Guardian rules and return any errors and warnings. Errors must be resolved before the email can be published, warnings are advisory.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetEmailMessageGuardianRequest {
#[validate(nested)]
pub path: GetEmailMessageGuardianRequestPath,
}
impl GetEmailMessageGuardianRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<GetEmailMessageGuardianResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data = oas3_gen_support::Diagnostics::<
EmailMessageGuardianResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetEmailMessageGuardianResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
EmailMessageFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetEmailMessageGuardianResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetEmailMessageGuardianResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data = oas3_gen_support::Diagnostics::<
EmailMessageFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetEmailMessageGuardianResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetEmailMessageGuardianResponse::MethodNotAllowed);
}
if status == http::StatusCode::CONFLICT {
let data = oas3_gen_support::Diagnostics::<
EmailMessageFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetEmailMessageGuardianResponse::Conflict(data));
}
let _ = req.bytes().await?;
return Ok(GetEmailMessageGuardianResponse::Unknown);
}
}
/// Response types for getEmailMessageGuardian
#[derive(Debug, Clone)]
pub enum GetEmailMessageGuardianResponse {
///200: Successful.
Ok(EmailMessageGuardianResponse),
///400: Invalid `emailMessageId`.
BadRequest(EmailMessageFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///404: Email message not found.
NotFound(EmailMessageFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///409: Email message uses MJML format.
Conflict(EmailMessageFailureResponse),
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct SendEventRequestHeader {
/// Include a unique ID for this request (maximum 100 characters) to avoid duplicate emails.
///
/// The value should be a string of up to 100 characters and should be unique for each request. We recommend using V4 UUIDs or some other method with enough guaranteed entropy to avoid collisions during a 24 hour window.
///
/// This endpoint will return a `409 Conflict` response if the idempotency key has been used in the previous 24 hours.
#[validate(length(max = 100u64))]
pub idempotency_key: Option<String>,
}
impl core::convert::TryFrom<&SendEventRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(headers: &SendEventRequestHeader) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(1usize);
if let Some(value) = &headers.idempotency_key {
let header_value = http::HeaderValue::try_from(value)?;
map.insert(IDEMPOTENCY_KEY, header_value);
}
Ok(map)
}
}
impl core::convert::TryFrom<SendEventRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(headers: SendEventRequestHeader) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Send events to trigger workflows.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct SendEventRequest {
#[validate(nested)]
pub header: SendEventRequestHeader,
/// Provide either `email` or `userId` to identify the contact ([read more](https://loops.so/docs/api-reference/send-event#body)).<br>Event properties will be available in emails sent by this event. Values of properties can be of type `string`, `number`, `boolean` or `date` ([see allowed date formats](https://loops.so/docs/events/properties#important-information-about-event-properties)).<br>Make sure to create the properties in Loops before using them in API calls.<br>You can add update the contact by adding contact properties as keys in this request (of type `string`, `number`, `boolean` or `date` ([see available date formats](https://loops.so/docs/contacts/properties#dates))).
pub body: EventRequest,
}
impl SendEventRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<SendEventResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<EventSuccessResponse>::json_with_diagnostics(req)
.await?;
return Ok(SendEventResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<EventFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(SendEventResponse::BadRequest(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(SendEventResponse::MethodNotAllowed);
}
if status == http::StatusCode::CONFLICT {
let data = oas3_gen_support::Diagnostics::<
IdempotencyKeyFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(SendEventResponse::Conflict(data));
}
let _ = req.bytes().await?;
return Ok(SendEventResponse::Unknown);
}
}
/// Response types for sendEvent
#[derive(Debug, Clone)]
pub enum SendEventResponse {
///200: Successful send.
Ok(EventSuccessResponse),
///400: Bad request (e.g. `eventName` is missing).
BadRequest(EventFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///409: Idempotency key has been used.
Conflict(IdempotencyKeyFailureResponse),
///default: Unknown response
Unknown,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct ListEventPatternsRequestQuery {
/// How many results to return in each request. Must be between 10 and 50. Default is 20.
#[serde(rename = "perPage")]
pub per_page: Option<String>,
/// A cursor to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response.
pub cursor: Option<String>,
}
/// Retrieve a paginated list of event patterns available to workflow event trigger nodes.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct ListEventPatternsRequest {
pub query: ListEventPatternsRequestQuery,
}
impl ListEventPatternsRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<ListEventPatternsResponseEnum> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<ListEventPatternsResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(ListEventPatternsResponseEnum::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
EventPatternFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(ListEventPatternsResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(ListEventPatternsResponseEnum::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(ListEventPatternsResponseEnum::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(ListEventPatternsResponseEnum::Unknown);
}
}
/// Response types for listEventPatterns
#[derive(Debug, Clone)]
pub enum ListEventPatternsResponseEnum {
///200: Successful.
Ok(ListEventPatternsResponse),
///400: Invalid `perPage` or `cursor` value.
BadRequest(EventPatternFailureResponse),
///401: Invalid API key.
Unauthorized,
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct GetEventPatternByNameRequestPath {
/// The exact event name. Event names are case-sensitive and should be URL-encoded if they contain special characters.
#[validate(length(min = 1u64))]
pub event_name: String,
}
/// Retrieve event pattern details by event name for a workflow event trigger. Event names are case-sensitive, so `PaymentReceived` and `paymentReceived` are different events.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetEventPatternByNameRequest {
#[validate(nested)]
pub path: GetEventPatternByNameRequestPath,
}
impl GetEventPatternByNameRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<GetEventPatternResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<EventPattern>::json_with_diagnostics(req).await?;
return Ok(GetEventPatternResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
EventPatternFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetEventPatternResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetEventPatternResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data = oas3_gen_support::Diagnostics::<
EventPatternFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetEventPatternResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetEventPatternResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetEventPatternResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct GetEventPatternRequestPath {
/// The ID of the event pattern.
#[validate(length(min = 1u64))]
pub event_pattern_id: String,
}
/// Retrieve event pattern details for a workflow event trigger.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetEventPatternRequest {
#[validate(nested)]
pub path: GetEventPatternRequestPath,
}
impl GetEventPatternRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<GetEventPatternResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<EventPattern>::json_with_diagnostics(req).await?;
return Ok(GetEventPatternResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
EventPatternFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetEventPatternResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetEventPatternResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data = oas3_gen_support::Diagnostics::<
EventPatternFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetEventPatternResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetEventPatternResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetEventPatternResponse::Unknown);
}
}
/// Response types for getEventPattern
#[derive(Debug, Clone)]
pub enum GetEventPatternResponse {
///200: Successful.
Ok(EventPattern),
///400: Invalid `eventPatternId`.
BadRequest(EventPatternFailureResponse),
///401: Invalid API key.
Unauthorized,
///404: Event pattern not found.
NotFound(EventPatternFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
/// Retrieve a list of your account's mailing lists.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct ListMailingListsRequest {}
impl ListMailingListsRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<ListMailingListsResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data = oas3_gen_support::Diagnostics::<List200Response>::json_with_diagnostics(req)
.await?;
return Ok(ListMailingListsResponse::Ok(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(ListMailingListsResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(ListMailingListsResponse::Unknown);
}
}
/// Response types for listMailingLists
#[derive(Debug, Clone)]
pub enum ListMailingListsResponse {
///200: Successful.
Ok(List200Response),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct GetThemeRequestPath {
/// The ID of the theme.
#[validate(length(min = 1u64))]
pub theme_id: String,
}
/// Retrieve a single theme by ID.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetThemeRequest {
#[validate(nested)]
pub path: GetThemeRequestPath,
}
impl GetThemeRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<GetThemeResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<ThemeResponse>::json_with_diagnostics(req).await?;
return Ok(GetThemeResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<ThemeFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetThemeResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetThemeResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<ThemeFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetThemeResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetThemeResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetThemeResponse::Unknown);
}
}
/// Response types for getTheme
#[derive(Debug, Clone)]
pub enum GetThemeResponse {
///200: Successful.
Ok(ThemeResponse),
///400: Invalid `themeId`.
BadRequest(ThemeFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///404: Theme not found.
NotFound(ThemeFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateThemeRequestPath {
/// The ID of the theme.
#[validate(length(min = 1u64))]
pub theme_id: String,
}
/// Update a theme's name and/or styles. When `styles` change, the update cascades to every email using this theme, and `affectedEmailCount` in the response reports how many emails were affected. Manual style edits made on individual emails are preserved: the cascade only changes properties an email has not overridden. A per-email override is removed only when it becomes identical to the theme's new value, after which that email follows the theme for that property.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateThemeRequest {
#[validate(nested)]
pub path: UpdateThemeRequestPath,
pub body: UpdateThemeBody,
}
impl UpdateThemeRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<UpdateThemeResponseEnum> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<UpdateThemeResponse>::json_with_diagnostics(req)
.await?;
return Ok(UpdateThemeResponseEnum::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<ThemeFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(UpdateThemeResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(UpdateThemeResponseEnum::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<ThemeFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(UpdateThemeResponseEnum::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(UpdateThemeResponseEnum::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(UpdateThemeResponseEnum::Unknown);
}
}
/// Response types for updateTheme
#[derive(Debug, Clone)]
pub enum UpdateThemeResponseEnum {
///200: Successful.
Ok(UpdateThemeResponse),
///400: Invalid `themeId` or request body.
BadRequest(ThemeFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///404: Theme not found.
NotFound(ThemeFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct ListThemesRequestQuery {
/// How many results to return in each request. Must be between 10 and 50. Default is 20.
#[serde(rename = "perPage")]
pub per_page: Option<String>,
/// A cursor to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response.
pub cursor: Option<String>,
}
/// Retrieve a paginated list of email themes, most recently created first.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct ListThemesRequest {
pub query: ListThemesRequestQuery,
}
impl ListThemesRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<ListThemesResponseEnum> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<ListThemesResponse>::json_with_diagnostics(req)
.await?;
return Ok(ListThemesResponseEnum::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<ThemeFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(ListThemesResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(ListThemesResponseEnum::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(ListThemesResponseEnum::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(ListThemesResponseEnum::Unknown);
}
}
/// Response types for listThemes
#[derive(Debug, Clone)]
pub enum ListThemesResponseEnum {
///200: Successful.
Ok(ListThemesResponse),
///400: Invalid `perPage` value.
BadRequest(ThemeFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
/// Create a new email theme for use across Loops emails.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct CreateThemeRequest {
#[validate(nested)]
pub body: CreateThemeBody,
}
impl CreateThemeRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<CreateThemeResponse> {
let status = req.status();
if status == http::StatusCode::CREATED {
let data =
oas3_gen_support::Diagnostics::<ThemeResponse>::json_with_diagnostics(req).await?;
return Ok(CreateThemeResponse::Created(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<ThemeFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(CreateThemeResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(CreateThemeResponse::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(CreateThemeResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(CreateThemeResponse::Unknown);
}
}
/// Response types for createTheme
#[derive(Debug, Clone)]
pub enum CreateThemeResponse {
///201: Theme created.
Created(ThemeResponse),
///400: Invalid request body.
BadRequest(ThemeFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct ListPublishedTransactionalEmailsRequestQuery {
/// How many results to return in each request. Must be between 10 and 50. Default is 20.
#[serde(rename = "perPage")]
pub per_page: Option<String>,
/// A cursor, to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response.
pub cursor: Option<String>,
}
/// Get a list of published transactional emails.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct ListPublishedTransactionalEmailsRequest {
pub query: ListPublishedTransactionalEmailsRequestQuery,
}
impl ListPublishedTransactionalEmailsRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<ListPublishedTransactionalEmailsResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<ListTransactionalsResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(ListPublishedTransactionalEmailsResponse::Ok(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(ListPublishedTransactionalEmailsResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(ListPublishedTransactionalEmailsResponse::Unknown);
}
}
/// Response types for listPublishedTransactionalEmails
#[derive(Debug, Clone)]
pub enum ListPublishedTransactionalEmailsResponse {
///200: Successful.
Ok(ListTransactionalsResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct SendTransactionalEmailRequestHeader {
/// Include a unique ID for this request (maximum 100 characters) to avoid duplicate emails.
///
/// The value should be a string of up to 100 characters and should be unique for each request. We recommend using V4 UUIDs or some other method with enough guaranteed entropy to avoid collisions during a 24 hour window.
///
/// This endpoint will return a `409 Conflict` response if the idempotency key has been used in the previous 24 hours.
#[validate(length(max = 100u64))]
pub idempotency_key: Option<String>,
}
impl core::convert::TryFrom<&SendTransactionalEmailRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &SendTransactionalEmailRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(1usize);
if let Some(value) = &headers.idempotency_key {
let header_value = http::HeaderValue::try_from(value)?;
map.insert(IDEMPOTENCY_KEY, header_value);
}
Ok(map)
}
}
impl core::convert::TryFrom<SendTransactionalEmailRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: SendTransactionalEmailRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Send a transactional email to a contact.<br>Please [email us](mailto:help@loops.so) to enable attachments on your account before using them with the API.
///
/// To set dynamic Subject, From, Reply to, CC, BCC email header fields, add data variables to those fields in the editor, then include data for each variable in the API request. Read our transactional email guide for more details.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct SendTransactionalEmailRequest {
#[validate(nested)]
pub header: SendTransactionalEmailRequestHeader,
#[validate(nested)]
pub body: TransactionalRequest,
}
impl SendTransactionalEmailRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<SendTransactionalEmailResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data = oas3_gen_support::Diagnostics::<
TransactionalSuccessResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(SendTransactionalEmailResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<Transactional400Response>::json_with_diagnostics(
req,
)
.await?;
return Ok(SendTransactionalEmailResponse::BadRequest(data));
}
if status == http::StatusCode::NOT_FOUND {
let data = oas3_gen_support::Diagnostics::<
TransactionalFailure3Response,
>::json_with_diagnostics(req)
.await?;
return Ok(SendTransactionalEmailResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(SendTransactionalEmailResponse::MethodNotAllowed);
}
if status == http::StatusCode::CONFLICT {
let data = oas3_gen_support::Diagnostics::<
IdempotencyKeyFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(SendTransactionalEmailResponse::Conflict(data));
}
let _ = req.bytes().await?;
return Ok(SendTransactionalEmailResponse::Unknown);
}
}
/// Response types for sendTransactionalEmail
#[derive(Debug, Clone)]
pub enum SendTransactionalEmailResponse {
///200: Successful send.
Ok(TransactionalSuccessResponse),
///400: Bad request (e.g. transactional email is not published).
BadRequest(Transactional400Response),
///404: Transactional email not found.
NotFound(TransactionalFailure3Response),
///405: Wrong HTTP request method.
MethodNotAllowed,
///409: Idempotency key has been used.
Conflict(IdempotencyKeyFailureResponse),
///default: Unknown response
Unknown,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct ListTransactionalEmailsRequestQuery {
/// How many results to return in each request. Must be between 10 and 50. Default is 20.
#[serde(rename = "perPage")]
pub per_page: Option<String>,
/// A cursor to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response.
pub cursor: Option<String>,
}
/// Retrieve a paginated list of transactional emails, most recently created first.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct ListTransactionalEmailsRequest {
pub query: ListTransactionalEmailsRequestQuery,
}
impl ListTransactionalEmailsRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<ListTransactionalEmailsResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data = oas3_gen_support::Diagnostics::<
ListTransactionalsResourceResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(ListTransactionalEmailsResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
TransactionalFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(ListTransactionalEmailsResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(ListTransactionalEmailsResponse::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(ListTransactionalEmailsResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(ListTransactionalEmailsResponse::Unknown);
}
}
/// Response types for listTransactionalEmails
#[derive(Debug, Clone)]
pub enum ListTransactionalEmailsResponse {
///200: Successful.
Ok(ListTransactionalsResourceResponse),
///400: Invalid `perPage` value.
BadRequest(TransactionalFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
/// Create a new transactional email. An empty draft email message is created automatically and its `draftEmailMessageId` is returned. Use the `POST /v1/email-messages/{emailMessageId}` endpoint along with the returned `draftEmailMessageContentRevisionId` to set subject, sender, preview text, and LMX content, then call `POST /v1/transactional-emails/{transactionalId}/publish` to publish the draft.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct CreateTransactionalEmailRequest {
#[validate(nested)]
pub body: CreateTransactionalRequest,
}
impl CreateTransactionalEmailRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<CreateTransactionalEmailResponse> {
let status = req.status();
if status == http::StatusCode::CREATED {
let data =
oas3_gen_support::Diagnostics::<TransactionalDraftResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(CreateTransactionalEmailResponse::Created(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
TransactionalFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(CreateTransactionalEmailResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(CreateTransactionalEmailResponse::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(CreateTransactionalEmailResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(CreateTransactionalEmailResponse::Unknown);
}
}
/// Response types for createTransactionalEmail
#[derive(Debug, Clone)]
pub enum CreateTransactionalEmailResponse {
///201: Transactional email created.
Created(TransactionalDraftResponse),
///400: Invalid request body or no sending domain configured.
BadRequest(TransactionalFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct GetTransactionalEmailRequestPath {
/// The ID of the transactional email.
#[validate(length(min = 1u64))]
pub transactional_id: String,
}
/// Retrieve a single transactional email by ID.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetTransactionalEmailRequest {
#[validate(nested)]
pub path: GetTransactionalEmailRequestPath,
}
impl GetTransactionalEmailRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<GetTransactionalEmailResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<TransactionalResource>::json_with_diagnostics(req)
.await?;
return Ok(GetTransactionalEmailResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
TransactionalFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetTransactionalEmailResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetTransactionalEmailResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data = oas3_gen_support::Diagnostics::<
TransactionalFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetTransactionalEmailResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetTransactionalEmailResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetTransactionalEmailResponse::Unknown);
}
}
/// Response types for getTransactionalEmail
#[derive(Debug, Clone)]
pub enum GetTransactionalEmailResponse {
///200: Successful.
Ok(TransactionalResource),
///400: Invalid `transactionalId`.
BadRequest(TransactionalFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///404: Transactional email not found.
NotFound(TransactionalFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateTransactionalEmailRequestPath {
/// The ID of the transactional email.
#[validate(length(min = 1u64))]
pub transactional_id: String,
}
/// Update a transactional email's name or group. At least one field must be provided.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateTransactionalEmailRequest {
#[validate(nested)]
pub path: UpdateTransactionalEmailRequestPath,
pub body: UpdateTransactionalRequest,
}
impl UpdateTransactionalEmailRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<GetTransactionalEmailResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<TransactionalResource>::json_with_diagnostics(req)
.await?;
return Ok(GetTransactionalEmailResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
TransactionalFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetTransactionalEmailResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetTransactionalEmailResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data = oas3_gen_support::Diagnostics::<
TransactionalFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetTransactionalEmailResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetTransactionalEmailResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetTransactionalEmailResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct GetTransactionalEmailMetricsRequestPath {
/// The ID of the transactional email.
#[validate(length(min = 1u64))]
pub transactional_id: String,
}
/// Retrieve all-time delivery metrics for a transactional email, totalled across every published version.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetTransactionalEmailMetricsRequest {
#[validate(nested)]
pub path: GetTransactionalEmailMetricsRequestPath,
}
impl GetTransactionalEmailMetricsRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<GetTransactionalEmailMetricsResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data = oas3_gen_support::Diagnostics::<
TransactionalMetricsResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetTransactionalEmailMetricsResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
TransactionalFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetTransactionalEmailMetricsResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetTransactionalEmailMetricsResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data = oas3_gen_support::Diagnostics::<
TransactionalFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(GetTransactionalEmailMetricsResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetTransactionalEmailMetricsResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetTransactionalEmailMetricsResponse::Unknown);
}
}
/// Response types for getTransactionalEmailMetrics
#[derive(Debug, Clone)]
pub enum GetTransactionalEmailMetricsResponse {
///200: Successful.
Ok(TransactionalMetricsResponse),
///400: Invalid `transactionalId`.
BadRequest(TransactionalFailureResponse),
///401: Invalid API key.
Unauthorized,
///404: Transactional email not found.
NotFound(TransactionalFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct EnsureTransactionalDraftRequestPath {
/// The ID of the transactional email.
#[validate(length(min = 1u64))]
pub transactional_id: String,
}
/// Ensure the transactional email has a draft email message. If a draft already exists it is returned unchanged; otherwise a new empty draft is created (seeded from the most recent published version when present). Use `POST /v1/email-messages/{emailMessageId}` to edit the draft's content.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct EnsureTransactionalDraftRequest {
#[validate(nested)]
pub path: EnsureTransactionalDraftRequestPath,
}
impl EnsureTransactionalDraftRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<EnsureTransactionalDraftResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<TransactionalDraftResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(EnsureTransactionalDraftResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
TransactionalFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(EnsureTransactionalDraftResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(EnsureTransactionalDraftResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data = oas3_gen_support::Diagnostics::<
TransactionalFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(EnsureTransactionalDraftResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(EnsureTransactionalDraftResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(EnsureTransactionalDraftResponse::Unknown);
}
}
/// Response types for ensureTransactionalDraft
#[derive(Debug, Clone)]
pub enum EnsureTransactionalDraftResponse {
///200: Draft ready.
Ok(TransactionalDraftResponse),
///400: Invalid `transactionalId` or no sending domain configured.
BadRequest(TransactionalFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///404: Transactional email not found.
NotFound(TransactionalFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct PublishTransactionalEmailRequestPath {
/// The ID of the transactional email.
#[validate(length(min = 1u64))]
pub transactional_id: String,
}
/// Publish the transactional email's current draft email message. The draft becomes the published version and the draft is cleared.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct PublishTransactionalEmailRequest {
#[validate(nested)]
pub path: PublishTransactionalEmailRequestPath,
}
impl PublishTransactionalEmailRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<PublishTransactionalEmailResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<TransactionalResource>::json_with_diagnostics(req)
.await?;
return Ok(PublishTransactionalEmailResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data = oas3_gen_support::Diagnostics::<
TransactionalFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(PublishTransactionalEmailResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(PublishTransactionalEmailResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data = oas3_gen_support::Diagnostics::<
TransactionalFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(PublishTransactionalEmailResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(PublishTransactionalEmailResponse::MethodNotAllowed);
}
if status == http::StatusCode::CONFLICT {
let data = oas3_gen_support::Diagnostics::<
TransactionalFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(PublishTransactionalEmailResponse::Conflict(data));
}
if status == http::StatusCode::UNPROCESSABLE_ENTITY {
let data = oas3_gen_support::Diagnostics::<
TransactionalFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(PublishTransactionalEmailResponse::UnprocessableEntity(data));
}
let _ = req.bytes().await?;
return Ok(PublishTransactionalEmailResponse::Unknown);
}
}
/// Response types for publishTransactionalEmail
#[derive(Debug, Clone)]
pub enum PublishTransactionalEmailResponse {
///200: Transactional email published.
Ok(TransactionalResource),
///400: Invalid `transactionalId`.
BadRequest(TransactionalFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///404: Transactional email not found.
NotFound(TransactionalFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///409: No draft to publish.
Conflict(TransactionalFailureResponse),
///422: Draft failed validation, sending domain is not verified, or content was flagged as unsafe.
UnprocessableEntity(TransactionalFailureResponse),
///default: Unknown response
Unknown,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct ListTransactionalGroupsRequestQuery {
/// How many results to return in each request. Must be between 10 and 50. Default is 20.
#[serde(rename = "perPage")]
pub per_page: Option<String>,
/// A cursor to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response.
pub cursor: Option<String>,
}
/// Retrieve a paginated list of transactional groups, most recently created first.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct ListTransactionalGroupsRequest {
pub query: ListTransactionalGroupsRequestQuery,
}
impl ListTransactionalGroupsRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<ListCampaignGroupsResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<ListGroupsResponse>::json_with_diagnostics(req)
.await?;
return Ok(ListCampaignGroupsResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(ListCampaignGroupsResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(ListCampaignGroupsResponse::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(ListCampaignGroupsResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(ListCampaignGroupsResponse::Unknown);
}
}
/// Create a new transactional group.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct CreateTransactionalGroupRequest {
#[validate(nested)]
pub body: CreateGroupRequest,
}
impl CreateTransactionalGroupRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<CreateCampaignGroupResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<GroupResponse>::json_with_diagnostics(req).await?;
return Ok(CreateCampaignGroupResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(CreateCampaignGroupResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(CreateCampaignGroupResponse::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(CreateCampaignGroupResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(CreateCampaignGroupResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct GetTransactionalGroupRequestPath {
/// The ID of the transactional group.
#[validate(length(min = 1u64))]
pub transactional_group_id: String,
}
/// Retrieve a single transactional group by ID.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetTransactionalGroupRequest {
#[validate(nested)]
pub path: GetTransactionalGroupRequestPath,
}
impl GetTransactionalGroupRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<GetCampaignGroupResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<GroupResponse>::json_with_diagnostics(req).await?;
return Ok(GetCampaignGroupResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetCampaignGroupResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetCampaignGroupResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateTransactionalGroupRequestPath {
/// The ID of the transactional group.
#[validate(length(min = 1u64))]
pub transactional_group_id: String,
}
/// Update a transactional group's name or description. At least one field must be provided. The reserved "Unsorted" group cannot be edited.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateTransactionalGroupRequest {
#[validate(nested)]
pub path: UpdateTransactionalGroupRequestPath,
pub body: UpdateGroupRequest,
}
impl UpdateTransactionalGroupRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<GetCampaignGroupResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<GroupResponse>::json_with_diagnostics(req).await?;
return Ok(GetCampaignGroupResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetCampaignGroupResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetCampaignGroupResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::Unknown);
}
}
/// Request a pre-signed URL to upload an image asset. Upload the file with an HTTP `PUT` to the returned `presignedUrl` (sending the same `Content-Type` and `Content-Length`), then call `/uploads/{emailAssetId}/complete` to finalize the asset.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct CreateUploadRequestParams {
#[validate(nested)]
pub body: CreateUploadRequest,
}
impl CreateUploadRequestParams {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<CreateUploadResponseEnum> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<CreateUploadResponse>::json_with_diagnostics(req)
.await?;
return Ok(CreateUploadResponseEnum::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<UploadFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(CreateUploadResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(CreateUploadResponseEnum::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(CreateUploadResponseEnum::MethodNotAllowed);
}
if status == http::StatusCode::PAYLOAD_TOO_LARGE {
let data =
oas3_gen_support::Diagnostics::<UploadFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(CreateUploadResponseEnum::ContentTooLarge(data));
}
let _ = req.bytes().await?;
return Ok(CreateUploadResponseEnum::Unknown);
}
}
/// Response types for createUpload
#[derive(Debug, Clone)]
pub enum CreateUploadResponseEnum {
///200: Pre-signed upload URL created.
Ok(CreateUploadResponse),
///400: Invalid request body or unsupported `contentType`.
BadRequest(UploadFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///405: Wrong HTTP request method.
MethodNotAllowed,
///413: Upload exceeds the maximum allowed size.
ContentTooLarge(UploadFailureResponse),
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct CompleteUploadRequestPath {
/// The `emailAssetId` returned when the upload was created via `POST /v1/uploads`.
#[validate(length(min = 1u64))]
pub email_asset_id: String,
}
/// Finalize an image upload after the file has been uploaded to the pre-signed URL. Returns the public URL of the uploaded image asset.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct CompleteUploadRequest {
#[validate(nested)]
pub path: CompleteUploadRequestPath,
}
impl CompleteUploadRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<CompleteUploadResponseEnum> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<CompleteUploadResponse>::json_with_diagnostics(req)
.await?;
return Ok(CompleteUploadResponseEnum::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<UploadFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(CompleteUploadResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(CompleteUploadResponseEnum::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<UploadFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(CompleteUploadResponseEnum::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(CompleteUploadResponseEnum::MethodNotAllowed);
}
if status == http::StatusCode::TOO_MANY_REQUESTS {
let data = oas3_gen_support::Diagnostics::<
UploadLimitExceededFailureResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(CompleteUploadResponseEnum::TooManyRequests(data));
}
let _ = req.bytes().await?;
return Ok(CompleteUploadResponseEnum::Unknown);
}
}
/// Response types for completeUpload
#[derive(Debug, Clone)]
pub enum CompleteUploadResponseEnum {
///200: Upload completed.
Ok(CompleteUploadResponse),
///400: Upload id is missing or the uploaded file has an unsupported content type.
BadRequest(UploadFailureResponse),
///401: Invalid API key or content API not enabled for this team.
Unauthorized,
///404: Upload not found.
NotFound(UploadFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///429: Upload limit exceeded.
TooManyRequests(UploadLimitExceededFailureResponse),
///default: Unknown response
Unknown,
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct ListWorkflowGroupsRequestQuery {
/// How many results to return in each request. Must be between 10 and 50. Default is 20.
#[serde(rename = "perPage")]
pub per_page: Option<String>,
/// A cursor to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response.
pub cursor: Option<String>,
}
/// Retrieve a paginated list of workflow groups, most recently created first.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct ListWorkflowGroupsRequest {
pub query: ListWorkflowGroupsRequestQuery,
}
impl ListWorkflowGroupsRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<ListCampaignGroupsResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<ListGroupsResponse>::json_with_diagnostics(req)
.await?;
return Ok(ListCampaignGroupsResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(ListCampaignGroupsResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(ListCampaignGroupsResponse::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(ListCampaignGroupsResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(ListCampaignGroupsResponse::Unknown);
}
}
/// Create a new workflow group.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct CreateWorkflowGroupRequest {
#[validate(nested)]
pub body: CreateGroupRequest,
}
impl CreateWorkflowGroupRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<CreateCampaignGroupResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<GroupResponse>::json_with_diagnostics(req).await?;
return Ok(CreateCampaignGroupResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(CreateCampaignGroupResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(CreateCampaignGroupResponse::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(CreateCampaignGroupResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(CreateCampaignGroupResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct GetWorkflowGroupRequestPath {
/// The ID of the workflow group.
#[validate(length(min = 1u64))]
pub workflow_group_id: String,
}
/// Retrieve a single workflow group by ID.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetWorkflowGroupRequest {
#[validate(nested)]
pub path: GetWorkflowGroupRequestPath,
}
impl GetWorkflowGroupRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<GetCampaignGroupResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<GroupResponse>::json_with_diagnostics(req).await?;
return Ok(GetCampaignGroupResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetCampaignGroupResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetCampaignGroupResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateWorkflowGroupRequestPath {
/// The ID of the workflow group.
#[validate(length(min = 1u64))]
pub workflow_group_id: String,
}
/// Update a workflow group's name or description. At least one field must be provided. The reserved "Unsorted" group cannot be edited.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateWorkflowGroupRequest {
#[validate(nested)]
pub path: UpdateWorkflowGroupRequestPath,
pub body: UpdateGroupRequest,
}
impl UpdateWorkflowGroupRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<GetCampaignGroupResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<GroupResponse>::json_with_diagnostics(req).await?;
return Ok(GetCampaignGroupResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetCampaignGroupResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<GroupFailureResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetCampaignGroupResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetCampaignGroupResponse::Unknown);
}
}
#[serde_with::skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, oas3_gen_support::Default)]
pub struct ListWorkflowsRequestQuery {
/// How many results to return in each request. Must be between 10 and 50. Default is 20.
#[serde(rename = "perPage")]
pub per_page: Option<String>,
/// A cursor to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response.
pub cursor: Option<String>,
}
/// Retrieve a paginated list of workflows.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct ListWorkflowsRequest {
pub query: ListWorkflowsRequestQuery,
}
impl ListWorkflowsRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<ListWorkflowsResponseEnum> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<ListWorkflowsResponse>::json_with_diagnostics(req)
.await?;
return Ok(ListWorkflowsResponseEnum::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(ListWorkflowsResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(ListWorkflowsResponseEnum::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(ListWorkflowsResponseEnum::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(ListWorkflowsResponseEnum::Unknown);
}
}
/// Response types for listWorkflows
#[derive(Debug, Clone)]
pub enum ListWorkflowsResponseEnum {
///200: Successful.
Ok(ListWorkflowsResponse),
///400: Invalid `perPage` or `cursor` value.
BadRequest(WorkflowFailureResponse),
///401: Invalid API key.
Unauthorized,
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
/// Create a draft workflow with a blank trigger and exit node. When `workflowGroupId` is omitted, the workflow is added to the team's Unsorted group.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct CreateWorkflowRequestParams {
#[validate(nested)]
pub body: CreateWorkflowRequest,
}
impl CreateWorkflowRequestParams {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<CreateWorkflowResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<SimplifiedWorkflow>::json_with_diagnostics(req)
.await?;
return Ok(CreateWorkflowResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(CreateWorkflowResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(CreateWorkflowResponse::Unauthorized);
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(CreateWorkflowResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(CreateWorkflowResponse::Unknown);
}
}
/// Response types for createWorkflow
#[derive(Debug, Clone)]
pub enum CreateWorkflowResponse {
///200: Workflow created.
Ok(SimplifiedWorkflow),
///400: Invalid request body or workflow group not found.
BadRequest(WorkflowFailureResponse),
///401: Invalid API key.
Unauthorized,
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct GetWorkflowRequestPath {
/// The ID of the workflow.
#[validate(length(min = 1u64))]
pub workflow_id: String,
}
/// Retrieve a workflow graph with node type names, connections, and selected display fields.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetWorkflowRequest {
#[validate(nested)]
pub path: GetWorkflowRequestPath,
}
impl GetWorkflowRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<GetWorkflowResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<SimplifiedWorkflow>::json_with_diagnostics(req)
.await?;
return Ok(GetWorkflowResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(GetWorkflowResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetWorkflowResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(GetWorkflowResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetWorkflowResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetWorkflowResponse::Unknown);
}
}
/// Response types for getWorkflow
#[derive(Debug, Clone)]
pub enum GetWorkflowResponse {
///200: Successful.
Ok(SimplifiedWorkflow),
///400: Invalid `workflowId`.
BadRequest(WorkflowFailureResponse),
///401: Invalid API key.
Unauthorized,
///404: Workflow not found.
NotFound(WorkflowFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateWorkflowPropertiesRequestParamsPath {
/// The ID of the workflow.
#[validate(length(min = 1u64))]
pub workflow_id: String,
}
/// Update a workflow's name, description, or group. At least one field must be provided. To change the workflow's mailing list, use the `POST /v1/workflows/{workflowId}/mailing-list` endpoint instead.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateWorkflowPropertiesRequestParams {
#[validate(nested)]
pub path: UpdateWorkflowPropertiesRequestParamsPath,
pub body: UpdateWorkflowPropertiesRequest,
}
impl UpdateWorkflowPropertiesRequestParams {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<UpdateWorkflowPropertiesResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<SimplifiedWorkflow>::json_with_diagnostics(req)
.await?;
return Ok(UpdateWorkflowPropertiesResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(UpdateWorkflowPropertiesResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(UpdateWorkflowPropertiesResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(UpdateWorkflowPropertiesResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(UpdateWorkflowPropertiesResponse::MethodNotAllowed);
}
if status == http::StatusCode::CONFLICT {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(UpdateWorkflowPropertiesResponse::Conflict(data));
}
let _ = req.bytes().await?;
return Ok(UpdateWorkflowPropertiesResponse::Unknown);
}
}
/// Response types for updateWorkflowProperties
#[derive(Debug, Clone)]
pub enum UpdateWorkflowPropertiesResponse {
///200: Workflow properties updated.
Ok(SimplifiedWorkflow),
///400: Invalid `workflowId`, request body, or workflow group not found.
BadRequest(WorkflowFailureResponse),
///401: Invalid API key.
Unauthorized,
///404: Workflow not found.
NotFound(WorkflowFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///409: `expectedRevisionId` is stale.
Conflict(WorkflowFailureResponse),
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct DeleteWorkflowRequestParamsPath {
/// The ID of the workflow.
#[validate(length(min = 1u64))]
pub workflow_id: String,
}
/// Delete a workflow. Successful deletion returns `204 No Content`. If the workflow is currently sending or has queued contacts, Loops returns `409 Conflict` with a message instead of deleting. Retry with `confirmDelete: true` to delete the workflow, stop sending, and cancel queued contacts.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct DeleteWorkflowRequestParams {
#[validate(nested)]
pub path: DeleteWorkflowRequestParamsPath,
pub body: DeleteWorkflowRequest,
}
impl DeleteWorkflowRequestParams {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<DeleteWorkflowResponse> {
let status = req.status();
if status == http::StatusCode::NO_CONTENT {
let _ = req.bytes().await?;
return Ok(DeleteWorkflowResponse::NoContent);
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(DeleteWorkflowResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(DeleteWorkflowResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(DeleteWorkflowResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(DeleteWorkflowResponse::MethodNotAllowed);
}
if status == http::StatusCode::CONFLICT {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(DeleteWorkflowResponse::Conflict(data));
}
let _ = req.bytes().await?;
return Ok(DeleteWorkflowResponse::Unknown);
}
}
/// Response types for deleteWorkflow
#[derive(Debug, Clone)]
pub enum DeleteWorkflowResponse {
///204: Workflow deleted. No response body.
NoContent,
///400: Invalid `workflowId`, request body, or delete target.
BadRequest(WorkflowFailureResponse),
///401: Invalid API key.
Unauthorized,
///404: Workflow not found. Deleted workflows are returned as not found.
NotFound(WorkflowFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///409: `expectedRevisionId` is stale, or workflow deletion requires confirmation because the workflow is currently sending or has queued contacts.
Conflict(WorkflowFailureResponse),
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct ChangeWorkflowMailingListRequestParamsPath {
/// The ID of the workflow.
#[validate(length(min = 1u64))]
pub workflow_id: String,
}
/// Dry run or apply a workflow mailing list change. If queued contacts would be removed from the workflow due to the change of mailing list, Loops returns with `"status": "queuedContactsFound"` instead of applying the change. Retry with `queuedContactPolicy: "discard"` to apply the change and discard those contacts. Confirmed update responses include the simplified workflow after the mailing list changes.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct ChangeWorkflowMailingListRequestParams {
#[validate(nested)]
pub path: ChangeWorkflowMailingListRequestParamsPath,
pub body: ChangeWorkflowMailingListRequest,
}
impl ChangeWorkflowMailingListRequestParams {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<ChangeWorkflowMailingListResponseEnum> {
let status = req.status();
if status == http::StatusCode::OK {
let data = oas3_gen_support::Diagnostics::<
ChangeWorkflowMailingListResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(ChangeWorkflowMailingListResponseEnum::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(ChangeWorkflowMailingListResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(ChangeWorkflowMailingListResponseEnum::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(ChangeWorkflowMailingListResponseEnum::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(ChangeWorkflowMailingListResponseEnum::MethodNotAllowed);
}
if status == http::StatusCode::CONFLICT {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(ChangeWorkflowMailingListResponseEnum::Conflict(data));
}
let _ = req.bytes().await?;
return Ok(ChangeWorkflowMailingListResponseEnum::Unknown);
}
}
/// Response types for changeWorkflowMailingList
#[derive(Debug, Clone)]
pub enum ChangeWorkflowMailingListResponseEnum {
///200: Mailing-list dry run, queued-contact warning, or update result. Confirmed update responses include the simplified workflow after the mailing list changes.
Ok(ChangeWorkflowMailingListResponse),
///400: Invalid `workflowId`, request body, mailing list, or workflow state.
BadRequest(WorkflowFailureResponse),
///401: Invalid API key.
Unauthorized,
///404: Workflow not found.
NotFound(WorkflowFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///409: `expectedRevisionId` is stale.
Conflict(WorkflowFailureResponse),
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct CreateWorkflowNodeRequestParamsPath {
/// The ID of the workflow.
#[validate(length(min = 1u64))]
pub workflow_id: String,
}
/// Create a new default workflow node and return it with the latest workflow.
///
/// Choose where the node goes with `insertMode`: `between` places it between an existing `fromNodeId` -> `toNodeId` connection, `before` places it before `toNodeId`, and `after` places it after `fromNodeId` when that node has exactly one outgoing connection. `after` is a convenience for simple linear paths, so callers do not need to fetch and pass the current child node ID. It is invalid when `fromNodeId` has no outgoing nodes, multiple outgoing nodes, or is an exit node. When the source has multiple outgoing nodes, use `between` with the exact `toNodeId` instead. For `before`, deprecated `beforeNodeId` requests are still accepted for compatibility, but new callers should use `toNodeId`.
///
/// New nodes start with default settings; update the node after creation to configure it. Branch nodes create their default paths too: `BranchNode` creates two `AudienceFilter` children, and `ExperimentBranchNode` creates two regular `VariantNode` children plus one control `VariantNode`. Public workflows can have up to 400 nodes. Generated children count toward that limit, so a normal create adds 1 node, `BranchNode` adds 3, and `ExperimentBranchNode` adds 4. To add a sibling child path to a branch or experiment branch, use the `POST /v1/workflows/{workflowId}/nodes/{nodeId}/add-branch` endpoint. Branch paths can be edited with create-node, but a workflow cannot be started unless each direct `BranchNode` child is an `AudienceFilter`. For experiments, use create-node only to insert a missing `VariantNode` before non-variant content; use add-branch for another variant path.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct CreateWorkflowNodeRequestParams {
#[validate(nested)]
pub path: CreateWorkflowNodeRequestParamsPath,
pub body: CreateWorkflowNodeRequest,
}
impl CreateWorkflowNodeRequestParams {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<CreateWorkflowNodeResponseEnum> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<CreateWorkflowNodeResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(CreateWorkflowNodeResponseEnum::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(CreateWorkflowNodeResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(CreateWorkflowNodeResponseEnum::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(CreateWorkflowNodeResponseEnum::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(CreateWorkflowNodeResponseEnum::MethodNotAllowed);
}
if status == http::StatusCode::CONFLICT {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(CreateWorkflowNodeResponseEnum::Conflict(data));
}
let _ = req.bytes().await?;
return Ok(CreateWorkflowNodeResponseEnum::Unknown);
}
}
/// Response types for createWorkflowNode
#[derive(Debug, Clone)]
pub enum CreateWorkflowNodeResponseEnum {
///200: Workflow node created.
Ok(CreateWorkflowNodeResponse),
///400: Invalid request. Details will be shown in `message`.
BadRequest(WorkflowFailureResponse),
///401: Invalid API key.
Unauthorized,
///404: Workflow or workflow node not found.
NotFound(WorkflowFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///409: `expectedRevisionId` is stale.
Conflict(WorkflowFailureResponse),
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct AddWorkflowBranchRequestParamsPath {
/// The ID of the workflow.
#[validate(length(min = 1u64))]
pub workflow_id: String,
/// The ID of the BranchNode or ExperimentBranchNode that should receive one new child.
#[validate(length(min = 1u64))]
pub node_id: String,
}
/// Add a branch and a child node under an existing Branch or Experiment node. Returns the created child node plus the latest workflow.
///
/// - Adding a branch to a `BranchNode` creates one `AudienceFilter` child node.
/// - Adding a branch to an `ExperimentBranchNode` creates one `VariantNode` child node.
///
/// This endpoint does not accept node configuration fields; update the child node with `POST /v1/workflows/{workflowId}/nodes/{nodeId}` after creation. Public workflows are limited to 400 nodes, and this endpoint adds 1 node.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct AddWorkflowBranchRequestParams {
#[validate(nested)]
pub path: AddWorkflowBranchRequestParamsPath,
pub body: AddWorkflowBranchRequest,
}
impl AddWorkflowBranchRequestParams {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<AddWorkflowBranchResponseEnum> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<AddWorkflowBranchResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(AddWorkflowBranchResponseEnum::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(AddWorkflowBranchResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(AddWorkflowBranchResponseEnum::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(AddWorkflowBranchResponseEnum::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(AddWorkflowBranchResponseEnum::MethodNotAllowed);
}
if status == http::StatusCode::CONFLICT {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(AddWorkflowBranchResponseEnum::Conflict(data));
}
let _ = req.bytes().await?;
return Ok(AddWorkflowBranchResponseEnum::Unknown);
}
}
/// Response types for addWorkflowBranch
#[derive(Debug, Clone)]
pub enum AddWorkflowBranchResponseEnum {
///200: Branch added.
Ok(AddWorkflowBranchResponse),
///400: Invalid `workflowId`, `nodeId`, request body, branch target, workflow state, or workflow node cap.
BadRequest(WorkflowFailureResponse),
///401: Invalid API key.
Unauthorized,
///404: Workflow or workflow node not found.
NotFound(WorkflowFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///409: `expectedRevisionId` is stale.
Conflict(WorkflowFailureResponse),
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct GetWorkflowNodeRequestPath {
/// The ID of the workflow.
#[validate(length(min = 1u64))]
pub workflow_id: String,
/// The ID of the workflow node.
#[validate(length(min = 1u64))]
pub node_id: String,
}
/// Retrieve detailed data for a single workflow node.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetWorkflowNodeRequest {
#[validate(nested)]
pub path: GetWorkflowNodeRequestPath,
}
impl GetWorkflowNodeRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(req: reqwest::Response) -> anyhow::Result<GetWorkflowNodeResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<WorkflowNodeWithRevision>::json_with_diagnostics(
req,
)
.await?;
return Ok(GetWorkflowNodeResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(GetWorkflowNodeResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetWorkflowNodeResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(GetWorkflowNodeResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetWorkflowNodeResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetWorkflowNodeResponse::Unknown);
}
}
/// Response types for getWorkflowNode
#[derive(Debug, Clone)]
pub enum GetWorkflowNodeResponse {
///200: Successful.
Ok(WorkflowNodeWithRevision),
///400: Invalid `workflowId` or `nodeId`.
BadRequest(WorkflowFailureResponse),
///401: Invalid API key.
Unauthorized,
///404: Workflow or workflow node not found.
NotFound(WorkflowFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateWorkflowNodeRequestParamsPath {
/// The ID of the workflow.
#[validate(length(min = 1u64))]
pub workflow_id: String,
/// The ID of the workflow node.
#[validate(length(min = 1u64))]
pub node_id: String,
}
/// Update workflow-node-owned fields for a single node. Shared resources such as email messages and audience segments should be updated through their own APIs.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct UpdateWorkflowNodeRequestParams {
#[validate(nested)]
pub path: UpdateWorkflowNodeRequestParamsPath,
pub body: UpdateWorkflowNodeRequest,
}
impl UpdateWorkflowNodeRequestParams {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<UpdateWorkflowNodeResponseEnum> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<UpdateWorkflowNodeResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(UpdateWorkflowNodeResponseEnum::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(UpdateWorkflowNodeResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(UpdateWorkflowNodeResponseEnum::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(UpdateWorkflowNodeResponseEnum::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(UpdateWorkflowNodeResponseEnum::MethodNotAllowed);
}
if status == http::StatusCode::CONFLICT {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(UpdateWorkflowNodeResponseEnum::Conflict(data));
}
if status == http::StatusCode::NOT_IMPLEMENTED {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(UpdateWorkflowNodeResponseEnum::NotImplemented(data));
}
let _ = req.bytes().await?;
return Ok(UpdateWorkflowNodeResponseEnum::Unknown);
}
}
/// Response types for updateWorkflowNode
#[derive(Debug, Clone)]
pub enum UpdateWorkflowNodeResponseEnum {
///200: Workflow node updated.
Ok(UpdateWorkflowNodeResponse),
///400: Invalid `workflowId`, `nodeId`, request body, or node update.
BadRequest(WorkflowFailureResponse),
///401: Invalid API key.
Unauthorized,
///404: Workflow or workflow node not found.
NotFound(WorkflowFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///409: `expectedRevisionId` is stale.
Conflict(WorkflowFailureResponse),
///501: This node update is not implemented.
NotImplemented(WorkflowFailureResponse),
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct DeleteWorkflowNodeRequestParamsPath {
/// The ID of the workflow.
#[validate(length(min = 1u64))]
pub workflow_id: String,
/// The ID of the workflow node.
#[validate(length(min = 1u64))]
pub node_id: String,
}
/// Delete a single workflow node. If contacts are queued at the node, Loops returns with `"status": "queuedContactsFound"` instead of deleting. Retry with `queuedContactPolicy: "discard"` to delete the node and discard those queued contacts. Confirmed deletion responses include the simplified workflow after the node is removed.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct DeleteWorkflowNodeRequestParams {
#[validate(nested)]
pub path: DeleteWorkflowNodeRequestParamsPath,
pub body: DeleteWorkflowNodeRequest,
}
impl DeleteWorkflowNodeRequestParams {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<DeleteWorkflowNodeResponseEnum> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<DeleteWorkflowNodeResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(DeleteWorkflowNodeResponseEnum::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(DeleteWorkflowNodeResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(DeleteWorkflowNodeResponseEnum::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(DeleteWorkflowNodeResponseEnum::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(DeleteWorkflowNodeResponseEnum::MethodNotAllowed);
}
if status == http::StatusCode::CONFLICT {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(DeleteWorkflowNodeResponseEnum::Conflict(data));
}
let _ = req.bytes().await?;
return Ok(DeleteWorkflowNodeResponseEnum::Unknown);
}
}
/// Response types for deleteWorkflowNode
#[derive(Debug, Clone)]
pub enum DeleteWorkflowNodeResponseEnum {
///200: Delete dry run, queued-contact warning, or deletion result. Confirmed deletion responses include the simplified workflow after the node is removed.
Ok(DeleteWorkflowNodeResponse),
///400: Invalid `workflowId`, `nodeId`, request body, or delete target.
BadRequest(WorkflowFailureResponse),
///401: Invalid API key.
Unauthorized,
///404: Workflow or workflow node not found.
NotFound(WorkflowFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///409: `expectedRevisionId` is stale.
Conflict(WorkflowFailureResponse),
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct GetWorkflowNodeMetricsRequestPath {
/// The ID of the workflow.
#[validate(length(min = 1u64))]
pub workflow_id: String,
/// The ID of the `SendEmailAction` node.
#[validate(length(min = 1u64))]
pub node_id: String,
}
/// Retrieve all-time email engagement metrics for a workflow `SendEmailAction` node. Nodes of any other type return a `400` response. A `SendEmailAction` node with an email that has not sent anything yet reports every counter as `0`.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct GetWorkflowNodeMetricsRequest {
#[validate(nested)]
pub path: GetWorkflowNodeMetricsRequestPath,
}
impl GetWorkflowNodeMetricsRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<GetWorkflowNodeMetricsResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<EmailMetricsResponse>::json_with_diagnostics(req)
.await?;
return Ok(GetWorkflowNodeMetricsResponse::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(GetWorkflowNodeMetricsResponse::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(GetWorkflowNodeMetricsResponse::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(GetWorkflowNodeMetricsResponse::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(GetWorkflowNodeMetricsResponse::MethodNotAllowed);
}
let _ = req.bytes().await?;
return Ok(GetWorkflowNodeMetricsResponse::Unknown);
}
}
/// Response types for getWorkflowNodeMetrics
#[derive(Debug, Clone)]
pub enum GetWorkflowNodeMetricsResponse {
///200: Successful.
Ok(EmailMetricsResponse),
///400: Invalid `workflowId` or `nodeId`, the node is not a `SendEmailAction` node, or the node has no email message.
BadRequest(WorkflowFailureResponse),
///401: Invalid API key.
Unauthorized,
///404: Workflow or workflow node not found.
NotFound(WorkflowFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct RerouteNodeConnectionRequestParamsPath {
/// The ID of the workflow.
#[validate(length(min = 1u64))]
pub workflow_id: String,
/// The ID of the source workflow node whose outgoing connection should be moved.
#[validate(length(min = 1u64))]
pub node_id: String,
}
/// Reroute the source node's existing connection to another valid target node. Returns the updated source node and the latest workflow.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct RerouteNodeConnectionRequestParams {
#[validate(nested)]
pub path: RerouteNodeConnectionRequestParamsPath,
#[validate(nested)]
pub body: RerouteNodeConnectionRequest,
}
impl RerouteNodeConnectionRequestParams {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<RerouteNodeConnectionResponseEnum> {
let status = req.status();
if status == http::StatusCode::OK {
let data = oas3_gen_support::Diagnostics::<
RerouteNodeConnectionResponse,
>::json_with_diagnostics(req)
.await?;
return Ok(RerouteNodeConnectionResponseEnum::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(RerouteNodeConnectionResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(RerouteNodeConnectionResponseEnum::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(RerouteNodeConnectionResponseEnum::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(RerouteNodeConnectionResponseEnum::MethodNotAllowed);
}
if status == http::StatusCode::CONFLICT {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(RerouteNodeConnectionResponseEnum::Conflict(data));
}
let _ = req.bytes().await?;
return Ok(RerouteNodeConnectionResponseEnum::Unknown);
}
}
/// Response types for rerouteNodeConnection
#[derive(Debug, Clone)]
pub enum RerouteNodeConnectionResponseEnum {
///200: Node connection rerouted.
Ok(RerouteNodeConnectionResponse),
///400: Invalid `workflowId`, `nodeId`, request body, node connection selection, reroute target, or workflow state.
BadRequest(WorkflowFailureResponse),
///401: Invalid API key.
Unauthorized,
///404: Workflow or workflow node not found.
NotFound(WorkflowFailureResponse),
///405: Wrong HTTP request method.
MethodNotAllowed,
///409: `expectedRevisionId` is stale.
Conflict(WorkflowFailureResponse),
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct DeleteWorkflowNodeRecursivelyRequestPath {
/// The ID of the workflow.
#[validate(length(min = 1u64))]
pub workflow_id: String,
/// The root node ID of the subtree to delete.
#[validate(length(min = 1u64))]
pub node_id: String,
}
/// Delete a node and its downstream subtree. If contacts are queued at any node that would be deleted, Loops returns with `"status": "queuedContactsFound"` instead of deleting. Retry with `queuedContactPolicy: "discard"` to delete the nodes and discard those queued contacts. Confirmed deletion responses include the simplified workflow after the nodes are removed.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct DeleteWorkflowNodeRecursivelyRequest {
#[validate(nested)]
pub path: DeleteWorkflowNodeRecursivelyRequestPath,
pub body: DeleteWorkflowNodeRequest,
}
impl DeleteWorkflowNodeRecursivelyRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<DeleteWorkflowNodeResponseEnum> {
let status = req.status();
if status == http::StatusCode::OK {
let data =
oas3_gen_support::Diagnostics::<DeleteWorkflowNodeResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(DeleteWorkflowNodeResponseEnum::Ok(data));
}
if status == http::StatusCode::BAD_REQUEST {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(DeleteWorkflowNodeResponseEnum::BadRequest(data));
}
if status == http::StatusCode::UNAUTHORIZED {
let _ = req.bytes().await?;
return Ok(DeleteWorkflowNodeResponseEnum::Unauthorized);
}
if status == http::StatusCode::NOT_FOUND {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(DeleteWorkflowNodeResponseEnum::NotFound(data));
}
if status == http::StatusCode::METHOD_NOT_ALLOWED {
let _ = req.bytes().await?;
return Ok(DeleteWorkflowNodeResponseEnum::MethodNotAllowed);
}
if status == http::StatusCode::CONFLICT {
let data =
oas3_gen_support::Diagnostics::<WorkflowFailureResponse>::json_with_diagnostics(
req,
)
.await?;
return Ok(DeleteWorkflowNodeResponseEnum::Conflict(data));
}
let _ = req.bytes().await?;
return Ok(DeleteWorkflowNodeResponseEnum::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookContactUnsubscribedRequestHeader {
/// Unique message ID. Use to deduplicate deliveries.
#[validate(length(min = 1u64))]
pub webhook_id: String,
/// Unix timestamp of when the message was sent.
#[validate(length(min = 1u64))]
pub webhook_timestamp: String,
/// HMAC signature for verifying the request. Verify using your endpoint signing secret from the Loops dashboard.
#[validate(length(min = 1u64))]
pub webhook_signature: String,
}
impl core::convert::TryFrom<&WebhookContactUnsubscribedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &WebhookContactUnsubscribedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(3usize);
let header_value = http::HeaderValue::try_from(&headers.webhook_id)?;
map.insert(WEBHOOK_ID, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_timestamp)?;
map.insert(WEBHOOK_TIMESTAMP, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_signature)?;
map.insert(WEBHOOK_SIGNATURE, header_value);
Ok(map)
}
}
impl core::convert::TryFrom<WebhookContactUnsubscribedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: WebhookContactUnsubscribedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Sent when a contact is unsubscribed from your audience, or when a contact is deleted from your audience (alongside `contact.deleted`). This is not the same as a contact unsubscribing from a mailing list (see `contact.mailingList.unsubscribed`). Contains a `contactIdentity` object.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookContactUnsubscribedRequest {
#[validate(nested)]
pub header: WebhookContactUnsubscribedRequestHeader,
#[validate(nested)]
pub body: WebhookContactUnsubscribedPayload,
}
impl WebhookContactUnsubscribedRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<WebhookEmailOpenedResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Ok);
}
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookContactCreatedRequestHeader {
/// Unique message ID. Use to deduplicate deliveries.
#[validate(length(min = 1u64))]
pub webhook_id: String,
/// Unix timestamp of when the message was sent.
#[validate(length(min = 1u64))]
pub webhook_timestamp: String,
/// HMAC signature for verifying the request. Verify using your endpoint signing secret from the Loops dashboard.
#[validate(length(min = 1u64))]
pub webhook_signature: String,
}
impl core::convert::TryFrom<&WebhookContactCreatedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &WebhookContactCreatedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(3usize);
let header_value = http::HeaderValue::try_from(&headers.webhook_id)?;
map.insert(WEBHOOK_ID, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_timestamp)?;
map.insert(WEBHOOK_TIMESTAMP, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_signature)?;
map.insert(WEBHOOK_SIGNATURE, header_value);
Ok(map)
}
}
impl core::convert::TryFrom<WebhookContactCreatedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: WebhookContactCreatedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Sent when a new contact is created in your audience. Contains a `contactIdentity` object and a full `contact` object with all of the new contact's properties (including custom properties). When double opt-in is enabled, contact webhooks do not fire until the contact is confirmed; `contact.created` only fires for form-created contacts once they confirm their subscription. `optInStatus` will never be `"pending"` or `"rejected"` for this event.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookContactCreatedRequest {
#[validate(nested)]
pub header: WebhookContactCreatedRequestHeader,
#[validate(nested)]
pub body: WebhookContactCreatedPayload,
}
impl WebhookContactCreatedRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<WebhookEmailOpenedResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Ok);
}
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookContactDeletedRequestHeader {
/// Unique message ID. Use to deduplicate deliveries.
#[validate(length(min = 1u64))]
pub webhook_id: String,
/// Unix timestamp of when the message was sent.
#[validate(length(min = 1u64))]
pub webhook_timestamp: String,
/// HMAC signature for verifying the request. Verify using your endpoint signing secret from the Loops dashboard.
#[validate(length(min = 1u64))]
pub webhook_signature: String,
}
impl core::convert::TryFrom<&WebhookContactDeletedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &WebhookContactDeletedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(3usize);
let header_value = http::HeaderValue::try_from(&headers.webhook_id)?;
map.insert(WEBHOOK_ID, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_timestamp)?;
map.insert(WEBHOOK_TIMESTAMP, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_signature)?;
map.insert(WEBHOOK_SIGNATURE, header_value);
Ok(map)
}
}
impl core::convert::TryFrom<WebhookContactDeletedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: WebhookContactDeletedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Sent when a contact is deleted from your audience. Contains a `contactIdentity` object.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookContactDeletedRequest {
#[validate(nested)]
pub header: WebhookContactDeletedRequestHeader,
#[validate(nested)]
pub body: WebhookContactDeletedPayload,
}
impl WebhookContactDeletedRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<WebhookEmailOpenedResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Ok);
}
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookContactMailingListSubscribedRequestHeader {
/// Unique message ID. Use to deduplicate deliveries.
#[validate(length(min = 1u64))]
pub webhook_id: String,
/// Unix timestamp of when the message was sent.
#[validate(length(min = 1u64))]
pub webhook_timestamp: String,
/// HMAC signature for verifying the request. Verify using your endpoint signing secret from the Loops dashboard.
#[validate(length(min = 1u64))]
pub webhook_signature: String,
}
impl core::convert::TryFrom<&WebhookContactMailingListSubscribedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &WebhookContactMailingListSubscribedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(3usize);
let header_value = http::HeaderValue::try_from(&headers.webhook_id)?;
map.insert(WEBHOOK_ID, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_timestamp)?;
map.insert(WEBHOOK_TIMESTAMP, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_signature)?;
map.insert(WEBHOOK_SIGNATURE, header_value);
Ok(map)
}
}
impl core::convert::TryFrom<WebhookContactMailingListSubscribedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: WebhookContactMailingListSubscribedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Sent when a contact is subscribed to a mailing list. Contains `contactIdentity` and `mailingList` objects. When double opt-in is enabled, this event only fires after the contact confirms their subscription.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookContactMailingListSubscribedRequest {
#[validate(nested)]
pub header: WebhookContactMailingListSubscribedRequestHeader,
#[validate(nested)]
pub body: WebhookContactMailingListSubscribedPayload,
}
impl WebhookContactMailingListSubscribedRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<WebhookEmailOpenedResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Ok);
}
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookContactMailingListUnsubscribedRequestHeader {
/// Unique message ID. Use to deduplicate deliveries.
#[validate(length(min = 1u64))]
pub webhook_id: String,
/// Unix timestamp of when the message was sent.
#[validate(length(min = 1u64))]
pub webhook_timestamp: String,
/// HMAC signature for verifying the request. Verify using your endpoint signing secret from the Loops dashboard.
#[validate(length(min = 1u64))]
pub webhook_signature: String,
}
impl core::convert::TryFrom<&WebhookContactMailingListUnsubscribedRequestHeader>
for http::HeaderMap
{
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &WebhookContactMailingListUnsubscribedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(3usize);
let header_value = http::HeaderValue::try_from(&headers.webhook_id)?;
map.insert(WEBHOOK_ID, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_timestamp)?;
map.insert(WEBHOOK_TIMESTAMP, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_signature)?;
map.insert(WEBHOOK_SIGNATURE, header_value);
Ok(map)
}
}
impl core::convert::TryFrom<WebhookContactMailingListUnsubscribedRequestHeader>
for http::HeaderMap
{
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: WebhookContactMailingListUnsubscribedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Sent when a contact is unsubscribed from a mailing list. This is not the same as a contact unsubscribing from your audience (see `contact.unsubscribed`). Contains `contactIdentity` and `mailingList` objects.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookContactMailingListUnsubscribedRequest {
#[validate(nested)]
pub header: WebhookContactMailingListUnsubscribedRequestHeader,
#[validate(nested)]
pub body: WebhookContactMailingListUnsubscribedPayload,
}
impl WebhookContactMailingListUnsubscribedRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<WebhookEmailOpenedResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Ok);
}
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookTransactionalEmailSentRequestHeader {
/// Unique message ID. Use to deduplicate deliveries.
#[validate(length(min = 1u64))]
pub webhook_id: String,
/// Unix timestamp of when the message was sent.
#[validate(length(min = 1u64))]
pub webhook_timestamp: String,
/// HMAC signature for verifying the request. Verify using your endpoint signing secret from the Loops dashboard.
#[validate(length(min = 1u64))]
pub webhook_signature: String,
}
impl core::convert::TryFrom<&WebhookTransactionalEmailSentRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &WebhookTransactionalEmailSentRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(3usize);
let header_value = http::HeaderValue::try_from(&headers.webhook_id)?;
map.insert(WEBHOOK_ID, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_timestamp)?;
map.insert(WEBHOOK_TIMESTAMP, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_signature)?;
map.insert(WEBHOOK_SIGNATURE, header_value);
Ok(map)
}
}
impl core::convert::TryFrom<WebhookTransactionalEmailSentRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: WebhookTransactionalEmailSentRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Sent when a transactional email is sent to a contact. Contains a `transactionalId` value plus `contactIdentity` and `email` objects.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookTransactionalEmailSentRequest {
#[validate(nested)]
pub header: WebhookTransactionalEmailSentRequestHeader,
#[validate(nested)]
pub body: WebhookTransactionalEmailSentPayload,
}
impl WebhookTransactionalEmailSentRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<WebhookEmailOpenedResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Ok);
}
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookCampaignEmailSentRequestHeader {
/// Unique message ID. Use to deduplicate deliveries.
#[validate(length(min = 1u64))]
pub webhook_id: String,
/// Unix timestamp of when the message was sent.
#[validate(length(min = 1u64))]
pub webhook_timestamp: String,
/// HMAC signature for verifying the request. Verify using your endpoint signing secret from the Loops dashboard.
#[validate(length(min = 1u64))]
pub webhook_signature: String,
}
impl core::convert::TryFrom<&WebhookCampaignEmailSentRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &WebhookCampaignEmailSentRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(3usize);
let header_value = http::HeaderValue::try_from(&headers.webhook_id)?;
map.insert(WEBHOOK_ID, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_timestamp)?;
map.insert(WEBHOOK_TIMESTAMP, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_signature)?;
map.insert(WEBHOOK_SIGNATURE, header_value);
Ok(map)
}
}
impl core::convert::TryFrom<WebhookCampaignEmailSentRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: WebhookCampaignEmailSentRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Sent when a campaign email is sent to a contact. This event fires for every campaign send (for example, sending to 1,000 contacts produces 1,000 events). Contains `campaignId` and `campaignName` plus `contactIdentity` and `email` objects. If the campaign was sent to one or more mailing lists, a `mailingLists` array is also included.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookCampaignEmailSentRequest {
#[validate(nested)]
pub header: WebhookCampaignEmailSentRequestHeader,
#[validate(nested)]
pub body: WebhookCampaignEmailSentPayload,
}
impl WebhookCampaignEmailSentRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<WebhookEmailOpenedResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Ok);
}
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookLoopEmailSentRequestHeader {
/// Unique message ID. Use to deduplicate deliveries.
#[validate(length(min = 1u64))]
pub webhook_id: String,
/// Unix timestamp of when the message was sent.
#[validate(length(min = 1u64))]
pub webhook_timestamp: String,
/// HMAC signature for verifying the request. Verify using your endpoint signing secret from the Loops dashboard.
#[validate(length(min = 1u64))]
pub webhook_signature: String,
}
impl core::convert::TryFrom<&WebhookLoopEmailSentRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &WebhookLoopEmailSentRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(3usize);
let header_value = http::HeaderValue::try_from(&headers.webhook_id)?;
map.insert(WEBHOOK_ID, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_timestamp)?;
map.insert(WEBHOOK_TIMESTAMP, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_signature)?;
map.insert(WEBHOOK_SIGNATURE, header_value);
Ok(map)
}
}
impl core::convert::TryFrom<WebhookLoopEmailSentRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: WebhookLoopEmailSentRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Sent when a workflow email is sent to a contact. This event keeps its `loop` naming for compatibility (Loops was renamed to Workflows on May 6, 2026). This event fires for every contact in a workflow (for example, 1,000 recipients produces 1,000 events). Contains `loopId` and `loopName` plus `contactIdentity` and `email` objects. If the workflow was sent to one or more mailing lists, a `mailingLists` array is also included.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookLoopEmailSentRequest {
#[validate(nested)]
pub header: WebhookLoopEmailSentRequestHeader,
#[validate(nested)]
pub body: WebhookLoopEmailSentPayload,
}
impl WebhookLoopEmailSentRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<WebhookEmailOpenedResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Ok);
}
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookEmailDeliveredRequestHeader {
/// Unique message ID. Use to deduplicate deliveries.
#[validate(length(min = 1u64))]
pub webhook_id: String,
/// Unix timestamp of when the message was sent.
#[validate(length(min = 1u64))]
pub webhook_timestamp: String,
/// HMAC signature for verifying the request. Verify using your endpoint signing secret from the Loops dashboard.
#[validate(length(min = 1u64))]
pub webhook_signature: String,
}
impl core::convert::TryFrom<&WebhookEmailDeliveredRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &WebhookEmailDeliveredRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(3usize);
let header_value = http::HeaderValue::try_from(&headers.webhook_id)?;
map.insert(WEBHOOK_ID, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_timestamp)?;
map.insert(WEBHOOK_TIMESTAMP, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_signature)?;
map.insert(WEBHOOK_SIGNATURE, header_value);
Ok(map)
}
}
impl core::convert::TryFrom<WebhookEmailDeliveredRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: WebhookEmailDeliveredRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Sent when an email is delivered to its recipient. Contains `sourceType` (`campaign`, `loop`, or `transactional`) and the related `campaignId`, `loopId` (workflow ID), or `transactionalId`, plus `contactIdentity` and `email` objects.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookEmailDeliveredRequest {
#[validate(nested)]
pub header: WebhookEmailDeliveredRequestHeader,
#[validate(nested)]
pub body: WebhookEmailDeliveredPayload,
}
impl WebhookEmailDeliveredRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<WebhookEmailOpenedResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Ok);
}
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookEmailSoftBouncedRequestHeader {
/// Unique message ID. Use to deduplicate deliveries.
#[validate(length(min = 1u64))]
pub webhook_id: String,
/// Unix timestamp of when the message was sent.
#[validate(length(min = 1u64))]
pub webhook_timestamp: String,
/// HMAC signature for verifying the request. Verify using your endpoint signing secret from the Loops dashboard.
#[validate(length(min = 1u64))]
pub webhook_signature: String,
}
impl core::convert::TryFrom<&WebhookEmailSoftBouncedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &WebhookEmailSoftBouncedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(3usize);
let header_value = http::HeaderValue::try_from(&headers.webhook_id)?;
map.insert(WEBHOOK_ID, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_timestamp)?;
map.insert(WEBHOOK_TIMESTAMP, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_signature)?;
map.insert(WEBHOOK_SIGNATURE, header_value);
Ok(map)
}
}
impl core::convert::TryFrom<WebhookEmailSoftBouncedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: WebhookEmailSoftBouncedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Sent when an email soft bounces. Soft bounces are temporary delivery failures (for example, a connection timing out). Soft bounces are retried multiple times and the email may still be delivered. Contains `sourceType` and the related `campaignId`, `loopId` (workflow ID), or `transactionalId`, plus `contactIdentity` and `email` objects.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookEmailSoftBouncedRequest {
#[validate(nested)]
pub header: WebhookEmailSoftBouncedRequestHeader,
#[validate(nested)]
pub body: WebhookEmailSoftBouncedPayload,
}
impl WebhookEmailSoftBouncedRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<WebhookEmailOpenedResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Ok);
}
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookEmailHardBouncedRequestHeader {
/// Unique message ID. Use to deduplicate deliveries.
#[validate(length(min = 1u64))]
pub webhook_id: String,
/// Unix timestamp of when the message was sent.
#[validate(length(min = 1u64))]
pub webhook_timestamp: String,
/// HMAC signature for verifying the request. Verify using your endpoint signing secret from the Loops dashboard.
#[validate(length(min = 1u64))]
pub webhook_signature: String,
}
impl core::convert::TryFrom<&WebhookEmailHardBouncedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &WebhookEmailHardBouncedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(3usize);
let header_value = http::HeaderValue::try_from(&headers.webhook_id)?;
map.insert(WEBHOOK_ID, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_timestamp)?;
map.insert(WEBHOOK_TIMESTAMP, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_signature)?;
map.insert(WEBHOOK_SIGNATURE, header_value);
Ok(map)
}
}
impl core::convert::TryFrom<WebhookEmailHardBouncedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: WebhookEmailHardBouncedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Sent when an email hard bounces. Hard bounces are persistent delivery failures (for example, a mailbox that does not exist); the email will not be delivered. In Loops, a hard bounce also unsubscribes the contact from your audience, so a `contact.unsubscribed` event will also be sent. Contains `sourceType` and the related `campaignId`, `loopId` (workflow ID), or `transactionalId`, plus `contactIdentity` and `email` objects.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookEmailHardBouncedRequest {
#[validate(nested)]
pub header: WebhookEmailHardBouncedRequestHeader,
#[validate(nested)]
pub body: WebhookEmailHardBouncedPayload,
}
impl WebhookEmailHardBouncedRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<WebhookEmailOpenedResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Ok);
}
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookEmailClickedRequestHeader {
/// Unique message ID. Use to deduplicate deliveries.
#[validate(length(min = 1u64))]
pub webhook_id: String,
/// Unix timestamp of when the message was sent.
#[validate(length(min = 1u64))]
pub webhook_timestamp: String,
/// HMAC signature for verifying the request. Verify using your endpoint signing secret from the Loops dashboard.
#[validate(length(min = 1u64))]
pub webhook_signature: String,
}
impl core::convert::TryFrom<&WebhookEmailClickedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &WebhookEmailClickedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(3usize);
let header_value = http::HeaderValue::try_from(&headers.webhook_id)?;
map.insert(WEBHOOK_ID, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_timestamp)?;
map.insert(WEBHOOK_TIMESTAMP, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_signature)?;
map.insert(WEBHOOK_SIGNATURE, header_value);
Ok(map)
}
}
impl core::convert::TryFrom<WebhookEmailClickedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: WebhookEmailClickedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Sent when a link in a campaign or workflow email is clicked. Not available for transactional emails because link clicks are not tracked for transactional emails. Contains `sourceType` and the related `campaignId` or `loopId` (workflow ID), plus `contactIdentity` and `email` objects.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookEmailClickedRequest {
#[validate(nested)]
pub header: WebhookEmailClickedRequestHeader,
#[validate(nested)]
pub body: WebhookEmailClickedPayload,
}
impl WebhookEmailClickedRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<WebhookEmailOpenedResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Ok);
}
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookEmailUnsubscribedRequestHeader {
/// Unique message ID. Use to deduplicate deliveries.
#[validate(length(min = 1u64))]
pub webhook_id: String,
/// Unix timestamp of when the message was sent.
#[validate(length(min = 1u64))]
pub webhook_timestamp: String,
/// HMAC signature for verifying the request. Verify using your endpoint signing secret from the Loops dashboard.
#[validate(length(min = 1u64))]
pub webhook_signature: String,
}
impl core::convert::TryFrom<&WebhookEmailUnsubscribedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &WebhookEmailUnsubscribedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(3usize);
let header_value = http::HeaderValue::try_from(&headers.webhook_id)?;
map.insert(WEBHOOK_ID, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_timestamp)?;
map.insert(WEBHOOK_TIMESTAMP, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_signature)?;
map.insert(WEBHOOK_SIGNATURE, header_value);
Ok(map)
}
}
impl core::convert::TryFrom<WebhookEmailUnsubscribedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: WebhookEmailUnsubscribedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Sent when a recipient unsubscribes from marketing email or a mailing list using an email's "Unsubscribe" link. A `contact.unsubscribed` or `contact.mailingList.unsubscribed` event will also be sent depending on whether the email was sent to a mailing list. Not available for transactional emails because unsubscribe links are not included for transactional emails. Contains `sourceType` and the related `campaignId` or `loopId` (workflow ID), plus `contactIdentity` and `email` objects.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookEmailUnsubscribedRequest {
#[validate(nested)]
pub header: WebhookEmailUnsubscribedRequestHeader,
#[validate(nested)]
pub body: WebhookEmailUnsubscribedPayload,
}
impl WebhookEmailUnsubscribedRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<WebhookEmailOpenedResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Ok);
}
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookEmailResubscribedRequestHeader {
/// Unique message ID. Use to deduplicate deliveries.
#[validate(length(min = 1u64))]
pub webhook_id: String,
/// Unix timestamp of when the message was sent.
#[validate(length(min = 1u64))]
pub webhook_timestamp: String,
/// HMAC signature for verifying the request. Verify using your endpoint signing secret from the Loops dashboard.
#[validate(length(min = 1u64))]
pub webhook_signature: String,
}
impl core::convert::TryFrom<&WebhookEmailResubscribedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &WebhookEmailResubscribedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(3usize);
let header_value = http::HeaderValue::try_from(&headers.webhook_id)?;
map.insert(WEBHOOK_ID, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_timestamp)?;
map.insert(WEBHOOK_TIMESTAMP, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_signature)?;
map.insert(WEBHOOK_SIGNATURE, header_value);
Ok(map)
}
}
impl core::convert::TryFrom<WebhookEmailResubscribedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: WebhookEmailResubscribedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Sent when a recipient resubscribes to marketing email from an email's preference center ("Unsubscribe" link). Not available for transactional emails because unsubscribe links are not included for transactional emails. Contains `sourceType` and the related `campaignId` or `loopId` (workflow ID), plus `contactIdentity` and `email` objects.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookEmailResubscribedRequest {
#[validate(nested)]
pub header: WebhookEmailResubscribedRequestHeader,
#[validate(nested)]
pub body: WebhookEmailResubscribedPayload,
}
impl WebhookEmailResubscribedRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<WebhookEmailOpenedResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Ok);
}
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookEmailOpenedRequestHeader {
/// Unique message ID. Use to deduplicate deliveries.
#[validate(length(min = 1u64))]
pub webhook_id: String,
/// Unix timestamp of when the message was sent.
#[validate(length(min = 1u64))]
pub webhook_timestamp: String,
/// HMAC signature for verifying the request. Verify using your endpoint signing secret from the Loops dashboard.
#[validate(length(min = 1u64))]
pub webhook_signature: String,
}
impl core::convert::TryFrom<&WebhookEmailOpenedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &WebhookEmailOpenedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(3usize);
let header_value = http::HeaderValue::try_from(&headers.webhook_id)?;
map.insert(WEBHOOK_ID, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_timestamp)?;
map.insert(WEBHOOK_TIMESTAMP, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_signature)?;
map.insert(WEBHOOK_SIGNATURE, header_value);
Ok(map)
}
}
impl core::convert::TryFrom<WebhookEmailOpenedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: WebhookEmailOpenedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Sent when a campaign or workflow email is opened. Not available for transactional emails because email opens are not tracked for transactional emails. Contains `sourceType` and the related `campaignId` or `loopId` (workflow ID), plus `contactIdentity` and `email` objects.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookEmailOpenedRequest {
#[validate(nested)]
pub header: WebhookEmailOpenedRequestHeader,
#[validate(nested)]
pub body: WebhookEmailOpenedPayload,
}
impl WebhookEmailOpenedRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<WebhookEmailOpenedResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Ok);
}
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Unknown);
}
}
/// Response types for webhookEmailOpened
#[derive(Debug, Clone)]
pub enum WebhookEmailOpenedResponse {
///200: Webhook received successfully. Return any 2xx status code to acknowledge delivery.
Ok,
///default: Unknown response
Unknown,
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookEmailSpamReportedRequestHeader {
/// Unique message ID. Use to deduplicate deliveries.
#[validate(length(min = 1u64))]
pub webhook_id: String,
/// Unix timestamp of when the message was sent.
#[validate(length(min = 1u64))]
pub webhook_timestamp: String,
/// HMAC signature for verifying the request. Verify using your endpoint signing secret from the Loops dashboard.
#[validate(length(min = 1u64))]
pub webhook_signature: String,
}
impl core::convert::TryFrom<&WebhookEmailSpamReportedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &WebhookEmailSpamReportedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(3usize);
let header_value = http::HeaderValue::try_from(&headers.webhook_id)?;
map.insert(WEBHOOK_ID, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_timestamp)?;
map.insert(WEBHOOK_TIMESTAMP, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_signature)?;
map.insert(WEBHOOK_SIGNATURE, header_value);
Ok(map)
}
}
impl core::convert::TryFrom<WebhookEmailSpamReportedRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: WebhookEmailSpamReportedRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Sent when a recipient reports your email as spam. Contains `sourceType` and the related `campaignId`, `loopId` (workflow ID), or `transactionalId`, plus `contactIdentity` and `email` objects.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookEmailSpamReportedRequest {
#[validate(nested)]
pub header: WebhookEmailSpamReportedRequestHeader,
#[validate(nested)]
pub body: WebhookEmailSpamReportedPayload,
}
impl WebhookEmailSpamReportedRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<WebhookEmailOpenedResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Ok);
}
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookTestingTestEventRequestHeader {
/// Unique message ID. Use to deduplicate deliveries.
#[validate(length(min = 1u64))]
pub webhook_id: String,
/// Unix timestamp of when the message was sent.
#[validate(length(min = 1u64))]
pub webhook_timestamp: String,
/// HMAC signature for verifying the request. Verify using your endpoint signing secret from the Loops dashboard.
#[validate(length(min = 1u64))]
pub webhook_signature: String,
}
impl core::convert::TryFrom<&WebhookTestingTestEventRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: &WebhookTestingTestEventRequestHeader,
) -> core::result::Result<Self, Self::Error> {
let mut map = http::HeaderMap::with_capacity(3usize);
let header_value = http::HeaderValue::try_from(&headers.webhook_id)?;
map.insert(WEBHOOK_ID, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_timestamp)?;
map.insert(WEBHOOK_TIMESTAMP, header_value);
let header_value = http::HeaderValue::try_from(&headers.webhook_signature)?;
map.insert(WEBHOOK_SIGNATURE, header_value);
Ok(map)
}
}
impl core::convert::TryFrom<WebhookTestingTestEventRequestHeader> for http::HeaderMap {
type Error = http::header::InvalidHeaderValue;
fn try_from(
headers: WebhookTestingTestEventRequestHeader,
) -> core::result::Result<Self, Self::Error> {
http::HeaderMap::try_from(&headers)
}
}
/// Test event that can be triggered from the Webhooks settings page in Loops. Use this to verify that your endpoint is working and that your signature verification code is correct. The payload contains `eventName`, `eventTime`, `message` (always `"test"`), and `webhookSchemaVersion`.
#[derive(Debug, Clone, validator::Validate, oas3_gen_support::Default)]
pub struct WebhookTestingTestEventRequest {
#[validate(nested)]
pub header: WebhookTestingTestEventRequestHeader,
pub body: WebhookTestingTestEventPayload,
}
impl WebhookTestingTestEventRequest {
/// Parse the HTTP response into the response enum.
pub async fn parse_response(
req: reqwest::Response,
) -> anyhow::Result<WebhookEmailOpenedResponse> {
let status = req.status();
if status == http::StatusCode::OK {
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Ok);
}
let _ = req.bytes().await?;
return Ok(WebhookEmailOpenedResponse::Unknown);
}
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ContactSuppressionStatusResponseContact {
/// The contact's Loops ID.
pub id: String,
/// The contact's email address.
pub email: String,
/// The contact's unique user ID.
#[serde(rename = "userId")]
pub user_id: Option<String>,
}
/// The type of property.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, oas3_gen_support::Default)]
pub enum ContactPropertyCreateRequestType {
#[serde(rename = "string")]
#[default]
String,
#[serde(rename = "number")]
Number,
#[serde(rename = "boolean")]
Boolean,
#[serde(rename = "date")]
Date,
}
impl core::fmt::Display for ContactPropertyCreateRequestType {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::String => write!(f, "string"),
Self::Number => write!(f, "number"),
Self::Boolean => write!(f, "boolean"),
Self::Date => write!(f, "date"),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct TransactionalRequestAttachment {
/// The name of the file, shown in email clients.
#[validate(length(min = 1u64))]
pub filename: String,
/// The MIME type of the file.
#[serde(rename = "contentType")]
#[validate(length(min = 1u64))]
pub content_type: String,
/// The base64-encoded content of the file.
#[validate(length(min = 1u64))]
pub data: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ResponseError {
pub path: Option<String>,
pub message: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct TransactionalFailure4ResponseError {
pub path: Option<String>,
pub reason: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, oas3_gen_support::Default)]
pub enum Match {
#[serde(rename = "all")]
#[default]
All,
#[serde(rename = "any")]
Any,
}
impl core::fmt::Display for Match {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::All => write!(f, "all"),
Self::Any => write!(f, "any"),
}
}
}
/// A tree of audience conditions combined with `match`.
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct CreateAudienceSegmentRequestFilter {
#[serde(rename = "match")]
pub r#match: Match,
#[validate(length(min = 1u64))]
pub conditions: Vec<AudienceFilterCondition>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, oas3_gen_support::Default)]
pub enum Method {
#[serde(rename = "now")]
#[default]
Now,
#[serde(rename = "schedule")]
Schedule,
}
impl core::fmt::Display for Method {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Now => write!(f, "now"),
Self::Schedule => write!(f, "schedule"),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, oas3_gen_support::Default)]
pub enum PropertyConditionOperator {
#[serde(rename = "any")]
#[default]
Any,
#[serde(rename = "contains")]
Contains,
#[serde(rename = "notContains")]
NotContains,
#[serde(rename = "equals")]
Equals,
#[serde(rename = "notEquals")]
NotEquals,
#[serde(rename = "greaterThan")]
GreaterThan,
#[serde(rename = "lessThan")]
LessThan,
#[serde(rename = "isTrue")]
IsTrue,
#[serde(rename = "isFalse")]
IsFalse,
#[serde(rename = "empty")]
Empty,
#[serde(rename = "notEmpty")]
NotEmpty,
#[serde(rename = "dateEmpty")]
DateEmpty,
#[serde(rename = "dateNotEmpty")]
DateNotEmpty,
#[serde(rename = "after")]
After,
#[serde(rename = "before")]
Before,
#[serde(rename = "between")]
Between,
}
impl core::fmt::Display for PropertyConditionOperator {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Any => write!(f, "any"),
Self::Contains => write!(f, "contains"),
Self::NotContains => write!(f, "notContains"),
Self::Equals => write!(f, "equals"),
Self::NotEquals => write!(f, "notEquals"),
Self::GreaterThan => write!(f, "greaterThan"),
Self::LessThan => write!(f, "lessThan"),
Self::IsTrue => write!(f, "isTrue"),
Self::IsFalse => write!(f, "isFalse"),
Self::Empty => write!(f, "empty"),
Self::NotEmpty => write!(f, "notEmpty"),
Self::DateEmpty => write!(f, "dateEmpty"),
Self::DateNotEmpty => write!(f, "dateNotEmpty"),
Self::After => write!(f, "after"),
Self::Before => write!(f, "before"),
Self::Between => write!(f, "between"),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
pub struct PropertyConditionValueDateRange {
pub from: chrono::DateTime<chrono::Utc>,
pub to: chrono::DateTime<chrono::Utc>,
}
/// The comparison value. Omitted for value-less operators (e.g. `isTrue`, `empty`). A `{ from, to }` object for `between`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
#[serde(untagged)]
pub enum PropertyConditionValue {
#[default]
String(String),
Number(f64),
DateRange(PropertyConditionValueDateRange),
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, oas3_gen_support::Default)]
pub enum ActivityConditionAction {
#[serde(rename = "sent")]
#[default]
Sent,
#[serde(rename = "opened")]
Opened,
#[serde(rename = "clicked")]
Clicked,
}
impl core::fmt::Display for ActivityConditionAction {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Sent => write!(f, "sent"),
Self::Opened => write!(f, "opened"),
Self::Clicked => write!(f, "clicked"),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, oas3_gen_support::Default)]
pub enum ActivityConditionTarget {
#[serde(rename = "campaign")]
#[default]
Campaign,
#[serde(rename = "workflow")]
Workflow,
#[serde(rename = "workflowEmail")]
WorkflowEmail,
}
impl core::fmt::Display for ActivityConditionTarget {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Campaign => write!(f, "campaign"),
Self::Workflow => write!(f, "workflow"),
Self::WorkflowEmail => write!(f, "workflowEmail"),
}
}
}
/// The status of the campaign.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, oas3_gen_support::Default)]
pub enum Status2 {
#[default]
Draft,
Scheduled,
Sending,
Sent,
}
impl core::fmt::Display for Status2 {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Draft => write!(f, "Draft"),
Self::Scheduled => write!(f, "Scheduled"),
Self::Sending => write!(f, "Sending"),
Self::Sent => write!(f, "Sent"),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, oas3_gen_support::Default)]
pub enum SimplifiedWorkflowStatus {
#[default]
Draft,
Sending,
Paused,
PausedAndQueueing,
}
impl core::fmt::Display for SimplifiedWorkflowStatus {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Draft => write!(f, "Draft"),
Self::Sending => write!(f, "Sending"),
Self::Paused => write!(f, "Paused"),
Self::PausedAndQueueing => write!(f, "PausedAndQueueing"),
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct CreateWorkflowNodeBeforeRequestTargetNode {
#[serde(rename = "toNodeId")]
#[validate(length(min = 1u64))]
pub to_node_id: String,
}
#[derive(Debug, Clone, PartialEq, Serialize, validator::Validate, oas3_gen_support::Default)]
pub struct CreateWorkflowNodeBeforeRequestTargetNodeDeprecated {
#[deprecated]
#[serde(rename = "beforeNodeId")]
#[validate(length(min = 1u64))]
pub before_node_id: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, oas3_gen_support::Default)]
pub enum PreviewStatus {
#[serde(rename = "dryRun")]
#[default]
DryRun,
#[serde(rename = "queuedContactsFound")]
QueuedContactsFound,
}
impl core::fmt::Display for PreviewStatus {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::DryRun => write!(f, "dryRun"),
Self::QueuedContactsFound => write!(f, "queuedContactsFound"),
}
}
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ListEventPatternsResponsePagination {
#[serde(rename = "totalResults")]
pub total_results: Option<f64>,
#[serde(rename = "returnedResults")]
pub returned_results: Option<f64>,
#[serde(rename = "perPage")]
pub per_page: Option<f64>,
#[serde(rename = "totalPages")]
pub total_pages: Option<f64>,
#[serde(rename = "nextCursor")]
pub next_cursor: Option<String>,
#[serde(rename = "nextPage")]
pub next_page: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, oas3_gen_support::Default)]
#[serde(untagged)]
pub enum WorkflowContactPropertyComparisonValue {
#[default]
String(String),
Number(f64),
Boolean(bool),
}
/// The comparison operator. It must be valid for the selected contact property's type and for the `is` or `was` side of the comparison. Number and boolean properties allow `empty` on `was`, but not on `is`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, oas3_gen_support::Default)]
pub enum WorkflowContactPropertyComparisonOperator {
#[serde(rename = "any")]
#[default]
Any,
#[serde(rename = "contains")]
Contains,
#[serde(rename = "not_contains")]
NotContains,
#[serde(rename = "empty")]
Empty,
#[serde(rename = "not_empty")]
NotEmpty,
#[serde(rename = "equal")]
Equal,
#[serde(rename = "not_equal")]
NotEqual,
#[serde(rename = "greater_than")]
GreaterThan,
#[serde(rename = "less_than")]
LessThan,
#[serde(rename = "true")]
True,
#[serde(rename = "false")]
False,
#[serde(rename = "numeric_equal")]
NumericEqual,
#[serde(rename = "numeric_not_equal")]
NumericNotEqual,
#[serde(rename = "after")]
After,
#[serde(rename = "before")]
Before,
#[serde(rename = "between")]
Between,
}
impl core::fmt::Display for WorkflowContactPropertyComparisonOperator {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Any => write!(f, "any"),
Self::Contains => write!(f, "contains"),
Self::NotContains => write!(f, "not_contains"),
Self::Empty => write!(f, "empty"),
Self::NotEmpty => write!(f, "not_empty"),
Self::Equal => write!(f, "equal"),
Self::NotEqual => write!(f, "not_equal"),
Self::GreaterThan => write!(f, "greater_than"),
Self::LessThan => write!(f, "less_than"),
Self::True => write!(f, "true"),
Self::False => write!(f, "false"),
Self::NumericEqual => write!(f, "numeric_equal"),
Self::NumericNotEqual => write!(f, "numeric_not_equal"),
Self::After => write!(f, "after"),
Self::Before => write!(f, "before"),
Self::Between => write!(f, "between"),
}
}
}
/// The rendering format of the email.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, oas3_gen_support::Default)]
pub enum EmailFormat {
#[serde(rename = "styled")]
#[default]
Styled,
#[serde(rename = "plain")]
Plain,
}
impl core::fmt::Display for EmailFormat {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Styled => write!(f, "styled"),
Self::Plain => write!(f, "plain"),
}
}
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(default)]
pub struct EmailMessageResponseWarning {
pub rule: String,
#[default("warning".to_string())]
pub severity: String,
pub message: String,
pub path: Option<String>,
}
/// The identifier of the Guardian rule that fired.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, oas3_gen_support::Default)]
pub enum GuardianRuleRule {
#[serde(rename = "unsupportedContactProperties")]
#[default]
UnsupportedContactProperties,
#[serde(rename = "missingFallbackContactProperties")]
MissingFallbackContactProperties,
#[serde(rename = "unsupportedEventProperties")]
UnsupportedEventProperties,
#[serde(rename = "missingFallbackEventProperties")]
MissingFallbackEventProperties,
#[serde(rename = "unsupportedDataVariables")]
UnsupportedDataVariables,
#[serde(rename = "invalidCustomDataVariables")]
InvalidCustomDataVariables,
#[serde(rename = "missingRequiredDataVariables")]
MissingRequiredDataVariables,
#[serde(rename = "missingButtonHrefs")]
MissingButtonHrefs,
#[serde(rename = "invalidButtonHrefs")]
InvalidButtonHrefs,
#[serde(rename = "shortenedYouTubeButtonHrefs")]
ShortenedYouTubeButtonHrefs,
#[serde(rename = "missingLinkHrefs")]
MissingLinkHrefs,
#[serde(rename = "invalidLinkHrefs")]
InvalidLinkHrefs,
#[serde(rename = "shortenedYouTubeLinkHrefs")]
ShortenedYouTubeLinkHrefs,
#[serde(rename = "shortenedYouTubeImageHrefs")]
ShortenedYouTubeImageHrefs,
#[serde(rename = "emailWithoutMailtoButtonHrefs")]
EmailWithoutMailtoButtonHrefs,
#[serde(rename = "emailWithoutMailtoLinkHrefs")]
EmailWithoutMailtoLinkHrefs,
#[serde(rename = "emailWithoutMailtoImageHrefs")]
EmailWithoutMailtoImageHrefs,
#[serde(rename = "bareArrayNodes")]
BareArrayNodes,
#[serde(rename = "missingSocialIconHrefs")]
MissingSocialIconHrefs,
}
impl core::fmt::Display for GuardianRuleRule {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::UnsupportedContactProperties => {
write!(f, "unsupportedContactProperties")
}
Self::MissingFallbackContactProperties => {
write!(f, "missingFallbackContactProperties")
}
Self::UnsupportedEventProperties => write!(f, "unsupportedEventProperties"),
Self::MissingFallbackEventProperties => {
write!(f, "missingFallbackEventProperties")
}
Self::UnsupportedDataVariables => write!(f, "unsupportedDataVariables"),
Self::InvalidCustomDataVariables => write!(f, "invalidCustomDataVariables"),
Self::MissingRequiredDataVariables => {
write!(f, "missingRequiredDataVariables")
}
Self::MissingButtonHrefs => write!(f, "missingButtonHrefs"),
Self::InvalidButtonHrefs => write!(f, "invalidButtonHrefs"),
Self::ShortenedYouTubeButtonHrefs => write!(f, "shortenedYouTubeButtonHrefs"),
Self::MissingLinkHrefs => write!(f, "missingLinkHrefs"),
Self::InvalidLinkHrefs => write!(f, "invalidLinkHrefs"),
Self::ShortenedYouTubeLinkHrefs => write!(f, "shortenedYouTubeLinkHrefs"),
Self::ShortenedYouTubeImageHrefs => write!(f, "shortenedYouTubeImageHrefs"),
Self::EmailWithoutMailtoButtonHrefs => {
write!(f, "emailWithoutMailtoButtonHrefs")
}
Self::EmailWithoutMailtoLinkHrefs => write!(f, "emailWithoutMailtoLinkHrefs"),
Self::EmailWithoutMailtoImageHrefs => {
write!(f, "emailWithoutMailtoImageHrefs")
}
Self::BareArrayNodes => write!(f, "bareArrayNodes"),
Self::MissingSocialIconHrefs => write!(f, "missingSocialIconHrefs"),
}
}
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct GuardianRuleItem {
/// A human-readable label for the item (for example, link text or a property name).
pub label: String,
/// Machine-readable identifier when the rule refers to a property or variable, when applicable.
/// - Example: `Some("firstName".to_string())`
#[serde(rename = "codeName")]
pub code_name: Option<String>,
}
/// The type of email this event relates to. Workflow emails use `loop`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, oas3_gen_support::Default)]
pub enum WebhookEmailMetricPayloadSourceType {
#[serde(rename = "loop")]
#[default]
Loop,
#[serde(rename = "campaign")]
Campaign,
#[serde(rename = "transactional")]
Transactional,
}
impl core::fmt::Display for WebhookEmailMetricPayloadSourceType {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Loop => write!(f, "loop"),
Self::Campaign => write!(f, "campaign"),
Self::Transactional => write!(f, "transactional"),
}
}
}
/// The type of email this event relates to. Workflow emails use `loop`. Not available for transactional emails.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, oas3_gen_support::Default)]
pub enum WebhookMarketingEmailMetricPayloadSourceType {
#[serde(rename = "loop")]
#[default]
Loop,
#[serde(rename = "campaign")]
Campaign,
}
impl core::fmt::Display for WebhookMarketingEmailMetricPayloadSourceType {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Loop => write!(f, "loop"),
Self::Campaign => write!(f, "campaign"),
}
}
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ApiKey200Response {
pub success: bool,
/// The name of the team the API key belongs to.
#[serde(rename = "teamName")]
pub team_name: String,
}
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
pub struct ApiKey401Response {
pub success: Option<bool>,
pub message: Option<String>,
#[deprecated]
pub error: Option<String>,
}
pub type Find200Response = Vec<Contact>;
pub type Property200Response = Vec<ContactProperty>;
pub type List200Response = Vec<MailingList>;
#[derive(Debug, Clone, PartialEq, Deserialize, oas3_gen_support::Default)]
#[serde(untagged)]
pub enum Transactional400Response {
#[default]
SendFailure(TransactionalSendFailureResponse),
Failure2(TransactionalFailure2Response),
Failure3(TransactionalFailure3Response),
Failure4(TransactionalFailure4Response),
Failure5(TransactionalFailure5Response),
}