1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
use crate::primitives::environment::Environment;
use crate::primitives::purchase_platform::PurchasePlatform;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use serde_with::formats::Flexible;
use serde_with::TimestampMilliSeconds;
use uuid::Uuid;
/// Information that represents the customer’s purchase of the app, cryptographically signed by the App Store.
///
/// [AppTransaction](https://developer.apple.com/documentation/storekit/apptransaction)
#[serde_with::serde_as]
#[derive(Debug, Clone, Deserialize, Serialize, Hash)]
pub struct AppTransaction {
/// The server environment that signs the app transaction.
/// [environment](https://developer.apple.com/documentation/storekit/apptransaction/3963901-environment)
#[serde(rename = "receiptType")]
pub receipt_type: Option<Environment>,
/// The unique identifier the App Store uses to identify the app.
/// [appId](https://developer.apple.com/documentation/storekit/apptransaction/3954436-appid)
#[serde(rename = "appAppleId")]
pub app_apple_id: Option<i64>,
/// The bundle identifier that the app transaction applies to.
/// [bundle_id](https://developer.apple.com/documentation/storekit/apptransaction/3954439-bundleid)
#[serde(rename = "bundleId")]
pub bundle_id: Option<String>,
/// The app version that the app transaction applies to.
/// [appVersion](https://developer.apple.com/documentation/storekit/apptransaction/3954437-appversion)
#[serde(rename = "applicationVersion")]
pub application_version: Option<String>,
/// The version external identifier of the app.
/// [appVersionID](https://developer.apple.com/documentation/storekit/apptransaction/3954438-appversionid)
#[serde(rename = "versionExternalIdentifier")]
pub version_external_identifier: Option<i64>,
/// The date that the App Store signed the JWS app transaction.
/// [signedDate](https://developer.apple.com/documentation/storekit/apptransaction/3954449-signeddate)
#[serde(rename = "receiptCreationDate")]
#[serde_as(as = "Option<TimestampMilliSeconds<String, Flexible>>")]
pub receipt_creation_date: Option<DateTime<Utc>>,
/// The date the user originally purchased the app from the App Store.
/// [originalPurchaseDate](https://developer.apple.com/documentation/storekit/apptransaction/3954448-originalpurchasedate)
#[serde(rename = "originalPurchaseDate")]
#[serde_as(as = "Option<TimestampMilliSeconds<String, Flexible>>")]
pub original_purchase_date: Option<DateTime<Utc>>,
/// The app version that the user originally purchased from the App Store.
/// [originalAppVersion](https://developer.apple.com/documentation/storekit/apptransaction/3954447-originalappversion)
#[serde(rename = "originalApplicationVersion")]
pub original_application_version: Option<String>,
/// The Base64 device verification value to use to verify whether the app transaction belongs to the device.
/// [deviceVerification](https://developer.apple.com/documentation/storekit/apptransaction/3954441-deviceverification)
#[serde(rename = "deviceVerification")]
pub device_verification: Option<String>,
/// The UUID used to compute the device verification value.
/// [deviceVerificationNonce](https://developer.apple.com/documentation/storekit/apptransaction/3954442-deviceverificationnonce)
#[serde(rename = "deviceVerificationNonce")]
pub device_verification_nonce: Option<Uuid>,
/// The date the customer placed an order for the app before it’s available in the App Store.
/// [preorderDate](https://developer.apple.com/documentation/storekit/apptransaction/4013175-preorderdate)
#[serde(rename = "preorderDate")]
#[serde_as(as = "Option<TimestampMilliSeconds<String, Flexible>>")]
pub preorder_date: Option<DateTime<Utc>>,
/// The unique identifier of the app download transaction.
///
/// [appTransactionId](https://developer.apple.com/documentation/storekit/apptransaction/apptransactionid)
#[serde(rename = "appTransactionId")]
pub app_transaction_id: Option<String>,
/// The platform on which the customer originally purchased the app.
///
/// [original_platform](https://developer.apple.com/documentation/storekit/apptransaction/originalplatform)
#[serde(rename = "originalPlatform")]
pub original_platform: Option<PurchasePlatform>,
}
impl AppTransaction {
/// The date that the App Store signed the JWS app transaction.
/// [signedDate](https://developer.apple.com/documentation/storekit/apptransaction/3954449-signeddate)
pub fn signed_date(&self) -> Option<DateTime<Utc>> {
self.receipt_creation_date
}
}