Skip to main content

app_store_server_library/models/
decoded_realtime_request_body.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use serde_with::formats::Flexible;
4use serde_with::TimestampMilliSeconds;
5use uuid::Uuid;
6
7use crate::models::app_store_environment::Environment;
8use crate::models::decoded_signed_data::DecodedSignedData;
9
10/// The decoded request body the App Store sends to your server to request a real-time retention message.
11///
12/// [DecodedRealtimeRequestBody](https://developer.apple.com/documentation/retentionmessaging/decodedrealtimerequestbody)
13#[serde_with::serde_as]
14#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq)]
15pub struct DecodedRealtimeRequestBody {
16    /// The original transaction identifier of the customer's subscription.
17    ///
18    /// [originalTransactionId](https://developer.apple.com/documentation/retentionmessaging/originaltransactionid)
19    #[serde(rename = "originalTransactionId")]
20    pub original_transaction_id: String,
21
22    /// The unique identifier of the app in the App Store.
23    ///
24    /// [appAppleId](https://developer.apple.com/documentation/retentionmessaging/appappleid)
25    #[serde(rename = "appAppleId")]
26    pub app_apple_id: i64,
27
28    /// The unique identifier of the auto-renewable subscription.
29    ///
30    /// [productId](https://developer.apple.com/documentation/retentionmessaging/productid)
31    #[serde(rename = "productId")]
32    pub product_id: String,
33
34    /// The device's locale.
35    ///
36    /// [locale](https://developer.apple.com/documentation/retentionmessaging/locale)
37    #[serde(rename = "userLocale")]
38    pub user_locale: String,
39
40    /// A UUID the App Store server creates to uniquely identify each request.
41    ///
42    /// [requestIdentifier](https://developer.apple.com/documentation/retentionmessaging/requestidentifier)
43    #[serde(rename = "requestIdentifier")]
44    pub request_identifier: Uuid,
45
46    /// The UNIX time, in milliseconds, that the App Store signed the JSON Web Signature (JWS) data.
47    ///
48    /// [signedDate](https://developer.apple.com/documentation/retentionmessaging/signeddate)
49    #[serde(rename = "signedDate")]
50    #[serde_as(as = "TimestampMilliSeconds<String, Flexible>")]
51    pub signed_date: DateTime<Utc>,
52
53    /// The server environment, either sandbox or production.
54    ///
55    /// [environment](https://developer.apple.com/documentation/retentionmessaging/environment)
56    pub environment: Environment,
57}
58
59impl DecodedSignedData for DecodedRealtimeRequestBody {
60    fn signed_date_optional(&self) -> Option<DateTime<Utc>> {
61        Some(self.signed_date)
62    }
63}