nodesty_api_library/models/
shared.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Serialize, Deserialize)]
4#[serde(rename_all = "camelCase")]
5pub struct ApiResponse<T> {
6 pub success: bool,
7 #[serde(skip_serializing_if = "Option::is_none")]
8 pub error: Option<String>,
9 #[serde(skip_serializing_if = "Option::is_none")]
10 pub data: Option<T>,
11}
12
13#[derive(Debug, Clone)]
14pub struct RestClientOptions {
15 pub access_token: String,
16 pub base_url: String,
17 pub retry: Option<u32>,
18 pub timeout_ms: Option<u64>,
19 pub rate_limit_offset_ms: Option<u64>,
20}
21
22impl RestClientOptions {
23 pub fn new(access_token: String) -> Self {
24 Self {
25 access_token,
26 base_url: "https://nodesty.com/api".to_string(),
27 retry: Some(3),
28 timeout_ms: Some(30_000),
29 rate_limit_offset_ms: Some(50),
30 }
31 }
32
33 pub fn with_base_url(mut self, base_url: String) -> Self {
34 self.base_url = base_url;
35 self
36 }
37
38 pub fn with_retry(mut self, retry: u32) -> Self {
39 self.retry = Some(retry);
40 self
41 }
42
43 pub fn with_timeout_ms(mut self, timeout_ms: u64) -> Self {
44 self.timeout_ms = Some(timeout_ms);
45 self
46 }
47
48 pub fn with_rate_limit_offset_ms(mut self, rate_limit_offset_ms: u64) -> Self {
49 self.rate_limit_offset_ms = Some(rate_limit_offset_ms);
50 self
51 }
52}