acari_lib/
lib.rs

1mod cached_client;
2mod error;
3mod everhour_client;
4mod everhour_model;
5mod mite_client;
6mod mite_model;
7mod model;
8mod query;
9
10pub use cached_client::{clear_cache, CachedClient};
11pub use error::AcariError;
12pub use everhour_client::EverhourClient;
13pub use mite_client::MiteClient;
14pub use model::{Account, Customer, Minutes, Project, Service, TimeEntry, Tracker, User};
15pub use model::{AccountId, CustomerId, ProjectId, ServiceId, TimeEntryId, UserId};
16pub use query::{DateSpan, Day};
17
18#[cfg(test)]
19mod mite_client_tests;
20
21#[cfg(test)]
22mod everhour_client_tests;
23
24pub trait Client {
25  fn get_domain(&self) -> String;
26
27  fn get_account(&self) -> Result<Account, AcariError>;
28
29  fn get_myself(&self) -> Result<User, AcariError>;
30
31  fn get_customers(&self) -> Result<Vec<Customer>, AcariError>;
32
33  fn get_projects(&self) -> Result<Vec<Project>, AcariError>;
34
35  fn get_services(&self, project_id: &ProjectId) -> Result<Vec<Service>, AcariError>;
36
37  fn get_time_entries(&self, date_span: DateSpan) -> Result<Vec<TimeEntry>, AcariError>;
38
39  fn create_time_entry(
40    &self,
41    day: Day,
42    project_id: &ProjectId,
43    service_id: &ServiceId,
44    minutes: Minutes,
45    note: Option<String>,
46  ) -> Result<TimeEntry, AcariError>;
47
48  fn update_time_entry(&self, entry_id: &TimeEntryId, minutes: Minutes, note: Option<String>) -> Result<(), AcariError>;
49
50  fn delete_time_entry(&self, entry_id: &TimeEntryId) -> Result<(), AcariError>;
51
52  fn get_tracker(&self) -> Result<Tracker, AcariError>;
53
54  fn create_tracker(&self, entry_id: &TimeEntryId) -> Result<Tracker, AcariError>;
55
56  fn delete_tracker(&self, entry_id: &TimeEntryId) -> Result<Tracker, AcariError>;
57}
58
59#[macro_export]
60macro_rules! user_error {
61  ( $( $arg:expr ),* ) => {
62    AcariError::UserError(format!($($arg),*))
63  }
64}
65
66#[macro_export]
67macro_rules! internal_error {
68  ( $( $arg:expr ),* ) => {
69    AcariError::InternalError(format!($($arg),*))
70  }
71}