kobe_client/
client_builder.rs1use std::time::Duration;
2
3use crate::{client::KobeClient, config::Config};
4
5pub struct KobeApiClientBuilder {
7 config: Config,
8}
9
10impl KobeApiClientBuilder {
11 pub fn new() -> Self {
13 Self {
14 config: Config::mainnet(),
15 }
16 }
17
18 pub fn base_url(mut self, base_url: impl Into<String>) -> Self {
20 self.config.base_url = base_url.into();
21 self
22 }
23
24 pub fn timeout(mut self, timeout: Duration) -> Self {
26 self.config.timeout = timeout;
27 self
28 }
29
30 pub fn user_agent(mut self, user_agent: impl Into<String>) -> Self {
32 self.config.user_agent = user_agent.into();
33 self
34 }
35
36 pub fn retry(mut self, enabled: bool) -> Self {
38 self.config.retry_enabled = enabled;
39 self
40 }
41
42 pub fn max_retries(mut self, max_retries: u32) -> Self {
44 self.config.max_retries = max_retries;
45 self
46 }
47
48 pub fn build(self) -> KobeClient {
50 KobeClient::new(self.config)
51 }
52}
53
54impl Default for KobeApiClientBuilder {
55 fn default() -> Self {
56 Self::new()
57 }
58}