Rustbot/src/internals/tsclient.rs

20 lines
498 B
Rust
Raw Normal View History

2024-03-25 23:46:04 -04:00
use tokenservice_client::{TokenService, TokenServiceApi};
pub struct TSClient {
client: TokenService
}
impl TSClient {
pub fn new() -> Self {
2024-03-26 19:15:47 -04:00
let args: Vec<String> = std::env::args().collect();
let service = if args.len() > 1 { args[1].as_str() } else { "pgbot" };
2024-03-25 23:46:04 -04:00
TSClient {
2024-03-26 19:15:47 -04:00
client: TokenService::new(service)
2024-03-25 23:46:04 -04:00
}
}
pub async fn get(&self) -> Result<TokenServiceApi, Box<dyn std::error::Error>> {
let api = self.client.connect().await.unwrap();
Ok(api)
}
}