1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//! An async Rust client for the [Hevy API](https://api.hevyapp.com/docs/).
//!
//! Hevy is a workout tracking app; this crate wraps its public REST API,
//! giving you typed access to workouts, routines, routine folders, exercise
//! templates, exercise history, body measurements, and user info.
//!
//! # Getting started
//!
//! Get an API key from <https://hevy.com/settings?developer> (requires Hevy Pro),
//! then construct a [`HevyClient`] and call its methods:
//!
//! ```no_run
//! use hevy::{CreateWorkoutRequest, HevyClient, NewWorkout, WorkoutExerciseInput, WorkoutSetInput};
//!
//! # async fn run() -> hevy::Result<()> {
//! let client = HevyClient::new("YOUR_API_KEY");
//!
//! // List the first page of workouts.
//! let page = client.list_workouts(Some(1), Some(5)).await?;
//! for workout in &page.workouts {
//! println!("{}: {}", workout.id, workout.title);
//! }
//!
//! // Log a new workout.
//! let workout = NewWorkout::new(
//! "Friday Leg Day",
//! "2024-08-14T12:00:00Z",
//! "2024-08-14T12:30:00Z",
//! )
//! .with_exercise(
//! WorkoutExerciseInput::new("D04AC939").with_set(WorkoutSetInput::normal(100.0, 10)),
//! );
//! let created = client.create_workout(&CreateWorkoutRequest::new(workout)).await?;
//! println!("Created workout {}", created.id);
//! # Ok(())
//! # }
//! ```
//!
//! # Error handling
//!
//! All fallible operations return [`Result<T>`], with failures represented by
//! [`HevyError`]. Non-2xx responses are surfaced as [`HevyError::Api`], carrying
//! the HTTP status code and, when available, the API's `error` message.
//!
//! # Resource groups
//!
//! - **Workouts**: [`HevyClient::list_workouts`], [`HevyClient::get_workout`],
//! [`HevyClient::create_workout`], [`HevyClient::update_workout`],
//! [`HevyClient::workout_count`], [`HevyClient::workout_events`]
//! - **Routines**: [`HevyClient::list_routines`], [`HevyClient::get_routine`],
//! [`HevyClient::create_routine`], [`HevyClient::update_routine`]
//! - **Routine folders**: [`HevyClient::list_routine_folders`],
//! [`HevyClient::get_routine_folder`], [`HevyClient::create_routine_folder`]
//! - **Exercise templates**: [`HevyClient::list_exercise_templates`],
//! [`HevyClient::get_exercise_template`],
//! [`HevyClient::create_exercise_template`]
//! - **Exercise history**: [`HevyClient::exercise_history`]
//! - **Body measurements**: [`HevyClient::list_body_measurements`],
//! [`HevyClient::get_body_measurement`],
//! [`HevyClient::create_body_measurement`],
//! [`HevyClient::update_body_measurement`]
//! - **User**: [`HevyClient::get_user_info`]
pub use ;
pub use ;
pub use ;