1use serde::{Deserialize, Serialize};
4
5#[derive(Serialize, PartialEq, Default, Debug, Clone, Copy)]
11pub struct HttpPaginationOptions {
12 #[serde(skip_serializing_if = "Option::is_none")]
14 pub limit: Option<u64>,
15
16 #[serde(skip_serializing_if = "Option::is_none")]
20 pub offset: Option<u64>,
21
22 #[serde(skip_serializing_if = "Option::is_none")]
25 pub reverse: Option<bool>,
26}
27impl HttpPaginationOptions {
28 #[must_use]
30 pub fn with_limit(mut self, limit: u64) -> Self {
31 self.limit = Some(limit);
32 self
33 }
34
35 #[must_use]
37 pub fn with_offset(mut self, offset: u64) -> Self {
38 self.offset = Some(offset);
39 self
40 }
41
42 #[must_use]
44 pub fn with_reverse(mut self, reverse: bool) -> Self {
45 self.reverse = Some(reverse);
46 self
47 }
48
49 pub fn add_to_body(&self, body: &mut serde_json::Value) {
51 if let Some(limit) = self.limit {
52 body["limit"] = serde_json::json!(limit);
53 }
54 if let Some(offset) = self.offset {
55 body["offset"] = serde_json::json!(offset);
56 }
57 if let Some(reverse) = self.reverse {
58 body["reverse"] = serde_json::json!(reverse);
59 }
60 }
61}
62
63#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Copy)]
65#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
66pub struct HttpSmsSendResponse {
67 pub message_id: i64,
69
70 pub reference_id: u8,
72}
73
74impl From<(crate::sms::SmsOutgoingMessage, HttpSmsSendResponse)> for crate::sms::SmsMessage {
76 fn from(
77 value: (crate::sms::SmsOutgoingMessage, HttpSmsSendResponse),
78 ) -> crate::sms::SmsMessage {
79 crate::sms::SmsMessage {
80 message_id: Some(value.1.message_id),
81 phone_number: value.0.to,
82 message_content: value.0.content,
83 message_reference: Some(value.1.reference_id),
84 is_outgoing: true,
85 status: None,
86 created_at: None,
87 completed_at: None,
88 }
89 }
90}
91
92#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Copy)]
94#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
95pub struct HttpModemNetworkStatusResponse {
96 pub registration: u8,
98
99 pub technology: u8,
101}
102
103#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Copy)]
105#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
106pub struct HttpModemSignalStrengthResponse {
107 pub rssi: i32,
109
110 pub ber: i32,
112}
113
114#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
116#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
117pub struct HttpModemNetworkOperatorResponse {
118 pub status: u8,
120
121 pub format: u8,
123
124 pub operator: String,
126}
127
128#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Copy)]
130#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
131pub struct HttpModemBatteryLevelResponse {
132 pub status: u8,
134
135 pub charge: u8,
137
138 pub voltage: f32,
140}
141
142#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
144#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
145pub struct HttpSmsDeviceInfoResponse {
146 pub version: String,
148
149 pub phone_number: Option<String>,
151
152 pub service_provider: Option<String>,
154
155 pub network_operator: Option<HttpModemNetworkOperatorResponse>,
157
158 pub network_status: Option<HttpModemNetworkStatusResponse>,
160
161 pub battery: Option<HttpModemBatteryLevelResponse>,
163
164 pub signal: Option<HttpModemSignalStrengthResponse>,
166}
167
168#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
170#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
171pub struct LatestNumberFriendlyNamePair {
172 pub number: String,
174
175 pub friendly_name: Option<String>,
177}
178impl From<(String, Option<String>)> for LatestNumberFriendlyNamePair {
179 fn from(value: (String, Option<String>)) -> Self {
180 Self {
181 number: value.0,
182 friendly_name: value.1,
183 }
184 }
185}