mod calendar;
mod drive;
mod gmail;
mod linear;
pub mod types;
pub use calendar::Calendar;
pub use drive::Drive;
pub use gmail::Gmail;
pub use linear::Linear;
use crate::errors::Result;
use crate::transport::Transport;
#[derive(Debug, Clone)]
pub struct Integrations {
transport: Transport,
}
impl Integrations {
pub(crate) fn new(transport: Transport) -> Self {
Self { transport }
}
pub fn gmail(&self) -> Gmail {
Gmail::new(self.transport.clone())
}
pub fn calendar(&self) -> Calendar {
Calendar::new(self.transport.clone())
}
pub fn google_calendar(&self) -> Calendar {
self.calendar()
}
pub fn drive(&self) -> Drive {
Drive::new(self.transport.clone())
}
pub fn google_drive(&self) -> Drive {
self.drive()
}
pub fn linear(&self) -> Linear {
Linear::new(self.transport.clone())
}
pub fn provider(&self, name: impl Into<String>) -> Provider {
Provider {
transport: self.transport.clone(),
name: name.into(),
}
}
}
#[derive(Debug, Clone)]
pub struct Provider {
transport: Transport,
name: String,
}
impl Provider {
pub fn name(&self) -> &str {
&self.name
}
pub async fn call(&self, action: &str, body: serde_json::Value) -> Result<serde_json::Value> {
self.transport.integrations_call(&self.name, action, &body).await
}
}