Skip to main content

gsm_core/platforms/webchat/
config.rs

1const DEFAULT_DIRECT_LINE_BASE: &str = "https://directline.botframework.com/v3/directline";
2
3#[derive(Clone, Debug, Eq, PartialEq)]
4pub struct Config {
5    direct_line_base: String,
6}
7
8impl Config {
9    pub fn new(direct_line_base: impl Into<String>) -> Self {
10        Self {
11            direct_line_base: direct_line_base.into(),
12        }
13    }
14
15    pub fn with_base_url(base_url: impl Into<String>) -> Self {
16        Self::new(base_url)
17    }
18
19    pub fn direct_line_base(&self) -> &str {
20        &self.direct_line_base
21    }
22}
23
24impl Default for Config {
25    fn default() -> Self {
26        Self::new(DEFAULT_DIRECT_LINE_BASE)
27    }
28}
29
30#[derive(Debug, Clone)]
31pub struct SigningKeys {
32    pub secret: String,
33}
34
35#[derive(Clone, Debug, Eq, PartialEq)]
36pub struct OAuthProviderConfig {
37    pub issuer: String,
38    pub client_id: String,
39    pub redirect_base: String,
40}
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    fn default_base_url() {
48        let config = Config::default();
49        assert_eq!(config.direct_line_base(), DEFAULT_DIRECT_LINE_BASE);
50    }
51
52    #[test]
53    fn custom_base_url() {
54        let config = Config::with_base_url("https://example.com/directline");
55        assert_eq!(config.direct_line_base(), "https://example.com/directline");
56    }
57}