hi_push/rtm/
mod.rs

1use async_trait::async_trait;
2use serde::Serialize;
3
4pub struct Client {
5    cli: reqwest::Client,
6    client_id: String,
7    client_secret: String,
8}
9
10#[derive(Serialize)]
11pub struct Msg<'a> {
12    destination: &'a str,
13    enable_offline_messaging: Option<bool>, // under 1.5
14    enable_historical_messaging: Option<bool>,
15    payload: &'a str,
16}
17
18impl Client {
19    const PUSH_URL: &'static str = "";
20    pub fn new(client_id: &str, client_secret: &str) -> Result<Self, super::Error> {
21        let cli = reqwest::Client::builder()
22            .build()
23            .unwrap();
24        Ok(Self {
25            cli,
26            client_id: client_id.to_string(),
27            client_secret: client_secret.to_string(),
28        })
29    }
30}
31
32#[async_trait]
33impl<'b> super::Pusher<'b, Msg<'b>, ()> for Client {
34    async fn push(&self, msg: &'b Msg) -> Result<(), super::Error> {
35        let req = self.cli
36            .post(Client::PUSH_URL)
37            .basic_auth(&self.client_id, Some(&self.client_secret))
38            .send();
39
40        Ok(())
41    }
42}