//! The Telephony plugin allows notification of events such as incoming or missed calls.
use serde::{Deserialize, Serialize};

#[cfg(not(feature = "std"))]
use alloc::string::String;

/// This packet is a telephony event, such as the phone ringing.
///
/// <https://invent.kde.org/network/kdeconnect-meta/blob/master/protocol.md#kdeconnecttelephony>
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct TelephonyPacket {
    /// The telephony event type.
    pub event: String,

    /// The contact name associated with the event.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub contact_name: Option<String>,

    /// The phone number associated with the event.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub phone_number: Option<String>,

    /// base64 encoded JPEG.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub phone_thumbnail: Option<String>,

    /// Whether event has stopped.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default)]
    pub is_cancel: Option<bool>,
}
