app_store_server_library/primitives/advanced_commerce/
request_info.rs

1use serde::{Deserialize, Serialize};
2use uuid::Uuid;
3
4/// The metadata to include in Advanced Commerce server requests.
5///
6/// [RequestInfo](https://developer.apple.com/documentation/advancedcommerceapi/requestinfo)
7#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq)]
8#[serde(rename_all = "camelCase")]
9pub struct RequestInfo {
10    /// The app account token for the request.
11    ///
12    /// [App Account Token](https://developer.apple.com/documentation/advancedcommerceapi/appaccounttoken)
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub app_account_token: Option<Uuid>,
15    
16    /// The consistency token for the request.
17    ///
18    /// [Consistency Token](https://developer.apple.com/documentation/advancedcommerceapi/consistencytoken)
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub consistency_token: Option<String>,
21    
22    /// The request reference identifier.
23    ///
24    /// [Request Reference ID](https://developer.apple.com/documentation/advancedcommerceapi/requestreferenceid)
25    pub request_reference_id: Uuid,
26}
27
28impl RequestInfo {
29    pub fn new(request_reference_id: Uuid) -> Self {
30        Self {
31            app_account_token: None,
32            consistency_token: None,
33            request_reference_id,
34        }
35    }
36    
37    pub fn with_app_account_token(mut self, token: Uuid) -> Self {
38        self.app_account_token = Some(token);
39        self
40    }
41    
42    pub fn with_consistency_token(mut self, token: String) -> Self {
43        self.consistency_token = Some(token);
44        self
45    }
46}