fundamentum_sdk_api/client/
config.rs1use serde::{Deserialize, Serialize};
4
5const PKG_VERSION: &str = env!("CARGO_PKG_VERSION");
6
7#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
9#[serde(deny_unknown_fields)]
10pub struct ClientConfig {
11 pub base_path: String,
13 pub user_agent: Option<String>,
15 pub api_token: Option<String>,
17}
18
19impl ClientConfig {
20 #[must_use]
22 pub fn builder(base_path: String) -> ClientConfigBuilder {
23 ClientConfigBuilder::new(base_path)
24 }
25}
26
27#[derive(Default)]
29pub struct ClientConfigBuilder {
30 base_path: String,
31 user_agent: Option<String>,
32 api_token: Option<String>,
33}
34
35impl ClientConfigBuilder {
36 #[must_use]
38 pub fn new(base_path: String) -> Self {
39 Self {
40 base_path,
41 user_agent: Some(format!("Fundamentum/SDK/{PKG_VERSION}/rust")),
42 api_token: None,
43 }
44 }
45
46 #[must_use]
48 pub fn user_agent(mut self, user_agent: Option<String>) -> Self {
49 self.user_agent = user_agent;
50 self
51 }
52
53 #[must_use]
55 pub fn api_token(mut self, api_token: Option<String>) -> Self {
56 self.api_token = api_token;
57 self
58 }
59
60 #[must_use]
62 pub fn build(self) -> ClientConfig {
63 ClientConfig {
64 base_path: self.base_path,
65 user_agent: self.user_agent,
66 api_token: self.api_token,
67 }
68 }
69}