Skip to main content

hdm_am/operations/
misc.rs

1use crate::wire::OperationCode;
2use serde::{Deserialize, Serialize};
3
4use super::{EmptyResponse, Operation};
5
6/// Op 12 request: query the device's current date and time.
7#[derive(Debug, Clone, Serialize)]
8#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
9pub struct DateTimeRequest {}
10
11impl Operation for DateTimeRequest {
12    const CODE: OperationCode = OperationCode::DateTime;
13    type Response = DateTimeResponse;
14}
15
16/// Op 12 response.
17#[derive(Debug, Clone, Deserialize, Serialize)]
18#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
19#[non_exhaustive]
20pub struct DateTimeResponse {
21    /// Device date and time as a string. Spec does not pin the format; treat as opaque.
22    pub dt: String,
23}
24
25/// Op 13 request: trigger a sample-receipt print.
26#[derive(Debug, Clone, Serialize)]
27#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
28pub struct ReceiptSampleRequest {}
29
30impl Operation for ReceiptSampleRequest {
31    const CODE: OperationCode = OperationCode::ReceiptSample;
32    type Response = EmptyResponse;
33}
34
35/// Op 14 request: synchronise the HDM with the tax authority.
36#[derive(Debug, Clone, Serialize)]
37#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
38pub struct HdmTimeSyncRequest {}
39
40impl Operation for HdmTimeSyncRequest {
41    const CODE: OperationCode = OperationCode::HdmTimeSync;
42    type Response = EmptyResponse;
43}
44
45/// Op 15 request: discover the payment-system codes installed on the HDM device.
46#[derive(Debug, Clone, Serialize)]
47#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
48pub struct PaymentSystemsListRequest {}
49
50impl Operation for PaymentSystemsListRequest {
51    const CODE: OperationCode = OperationCode::PaymentSystemsList;
52    type Response = PaymentSystemsListResponse;
53}
54
55/// Op 15 response: list of payment systems configured on the device.
56#[derive(Debug, Clone, Deserialize, Serialize)]
57#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
58#[non_exhaustive]
59pub struct PaymentSystemsListResponse {
60    /// One entry per configured payment system.
61    #[serde(rename = "PaymentSystems", default)]
62    pub payment_systems: Vec<PaymentSystemEntry>,
63}
64
65/// A single payment-system entry from op 15. Codes are documented in spec §4.8 (1 = card,
66/// 10-18 = various Armenian mobile wallets).
67#[derive(Debug, Clone, Deserialize, Serialize)]
68#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
69#[non_exhaustive]
70pub struct PaymentSystemEntry {
71    /// Payment-system code (used in [`super::receipt::PrintReceiptRequest::payment_system`]).
72    pub code: u32,
73    /// Display name.
74    #[serde(default)]
75    pub name: String,
76}
77
78/// Op 16 request: submit a single eMark traceability code.
79#[derive(Debug, Clone, Serialize, Deserialize)]
80#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
81pub struct SingleEmarkRequest {
82    /// eMark code. Per spec §4.9: 29-110 chars, ASCII-printable only (33-126 plus 29 as
83    /// delimiter); `"` escaped as `\"`, `\` as `\\`, and ASCII 29 used as the group separator.
84    #[serde(rename = "eMark")]
85    pub e_mark: String,
86}
87
88impl Operation for SingleEmarkRequest {
89    const CODE: OperationCode = OperationCode::SingleEmark;
90    type Response = EmptyResponse;
91}