1#![allow(dead_code)]
16
17#[derive(Debug, Clone, Default)]
18pub struct Config {
19 pub openai_api_key: Option<String>,
20 pub jupiter_referral_account: Option<String>,
21 pub jupiter_fee_bps: Option<u16>, pub flash_privilege: Option<String>,
23 pub flexlend_api_key: Option<String>,
24 pub helius_api_key: Option<String>,
25 pub cookie_api_key: Option<String>,
26 pub birdeye_api_key: Option<String>,
27}
28
29#[derive(Default)]
30pub struct ConfigBuilder {
31 openai_api_key: Option<String>,
32 jupiter_referral_account: Option<String>,
33 jupiter_fee_bps: Option<u16>,
34 flash_privilege: Option<String>,
35 flexlend_api_key: Option<String>,
36 helius_api_key: Option<String>,
37 cookie_api_key: Option<String>,
38 birdeye_api_key: Option<String>,
39}
40
41impl ConfigBuilder {
42 pub fn openai_api_key(mut self, key: String) -> Self {
43 self.openai_api_key = Some(key);
44 self
45 }
46
47 pub fn jupiter_referral_account(mut self, account: String) -> Self {
48 self.jupiter_referral_account = Some(account);
49 self
50 }
51
52 pub fn jupiter_fee_bps(mut self, fee: u16) -> Self {
53 self.jupiter_fee_bps = Some(fee);
54 self
55 }
56
57 pub fn flash_privilege(mut self, privilege: String) -> Self {
58 self.flash_privilege = Some(privilege);
59 self
60 }
61
62 pub fn flexlend_api_key(mut self, key: String) -> Self {
63 self.flexlend_api_key = Some(key);
64 self
65 }
66
67 pub fn helius_api_key(mut self, key: String) -> Self {
68 self.helius_api_key = Some(key);
69 self
70 }
71
72 pub fn cookie_api_key(mut self, key: String) -> Self {
73 self.cookie_api_key = Some(key);
74 self
75 }
76
77 pub fn birdeye_api_key(mut self, key: String) -> Self {
78 self.birdeye_api_key = Some(key);
79 self
80 }
81
82 pub fn build(self) -> Config {
83 Config {
84 openai_api_key: self.openai_api_key,
85 jupiter_referral_account: self.jupiter_referral_account,
86 jupiter_fee_bps: self.jupiter_fee_bps,
87 flash_privilege: self.flash_privilege,
88 flexlend_api_key: self.flexlend_api_key,
89 helius_api_key: self.helius_api_key,
90 cookie_api_key: self.cookie_api_key,
91 birdeye_api_key: self.birdeye_api_key,
92 }
93 }
94}
95
96#[cfg(test)]
97mod tests {
98 use super::*;
99
100 #[test]
101 fn test_config_builder_default() {
102 let config = ConfigBuilder::default().build();
103 assert!(config.openai_api_key.is_none());
104 assert!(config.jupiter_referral_account.is_none());
105 assert_eq!(config.jupiter_fee_bps, None);
106 assert!(config.flash_privilege.is_none());
107 assert!(config.flexlend_api_key.is_none());
108 assert!(config.helius_api_key.is_none());
109 assert!(config.cookie_api_key.is_none());
110 assert!(config.birdeye_api_key.is_none());
111 }
112
113 #[test]
114 fn test_config_builder_with_values() {
115 let config = ConfigBuilder::default()
116 .openai_api_key("test_api_key".to_string())
117 .jupiter_referral_account("test_referral_account".to_string())
118 .jupiter_fee_bps(500)
119 .flash_privilege("test_flash_privilege".to_string())
120 .flexlend_api_key("test_flexlend_key".to_string())
121 .helius_api_key("test_helius_key".to_string())
122 .cookie_api_key("test_cookie_key".to_string())
123 .birdeye_api_key("birdeye_api_key".to_string())
124 .build();
125
126 assert_eq!(config.openai_api_key, Some("test_api_key".to_string()));
127 assert_eq!(config.jupiter_referral_account, Some("test_referral_account".to_string()));
128 assert_eq!(config.jupiter_fee_bps, Some(500));
129 assert_eq!(config.flash_privilege, Some("test_flash_privilege".to_string()));
130 assert_eq!(config.flexlend_api_key, Some("test_flexlend_key".to_string()));
131 assert_eq!(config.helius_api_key, Some("test_helius_key".to_string()));
132 assert_eq!(config.cookie_api_key, Some("test_cookie_key".to_string()));
133 assert_eq!(config.birdeye_api_key, Some("birdeye_api_key".to_string()));
134 }
135}