use crate::primitives::in_app_ownership_type::InAppOwnershipType;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use serde_with::formats::Flexible;
use serde_with::TimestampMilliSeconds;
#[serde_with::serde_as]
#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq)]
pub struct TransactionHistoryRequest {
#[serde(rename = "startDate")]
#[serde_as(as = "Option<TimestampMilliSeconds<String, Flexible>>")]
pub start_date: Option<DateTime<Utc>>,
#[serde(rename = "endDate")]
#[serde_as(as = "Option<TimestampMilliSeconds<String, Flexible>>")]
pub end_date: Option<DateTime<Utc>>,
#[serde(rename = "productIds")]
pub product_ids: Option<Vec<String>>,
#[serde(rename = "productTypes")]
pub product_types: Option<Vec<ProductType>>,
pub sort: Option<Order>,
#[serde(rename = "subscriptionGroupIdentifiers")]
pub subscription_group_identifiers: Option<Vec<String>>,
#[serde(rename = "inAppOwnershipType")]
pub in_app_ownership_type: Option<InAppOwnershipType>,
pub revoked: Option<bool>,
}
#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq)]
pub enum ProductType {
#[serde(rename = "AUTO_RENEWABLE")]
AutoRenewable,
#[serde(rename = "NON_RENEWABLE")]
NonRenewable,
#[serde(rename = "CONSUMABLE")]
Consumable,
#[serde(rename = "NON_CONSUMABLE")]
NonConsumable,
}
impl ProductType {
pub fn raw_value(&self) -> &str {
match self {
ProductType::AutoRenewable => "AUTO_RENEWABLE",
ProductType::NonRenewable => "NON_RENEWABLE",
ProductType::Consumable => "CONSUMABLE",
ProductType::NonConsumable => "NON_CONSUMABLE",
}
}
}
#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq)]
pub enum Order {
#[serde(rename = "ASCENDING")]
Ascending,
#[serde(rename = "DESCENDING")]
Descending,
}
impl Order {
pub fn raw_value(&self) -> &str {
match self {
Order::Ascending => "ASCENDING",
Order::Descending => "DESCENDING",
}
}
}