Add workspaces
This commit is contained in:
parent
a780af3f62
commit
4cbb60b5ac
@ -73,6 +73,22 @@ impl TogglApi {
|
||||
headers
|
||||
}
|
||||
|
||||
/// Get the workspaces that a user is a part of
|
||||
async fn get_users_workspaces(
|
||||
&self
|
||||
) -> Result<Vec<types::Workspace>, TogglError> {
|
||||
let url = format!("{base_url}/me/workspaces", base_url = BASE_URL);
|
||||
|
||||
let response = self.client.get(&url)
|
||||
.headers(self.headers.clone())
|
||||
.send().await?;
|
||||
|
||||
let data = response.text().await?;
|
||||
let workspaces: Vec<types::Workspace> = serde_json::from_str(&data)?;
|
||||
|
||||
Ok(workspaces)
|
||||
}
|
||||
|
||||
/// Fetches all time entries for this user from Toggl that have been modified since the given
|
||||
/// date.
|
||||
pub async fn get_time_entries_for_user_modified_since(&self, since: DateTime<Utc>) -> Result<Vec<types::TimeEntry>, TogglError> {
|
||||
@ -221,7 +237,8 @@ pub mod types {
|
||||
#[serde(with = "duration_field")]
|
||||
duration: Option<u32>,
|
||||
|
||||
at: DateTime<Utc>,
|
||||
#[serde(rename = "at")]
|
||||
updated_at: DateTime<Utc>,
|
||||
|
||||
description: String,
|
||||
|
||||
@ -273,7 +290,8 @@ pub mod types {
|
||||
status: ProjectStatus,
|
||||
active: bool,
|
||||
|
||||
at: DateTime<Utc>,
|
||||
#[serde(rename = "at")]
|
||||
updated_at: DateTime<Utc>,
|
||||
start_date: NaiveDate,
|
||||
created_at: DateTime<Utc>,
|
||||
server_deleted_at: Option<DateTime<Utc>>,
|
||||
@ -300,7 +318,8 @@ pub mod types {
|
||||
pub id: i64,
|
||||
|
||||
/// Represents the timestamp of the last update made to the client.
|
||||
pub at: DateTime<Utc>,
|
||||
#[serde(rename = "at")]
|
||||
pub updated_at: DateTime<Utc>,
|
||||
|
||||
/// Indicates whether the client is archived or not.
|
||||
pub archived: bool,
|
||||
@ -328,7 +347,8 @@ pub mod types {
|
||||
name: String,
|
||||
workspace_id: u64,
|
||||
creator_id: u64,
|
||||
at: DateTime<Utc>,
|
||||
#[serde(rename = "at")]
|
||||
updated_at: DateTime<Utc>,
|
||||
deleted_at: Option<DateTime<Utc>>,
|
||||
permissions: Option<String>,
|
||||
}
|
||||
@ -358,7 +378,8 @@ pub mod types {
|
||||
pub seconds: u32,
|
||||
pub start: DateTime<Utc>,
|
||||
pub stop: DateTime<Utc>,
|
||||
pub at: DateTime<Utc>,
|
||||
#[serde(rename = "at")]
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
@ -483,6 +504,13 @@ pub mod types {
|
||||
ds.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
pub struct Workspace {
|
||||
pub id: u64,
|
||||
pub organization_id: u64,
|
||||
pub name: String,
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user