app_store_server_library/primitives/
transaction_history_request.rs

1use crate::primitives::in_app_ownership_type::InAppOwnershipType;
2use chrono::{DateTime, Utc};
3use serde::{Deserialize, Serialize};
4use serde_with::formats::Flexible;
5use serde_with::TimestampMilliSeconds;
6
7#[serde_with::serde_as]
8#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq)]
9pub struct TransactionHistoryRequest {
10    /// An optional start date of the timespan for the transaction history records you’re requesting.
11    #[serde(rename = "startDate")]
12    #[serde_as(as = "Option<TimestampMilliSeconds<String, Flexible>>")]
13    pub start_date: Option<DateTime<Utc>>,
14
15    /// An optional end date of the timespan for the transaction history records you’re requesting.
16    #[serde(rename = "endDate")]
17    #[serde_as(as = "Option<TimestampMilliSeconds<String, Flexible>>")]
18    pub end_date: Option<DateTime<Utc>>,
19
20    /// An optional filter that indicates the product identifier to include in the transaction history.
21    #[serde(rename = "productIds")]
22    pub product_ids: Option<Vec<String>>,
23
24    /// An optional filter that indicates the product type to include in the transaction history.
25    #[serde(rename = "productTypes")]
26    pub product_types: Option<Vec<ProductType>>,
27
28    /// An optional sort order for the transaction history records.
29    pub sort: Option<Order>,
30
31    /// An optional filter that indicates the subscription group identifier to include in the transaction history.
32    #[serde(rename = "subscriptionGroupIdentifiers")]
33    pub subscription_group_identifiers: Option<Vec<String>>,
34
35    /// An optional filter that limits the transaction history by the in-app ownership type.
36    #[serde(rename = "inAppOwnershipType")]
37    pub in_app_ownership_type: Option<InAppOwnershipType>,
38
39    /// An optional Boolean value that indicates whether the response includes only revoked transactions.
40    pub revoked: Option<bool>,
41}
42
43#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq)]
44pub enum ProductType {
45    #[serde(rename = "AUTO_RENEWABLE")]
46    AutoRenewable,
47    #[serde(rename = "NON_RENEWABLE")]
48    NonRenewable,
49    #[serde(rename = "CONSUMABLE")]
50    Consumable,
51    #[serde(rename = "NON_CONSUMABLE")]
52    NonConsumable,
53}
54
55impl ProductType {
56    pub fn raw_value(&self) -> &str {
57        match self {
58            ProductType::AutoRenewable => "AUTO_RENEWABLE",
59            ProductType::NonRenewable => "NON_RENEWABLE",
60            ProductType::Consumable => "CONSUMABLE",
61            ProductType::NonConsumable => "NON_CONSUMABLE",
62        }
63    }
64}
65
66#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq)]
67pub enum Order {
68    #[serde(rename = "ASCENDING")]
69    Ascending,
70    #[serde(rename = "DESCENDING")]
71    Descending,
72}
73
74impl Order {
75    pub fn raw_value(&self) -> &str {
76        match self {
77            Order::Ascending => "ASCENDING",
78            Order::Descending => "DESCENDING",
79        }
80    }
81}