/*
 * Zernio API
 *
 * API reference for Zernio. Authenticate with a Bearer API key. Base URL: https://zernio.com/api
 *
 * The version of the OpenAPI document: 1.0.4
 * Contact: support@zernio.com
 * Generated by: https://openapi-generator.tech
 */

use crate::models;
use serde::{Deserialize, Serialize};

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct AdjustConversionsRequestAdjustmentsInner {
    #[serde(rename = "adjustmentType")]
    pub adjustment_type: AdjustmentType,
    /// When the adjustment occurred, unix seconds.
    #[serde(rename = "adjustmentTime")]
    pub adjustment_time: f64,
    /// Transaction ID of the original conversion (the `eventId` you sent). Recommended; required for ENHANCEMENT.
    #[serde(rename = "orderId", skip_serializing_if = "Option::is_none")]
    pub order_id: Option<String>,
    /// Alternative key — the original click ID. Pair with `conversionTime`. Not valid for ENHANCEMENT.
    #[serde(rename = "gclid", skip_serializing_if = "Option::is_none")]
    pub gclid: Option<String>,
    /// The original conversion's time, unix seconds. Required when identifying by `gclid`.
    #[serde(rename = "conversionTime", skip_serializing_if = "Option::is_none")]
    pub conversion_time: Option<f64>,
    /// RESTATEMENT only — the corrected TOTAL conversion value.
    #[serde(rename = "restatementValue", skip_serializing_if = "Option::is_none")]
    pub restatement_value: Option<f64>,
    /// RESTATEMENT only — ISO 4217 currency for `restatementValue`.
    #[serde(rename = "currency", skip_serializing_if = "Option::is_none")]
    pub currency: Option<String>,
    #[serde(rename = "user", skip_serializing_if = "Option::is_none")]
    pub user: Option<Box<models::AdjustConversionsRequestAdjustmentsInnerUser>>,
    /// ENHANCEMENT only — the original conversion's user agent (improves match quality).
    #[serde(rename = "userAgent", skip_serializing_if = "Option::is_none")]
    pub user_agent: Option<String>,
}

impl AdjustConversionsRequestAdjustmentsInner {
    pub fn new(
        adjustment_type: AdjustmentType,
        adjustment_time: f64,
    ) -> AdjustConversionsRequestAdjustmentsInner {
        AdjustConversionsRequestAdjustmentsInner {
            adjustment_type,
            adjustment_time,
            order_id: None,
            gclid: None,
            conversion_time: None,
            restatement_value: None,
            currency: None,
            user: None,
            user_agent: None,
        }
    }
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum AdjustmentType {
    #[serde(rename = "RETRACTION")]
    Retraction,
    #[serde(rename = "RESTATEMENT")]
    Restatement,
    #[serde(rename = "ENHANCEMENT")]
    Enhancement,
}

impl Default for AdjustmentType {
    fn default() -> AdjustmentType {
        Self::Retraction
    }
}
