smart_id_rust_client/models/api/certificate_choice_session.rs
1use crate::config::SmartIDConfig;
2use crate::models::api::response::SmartIdAPIResponse;
3use crate::models::common::{CertificateLevel, RequestProperties};
4use serde::{Deserialize, Serialize};
5use serde_with::skip_serializing_none;
6
7// region CertificateChoiceDeviceLinkSessionRequest
8
9/// Certificate Choice Device link Request
10///
11/// This struct represents a request for choosing a certificate with the Smart ID service.
12/// It includes various parameters required for the certificate choice process.
13///
14/// # Properties
15///
16/// * `relying_party_uuid` - The UUID of the relying party, provided by Smart ID.
17/// * `relying_party_name` - The name of the relying party, provided by Smart ID.
18/// * `initial_callback_url` - The initial callback URL for the request, used for device link flows (not required in QR flows).
19/// * `certificate_level` - The level of the certificate required for the request.
20/// * `nonce` - An optional nonce for the request.
21/// * `capabilities` - Used only when agreed with Smart-ID provider. When omitted request capabilities are derived from certificateLevel parameter.
22/// * `request_properties` - Optional properties for the request.
23///
24/// # Example
25///
26/// ```rust
27/// use smart_id_rust_client::config::SmartIDConfig;
28/// use smart_id_rust_client::models::api::certificate_choice_session::CertificateChoiceDeviceLinkRequest;
29///
30/// fn create_certificate_choice_request(cfg: &SmartIDConfig) -> CertificateChoiceDeviceLinkRequest {
31/// CertificateChoiceDeviceLinkRequest::new(cfg)
32/// }
33/// ```
34#[skip_serializing_none]
35#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
36#[serde(rename_all = "camelCase")]
37pub struct CertificateChoiceDeviceLinkRequest {
38 #[serde(rename = "relyingPartyUUID")]
39 pub relying_party_uuid: String,
40 pub relying_party_name: String,
41 pub initial_callback_url: Option<String>,
42 pub certificate_level: CertificateLevel,
43 pub nonce: Option<String>,
44 pub capabilities: Option<Vec<String>>,
45 pub request_properties: Option<RequestProperties>,
46}
47
48impl CertificateChoiceDeviceLinkRequest {
49 pub fn new(cfg: &SmartIDConfig) -> Self {
50 CertificateChoiceDeviceLinkRequest {
51 relying_party_uuid: cfg.relying_party_uuid.clone(),
52 relying_party_name: cfg.relying_party_name.clone(),
53 certificate_level: CertificateLevel::QUALIFIED,
54 ..Self::default()
55 }
56 }
57}
58
59#[allow(dead_code)]
60pub(crate) type CertificateChoiceDeviceLinkResponse =
61 SmartIdAPIResponse<CertificateChoiceDeviceLinkSession>;
62
63#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
64#[serde(rename_all = "camelCase")]
65pub struct CertificateChoiceDeviceLinkSession {
66 #[serde(rename = "sessionID")]
67 pub session_id: String,
68 pub session_token: String,
69 pub session_secret: String,
70 pub device_link_base: String,
71}
72
73// endregion CertificateChoiceDeviceLinkSessionRequest
74
75// region CertificateChoiceNotificationRequest
76
77/// Certificate Choice Notification Request
78///
79/// This struct represents a request for choosing a certificate with the Smart ID service.
80/// It includes various parameters required for the certificate choice process.
81///
82/// # Properties
83///
84/// * `relying_party_uuid` - The UUID of the relying party, provided by Smart ID.
85/// * `relying_party_name` - The name of the relying party, provided by Smart ID.
86/// * `initial_callback_url` - The initial callback URL for the request, used for device link flows (not be required in QR flows).
87/// * `certificate_level` - The level of the certificate required for the request.
88/// * `nonce` - An optional nonce for the request.
89/// * `capabilities` - Used only when agreed with Smart-ID provider. When omitted request capabilities are derived from certificateLevel parameter.
90/// * `request_properties` - Optional properties for the request.
91///
92/// # Example
93///
94/// ```rust
95/// use smart_id_rust_client::config::SmartIDConfig;
96/// use smart_id_rust_client::models::api::certificate_choice_session::CertificateChoiceDeviceLinkRequest;
97///
98/// fn create_certificate_choice_request(cfg: &SmartIDConfig) -> CertificateChoiceDeviceLinkRequest {
99/// CertificateChoiceDeviceLinkRequest::new(cfg)
100/// }
101/// ```
102#[skip_serializing_none]
103#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
104#[serde(rename_all = "camelCase")]
105pub struct CertificateChoiceNotificationRequest {
106 #[serde(rename = "relyingPartyUUID")]
107 pub relying_party_uuid: String,
108 pub relying_party_name: String,
109 pub initial_callback_url: Option<String>,
110 pub certificate_level: CertificateLevel,
111 pub nonce: Option<String>,
112 pub capabilities: Option<Vec<String>>,
113 pub request_properties: Option<RequestProperties>,
114}
115
116impl CertificateChoiceNotificationRequest {
117 pub fn new(cfg: &SmartIDConfig) -> Self {
118 CertificateChoiceNotificationRequest {
119 relying_party_uuid: cfg.relying_party_uuid.clone(),
120 relying_party_name: cfg.relying_party_name.clone(),
121 certificate_level: CertificateLevel::QUALIFIED,
122 ..Self::default()
123 }
124 }
125}
126
127pub(crate) type CertificateChoiceNotificationResponse =
128 SmartIdAPIResponse<CertificateChoiceNotificationSession>;
129
130#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
131#[serde(rename_all = "camelCase")]
132pub struct CertificateChoiceNotificationSession {
133 #[serde(rename = "sessionID")]
134 pub session_id: String,
135}
136
137// endregion CertificateChoiceNotificationRequest
138
139// region SigningCertificateRequest
140
141/// Request to fetch the signing certificate which has a specific document number.
142///
143/// # Properties
144/// * `relying_party_uuid` - The UUID of the relying party, provided by Smart ID.
145/// * `relying_party_name` - The name of the relying party, provided by Smart ID.
146/// * `certificate_level` - The level of the certificate required for the request, either ADVANCED or QUALIFIED.
147///
148/// # Example
149/// ```rust
150/// use smart_id_rust_client::config::SmartIDConfig;
151/// use smart_id_rust_client::models::api::certificate_choice_session::SigningCertificateRequest;use smart_id_rust_client::models::common::CertificateLevel;
152/// fn create_signing_certificate_request(cfg: &SmartIDConfig) -> SigningCertificateRequest {
153/// SigningCertificateRequest {
154/// relying_party_uuid: cfg.relying_party_uuid.clone(),
155/// relying_party_name: cfg.relying_party_name.clone(),
156/// certificate_level: CertificateLevel::QUALIFIED,
157/// }
158/// }
159#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
160#[serde(rename_all = "camelCase")]
161pub struct SigningCertificateRequest {
162 #[serde(rename = "relyingPartyUUID")]
163 pub relying_party_uuid: String,
164 pub relying_party_name: String,
165 pub certificate_level: CertificateLevel,
166}
167
168#[allow(dead_code)]
169pub(crate) type SigningCertificateResponse = SmartIdAPIResponse<SigningCertificateResult>;
170
171#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
172#[serde(rename_all = "camelCase")]
173pub struct SigningCertificateResult {
174 pub state: SigningCertificateResponseState,
175 pub cert: SigningCertificate,
176}
177
178#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
179#[serde(rename_all = "UPPERCASE")]
180#[allow(non_camel_case_types)]
181pub enum SigningCertificateResponseState {
182 OK,
183 DOCUMENT_UNUSABLE,
184}
185
186#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
187#[serde(rename_all = "camelCase")]
188pub struct SigningCertificate {
189 pub value: String, // Base64 encoded DER certificate
190 pub certificate_level: CertificateLevel, // ADVANCED or QUALIFIED only
191}
192
193// endregion: SigningCertificateRequest