kobe_client/
client_builder.rs

1use std::time::Duration;
2
3use crate::{client::KobeClient, config::Config};
4
5/// Builder for creating a JitoClient with custom configuration
6pub struct KobeApiClientBuilder {
7    config: Config,
8}
9
10impl KobeApiClientBuilder {
11    /// Create a new builder with mainnet defaults
12    pub fn new() -> Self {
13        Self {
14            config: Config::mainnet(),
15        }
16    }
17
18    /// Set the base URL
19    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    /// Set the request timeout
25    pub fn timeout(mut self, timeout: Duration) -> Self {
26        self.config.timeout = timeout;
27        self
28    }
29
30    /// Set the user agent
31    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    /// Enable or disable retries
37    pub fn retry(mut self, enabled: bool) -> Self {
38        self.config.retry_enabled = enabled;
39        self
40    }
41
42    /// Set maximum number of retries
43    pub fn max_retries(mut self, max_retries: u32) -> Self {
44        self.config.max_retries = max_retries;
45        self
46    }
47
48    /// Build the client
49    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}