pub struct TimeTracks<'a> { /* private fields */ }Implementations§
Source§impl<'a> TimeTracks<'a>
impl<'a> TimeTracks<'a>
Sourcepub async fn create(
&self,
body: &TimeTrackRequestContent,
) -> Result<CreateTimeTrackResponseContent, Error>
pub async fn create( &self, body: &TimeTrackRequestContent, ) -> Result<CreateTimeTrackResponseContent, Error>
Record a finished stretch of time.
JSON callers send the fields flat; Rails wraps them into calendar_time_track itself.
Sourcepub async fn delete(&self, time_track_id: i64) -> Result<(), Error>
pub async fn delete(&self, time_track_id: i64) -> Result<(), Error>
Delete a time track. The id is the recording’s.
Sourcepub async fn get_ongoing(
&self,
) -> Result<Option<GetOngoingTimeTrackResponseContent>, Error>
pub async fn get_ongoing( &self, ) -> Result<Option<GetOngoingTimeTrackResponseContent>, Error>
Get the ongoing time track (404 = no active track; see ADR-004)
Sourcepub async fn list(
&self,
params: &ListTimeTracksParams,
) -> Result<Page<ListTimeTracksResponseContent>, Error>
pub async fn list( &self, params: &ListTimeTracksParams, ) -> Result<Page<ListTimeTracksResponseContent>, Error>
List tracked time — completed tracks only, newest-ended first.
A running track is not here; read that with GetOngoingTimeTrack. The next page, if any, is a Link header, and the last page carries none, so a nil Link is the end of the list rather than an error.
category_id narrows the list to one category and 404s if the calendar has no category by that id.
The calendar’s categories come back alongside the tracks, so showing or applying the filter does not need ListTimeTrackCategories as well.
Sourcepub async fn list_categories(
&self,
) -> Result<ListTimeTrackCategoriesResponseContent, Error>
pub async fn list_categories( &self, ) -> Result<ListTimeTrackCategoriesResponseContent, Error>
List the calendar’s time track categories, alphabetically
Sourcepub async fn start(&self) -> Result<StartTimeTrackResponseContent, Error>
pub async fn start(&self) -> Result<StartTimeTrackResponseContent, Error>
Start a new time track. Takes no body: haystack’s Calendar::OngoingTimeTracksController#create ignores request parameters and starts a track with defaults; use UpdateTimeTrack to set notes and category_title, which also stops the track.
Sourcepub async fn update(
&self,
time_track_id: i64,
body: &UpdateTimeTrackRequestContent,
) -> Result<UpdateTimeTrackResponseContent, Error>
pub async fn update( &self, time_track_id: i64, body: &UpdateTimeTrackRequestContent, ) -> Result<UpdateTimeTrackResponseContent, Error>
Update a time track (stop by setting ends_at to current time).
Every update completes the track, whether or not ends_at is sent, so this cannot be used to adjust a running track: it stops it.
Only the fields sent are written, so a partial update leaves the rest of the track alone. A starts_at or ends_at the server cannot parse is a 400, not a 422.
Source§impl TimeTracks<'_>
impl TimeTracks<'_>
Sourcepub async fn start_tracking(&self) -> Result<Recording, Error>
pub async fn start_tracking(&self) -> Result<Recording, Error>
Starts a time track. It takes nothing: HEY ignores the request body here and starts a
track with defaults. Notes and a category come later, with
TimeTracks::update or TimeTracks::stop_and_file, both of which also stop the
track.
This is TimeTracks::start with the one refusal it can meet named: a track already
running answers 409, which arrives as crate::ErrorCode::Conflict carrying HEY’s
own message, so a caller can branch on it rather than read a generic API error.
Sourcepub async fn stop(&self, time_track_id: i64) -> Result<(), Error>
pub async fn stop(&self, time_track_id: i64) -> Result<(), Error>
Stops the running time track by setting its end to now.
Sourcepub async fn stop_and_file(
&self,
time_track_id: i64,
category_title: Option<&str>,
) -> Result<(), Error>
pub async fn stop_and_file( &self, time_track_id: i64, category_title: Option<&str>, ) -> Result<(), Error>
Stops a time track and files it under a category in the one request, creating the
category if HEY has none by that name. No category stops the track without filing it,
which is what TimeTracks::stop does.
Filing is only ever part of stopping: HEY completes a track on every update, so there is no such thing as setting a category on a track that keeps running.
It sends the same PUT TimeTracks::update does, but announces itself to the
client’s hooks as StopTimeTrack rather than UpdateTimeTrack, so a gating policy
can allow one without the other.
Sourcepub async fn create_category(&self, title: &str) -> Result<(), Error>
pub async fn create_category(&self, title: &str) -> Result<(), Error>
Adds a category to file tracks under.
Sourcepub async fn update_category(
&self,
category_id: i64,
title: &str,
) -> Result<(), Error>
pub async fn update_category( &self, category_id: i64, title: &str, ) -> Result<(), Error>
Renames a category.