/*
 * 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};

/// ReviewWebhookReview : Review data shared by review.new and review.updated payloads.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ReviewWebhookReview {
    /// Platform review ID (e.g. \"accounts/123/locations/456/reviews/789\" for Google Business).
    #[serde(rename = "id")]
    pub id: String,
    /// Platform the review originated on. Currently Google Business Profile only.
    #[serde(rename = "platform")]
    pub platform: Platform,
    /// Star rating the reviewer gave.
    #[serde(rename = "rating")]
    pub rating: i32,
    /// Review text content. May be empty if the reviewer left only a rating.
    #[serde(rename = "text")]
    pub text: String,
    #[serde(rename = "reviewer")]
    pub reviewer: Box<models::ReviewWebhookReviewReviewer>,
    #[serde(rename = "createdAt")]
    pub created_at: String,
    /// Whether the connected account has replied to this review.
    #[serde(rename = "hasReply")]
    pub has_reply: bool,
    #[serde(rename = "reply", skip_serializing_if = "Option::is_none")]
    pub reply: Option<Box<models::ReviewWebhookReviewReply>>,
}

impl ReviewWebhookReview {
    /// Review data shared by review.new and review.updated payloads.
    pub fn new(
        id: String,
        platform: Platform,
        rating: i32,
        text: String,
        reviewer: models::ReviewWebhookReviewReviewer,
        created_at: String,
        has_reply: bool,
    ) -> ReviewWebhookReview {
        ReviewWebhookReview {
            id,
            platform,
            rating,
            text,
            reviewer: Box::new(reviewer),
            created_at,
            has_reply,
            reply: None,
        }
    }
}
/// Platform the review originated on. Currently Google Business Profile only.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Platform {
    #[serde(rename = "googlebusiness")]
    Googlebusiness,
}

impl Default for Platform {
    fn default() -> Platform {
        Self::Googlebusiness
    }
}
