ring_client/client/
mod.rs1use crate::client::api::RingApi;
2use crate::client::authentication::{Credentials, RingAuth, Tokens};
3use std::sync::Arc;
4use tokio::sync::RwLock;
5
6mod api;
7mod wrapper;
8
9pub mod authentication;
11
12pub use api::device;
13pub use api::location;
14pub use api::session;
15pub use api::ticket;
16
17pub use api::ApiError;
18pub use authentication::AuthenticationError;
19
20#[derive(Debug)]
22pub struct Client {
23 user: RwLock<Option<Credentials>>,
24 tokens: RwLock<Option<Arc<Tokens>>>,
25 auth: RingAuth,
26 api: RingApi,
27 display_name: String,
28 system_id: String,
29}
30
31impl Client {
32 #[must_use]
37 pub fn new(
38 display_name: &str,
39 system_id: &str,
40 operating_system: crate::helper::OperatingSystem,
41 ) -> Self {
42 Self {
43 user: RwLock::new(None),
44 tokens: RwLock::new(None),
45 auth: RingAuth::new(operating_system),
46 api: RingApi::new(operating_system),
47 display_name: display_name.to_string(),
48 system_id: system_id.to_string(),
49 }
50 }
51}