Skip to content

Commit

Permalink
Re-export types for easier access
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsided committed Jul 8, 2023
1 parent a142c2f commit 4085b00
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
12 changes: 4 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,14 @@ impl WakaTimeClient {
pub async fn all_time_since_today<'a>(
&self,
options: AllTimesSinceTodayOptions<'a>,
) -> Result<model::all_times_since_today::AllTimeSinceToday, ApiError> {
) -> Result<model::AllTimeSinceToday, ApiError> {
let qs = options.into_query_string();
let url = format!(
"{BASE_URL}users/{user}/all_time_since_today{qs}",
user = self.user
);
let response = self.client.get(url).send().await?;
Self::deserialize_as(
response,
|r: DataWrapper<model::all_times_since_today::AllTimeSinceToday>| r.data,
)
.await
Self::deserialize_as(response, |r: DataWrapper<model::AllTimeSinceToday>| r.data).await
}

/// ## Documentation
Expand All @@ -108,7 +104,7 @@ impl WakaTimeClient {
project: &str,
hash: &str,
options: CommitOptions<'a>,
) -> Result<model::commit::CommitResponse, ApiError> {
) -> Result<model::Commits, ApiError> {
let qs = options.into_query_string();
let url = format!(
"{BASE_URL}users/{user}/projects/{project}/commits/{hash}{qs}",
Expand All @@ -125,7 +121,7 @@ impl WakaTimeClient {
start: &str,
end: &str,
options: SummariesOptions<'a>,
) -> Result<model::summaries::Summaries, ApiError> {
) -> Result<model::Summaries, ApiError> {
let qs = options
.into_query_string()
.with_value("start", start)
Expand Down
2 changes: 2 additions & 0 deletions src/model/all_times_since_today.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Contains the models for [`WakaTimeClient::all_time_since_today`](crate::WakaTimeClient::all_time_since_today).

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
6 changes: 4 additions & 2 deletions src/model/commit.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
//! Contains the models for [`WakaTimeClient::commit`](crate::WakaTimeClient::commit).

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CommitResponse {
pub struct Commits {
pub commit: Commit,
/// Branch name containting the commit.
/// Branch name containing the commit.
pub branch: String,
pub project: Project,
/// Project's sync status.
Expand Down
6 changes: 6 additions & 0 deletions src/model/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
//! API model types.

pub mod all_times_since_today;
pub mod commit;
pub mod summaries;

pub use all_times_since_today::AllTimeSinceToday;
pub use commit::Commits;
pub use summaries::Summaries;
2 changes: 2 additions & 0 deletions src/model/summaries.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Contains the models for [`WakaTimeClient::summaries`](crate::WakaTimeClient::summaries).

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down

0 comments on commit 4085b00

Please sign in to comment.