/*
* Zernio API
*
* API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api Versioning and deprecation: all endpoints are versioned in the URL path (current version: /v1). Breaking changes only ship in a new path version; existing versions keep working. Deprecated operations are marked 'deprecated: true' in this spec and announced in the changelog (https://zernio.com/changelog) before removal. Errors: every 4xx/5xx response is application/json with a machine-readable 'code' and a human-readable 'error' message (see the ErrorResponse schema). Request ids: responses carry an X-Request-Id header with the id we log the request under. Quote it when reporting a problem. A valid x-request-id you send is reused as that id.
*
* The version of the OpenAPI document: 1.104.0
* Contact: support@zernio.com
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// ErrorResponse : Canonical error envelope. `error` is the human-readable message; `type`, `code`, `param`, `platform`, and `platformError` are top-level siblings for programmatic handling. For upstream platform failures (`type: platform_error`), `platformError` carries the provider's raw payload verbatim (for Meta: `error_subcode`, `error_user_title`, `error_user_msg`).
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ErrorResponse {
/// Human-readable error message.
#[serde(rename = "error", skip_serializing_if = "Option::is_none")]
pub error: Option<String>,
/// Error class for programmatic handling.
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
pub r#type: Option<Type>,
/// Stable machine-readable error code.
#[serde(rename = "code", skip_serializing_if = "Option::is_none")]
pub code: Option<String>,
/// The request field that caused the error, when applicable.
#[serde(rename = "param", skip_serializing_if = "Option::is_none")]
pub param: Option<String>,
/// Upstream platform (e.g. meta, google, tiktok), present when type is platform_error.
#[serde(rename = "platform", skip_serializing_if = "Option::is_none")]
pub platform: Option<String>,
/// Raw error payload from the upstream platform, passed through verbatim so integrators can read provider-specific codes. For Meta this includes error_subcode, error_user_title, and error_user_msg.
#[serde(rename = "platformError", skip_serializing_if = "Option::is_none")]
pub platform_error: Option<std::collections::HashMap<String, serde_json::Value>>,
#[serde(rename = "details", skip_serializing_if = "Option::is_none")]
pub details: Option<models::ErrorResponseDetails>,
}
impl ErrorResponse {
/// Canonical error envelope. `error` is the human-readable message; `type`, `code`, `param`, `platform`, and `platformError` are top-level siblings for programmatic handling. For upstream platform failures (`type: platform_error`), `platformError` carries the provider's raw payload verbatim (for Meta: `error_subcode`, `error_user_title`, `error_user_msg`).
pub fn new() -> ErrorResponse {
ErrorResponse {
error: None,
r#type: None,
code: None,
param: None,
platform: None,
platform_error: None,
details: None,
}
}
}
/// Error class for programmatic handling.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "invalid_request_error")]
InvalidRequestError,
#[serde(rename = "authentication_error")]
AuthenticationError,
#[serde(rename = "permission_error")]
PermissionError,
#[serde(rename = "not_found")]
NotFound,
#[serde(rename = "rate_limit_error")]
RateLimitError,
#[serde(rename = "platform_error")]
PlatformError,
#[serde(rename = "api_error")]
ApiError,
}
impl Default for Type {
fn default() -> Type {
Self::InvalidRequestError
}
}