ruby_garmin_connect 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/lib/garmin_connect/api/body_composition.rb +37 -0
- data/lib/garmin_connect/api/workouts.rb +81 -0
- data/lib/garmin_connect/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9b18f0c8f89a53ffc4f5f823c156aa14efcdcdd4fdcbcc11bfcf2c96ad8026fa
|
|
4
|
+
data.tar.gz: b041d02818b7e1cc499bfce5b24982b73d3b616a2e2f41eb6599b6f0bb9b70c1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a1975143fb61ac5c6af8ca844416415946babf90240eb6cb6ac52ec40a4a37f606c233d2d60304609066303b4a472026cc2942c7a4b6e2cd750b36c8fa900185
|
|
7
|
+
data.tar.gz: 500020861e427e9795a78bc242cb80a7755a9e714f6f341c0141496a6292abca62a1fdfbae9420f0d894bc1049e5c11f3c371aa1e95d9cd5cc3eaba1d5eb3fe4
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.0 (2026-02-11)
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `add_body_composition` - upload body scale data (body fat %, muscle mass, etc.) as a FIT file
|
|
8
|
+
- `add_weigh_in_with_timestamps` - add a weigh-in with explicit local and GMT timestamps
|
|
9
|
+
- `delete_weigh_ins` - batch delete all weigh-ins for a given date
|
|
10
|
+
- Typed workout creation helpers:
|
|
11
|
+
- `create_running_workout`
|
|
12
|
+
- `create_cycling_workout`
|
|
13
|
+
- `create_swimming_workout`
|
|
14
|
+
- `create_walking_workout`
|
|
15
|
+
- `create_hiking_workout`
|
|
16
|
+
|
|
17
|
+
### Improved
|
|
18
|
+
|
|
19
|
+
- Comprehensive test coverage for all 9 API modules (199 examples, up from 48)
|
|
20
|
+
- User, Health, Activities, Body Composition, Metrics, Devices, Badges, Workouts, Wellness
|
|
21
|
+
|
|
3
22
|
## 0.1.0 (2026-02-11)
|
|
4
23
|
|
|
5
24
|
- Initial release
|
|
@@ -54,6 +54,31 @@ module GarminConnect
|
|
|
54
54
|
)
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
+
# Add a weigh-in with explicit timestamps.
|
|
58
|
+
# @param value [Float] weight value
|
|
59
|
+
# @param date_timestamp [String] local timestamp (e.g., "2026-02-11T08:30:00.000")
|
|
60
|
+
# @param gmt_timestamp [String] GMT timestamp (e.g., "2026-02-11T14:30:00.000")
|
|
61
|
+
# @param unit_key [String] "kg" or "lbs"
|
|
62
|
+
def add_weigh_in_with_timestamps(value, date_timestamp:, gmt_timestamp:, unit_key: "kg")
|
|
63
|
+
connection.post(
|
|
64
|
+
"/weight-service/user-weight",
|
|
65
|
+
body: {
|
|
66
|
+
"dateTimestamp" => date_timestamp,
|
|
67
|
+
"gmtTimestamp" => gmt_timestamp,
|
|
68
|
+
"unitKey" => unit_key,
|
|
69
|
+
"sourceType" => "MANUAL",
|
|
70
|
+
"value" => value
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Upload body composition data as a FIT file.
|
|
76
|
+
# This is used for full body scale data (body fat %, muscle mass, bone mass, etc.).
|
|
77
|
+
# @param file_path [String] path to the FIT file containing body composition data
|
|
78
|
+
def add_body_composition(file_path)
|
|
79
|
+
connection.upload("/upload-service/upload", file_path: file_path)
|
|
80
|
+
end
|
|
81
|
+
|
|
57
82
|
# Delete a specific weigh-in.
|
|
58
83
|
# @param date [Date, String]
|
|
59
84
|
# @param weight_pk [String, Integer] the weigh-in version/pk
|
|
@@ -61,6 +86,18 @@ module GarminConnect
|
|
|
61
86
|
connection.delete("/weight-service/weight/#{format_date(date)}/byversion/#{weight_pk}")
|
|
62
87
|
end
|
|
63
88
|
|
|
89
|
+
# Delete all weigh-ins for a specific date.
|
|
90
|
+
# Fetches all weigh-ins for the day, then deletes each one.
|
|
91
|
+
# @param date [Date, String]
|
|
92
|
+
def delete_weigh_ins(date)
|
|
93
|
+
day_data = daily_weigh_ins(date)
|
|
94
|
+
entries = day_data&.dig("dateWeightList") || []
|
|
95
|
+
entries.each do |entry|
|
|
96
|
+
weight_pk = entry["version"] || entry["samplePk"]
|
|
97
|
+
delete_weigh_in(date, weight_pk) if weight_pk
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
64
101
|
# --- Hydration ---
|
|
65
102
|
|
|
66
103
|
# Get daily hydration data.
|
|
@@ -39,6 +39,48 @@ module GarminConnect
|
|
|
39
39
|
connection.get("/workout-service/schedule/#{scheduled_workout_id}")
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
# --- Typed Workout Helpers ---
|
|
43
|
+
|
|
44
|
+
# Create a running workout.
|
|
45
|
+
# @param name [String] workout name
|
|
46
|
+
# @param steps [Array<Hash>] workout step definitions
|
|
47
|
+
# @param description [String, nil] optional description
|
|
48
|
+
def create_running_workout(name, steps: [], description: nil)
|
|
49
|
+
create_typed_workout(name, sport_type: running_sport_type, steps: steps, description: description)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Create a cycling workout.
|
|
53
|
+
# @param name [String] workout name
|
|
54
|
+
# @param steps [Array<Hash>] workout step definitions
|
|
55
|
+
# @param description [String, nil] optional description
|
|
56
|
+
def create_cycling_workout(name, steps: [], description: nil)
|
|
57
|
+
create_typed_workout(name, sport_type: cycling_sport_type, steps: steps, description: description)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Create a swimming workout.
|
|
61
|
+
# @param name [String] workout name
|
|
62
|
+
# @param steps [Array<Hash>] workout step definitions
|
|
63
|
+
# @param description [String, nil] optional description
|
|
64
|
+
def create_swimming_workout(name, steps: [], description: nil)
|
|
65
|
+
create_typed_workout(name, sport_type: swimming_sport_type, steps: steps, description: description)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Create a walking workout.
|
|
69
|
+
# @param name [String] workout name
|
|
70
|
+
# @param steps [Array<Hash>] workout step definitions
|
|
71
|
+
# @param description [String, nil] optional description
|
|
72
|
+
def create_walking_workout(name, steps: [], description: nil)
|
|
73
|
+
create_typed_workout(name, sport_type: walking_sport_type, steps: steps, description: description)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Create a hiking workout.
|
|
77
|
+
# @param name [String] workout name
|
|
78
|
+
# @param steps [Array<Hash>] workout step definitions
|
|
79
|
+
# @param description [String, nil] optional description
|
|
80
|
+
def create_hiking_workout(name, steps: [], description: nil)
|
|
81
|
+
create_typed_workout(name, sport_type: hiking_sport_type, steps: steps, description: description)
|
|
82
|
+
end
|
|
83
|
+
|
|
42
84
|
# --- Training Plans ---
|
|
43
85
|
|
|
44
86
|
# Get all available training plans.
|
|
@@ -57,6 +99,45 @@ module GarminConnect
|
|
|
57
99
|
def adaptive_training_plan(plan_id)
|
|
58
100
|
connection.get("/trainingplan-service/trainingplan/fbt-adaptive/#{plan_id}")
|
|
59
101
|
end
|
|
102
|
+
|
|
103
|
+
private
|
|
104
|
+
|
|
105
|
+
def create_typed_workout(name, sport_type:, steps: [], description: nil)
|
|
106
|
+
payload = {
|
|
107
|
+
"workoutName" => name,
|
|
108
|
+
"sportType" => sport_type,
|
|
109
|
+
"workoutSegments" => [
|
|
110
|
+
{
|
|
111
|
+
"segmentOrder" => 1,
|
|
112
|
+
"sportType" => sport_type,
|
|
113
|
+
"workoutSteps" => steps
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
payload["description"] = description if description
|
|
118
|
+
|
|
119
|
+
create_workout(payload)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def running_sport_type
|
|
123
|
+
{ "sportTypeId" => 1, "sportTypeKey" => "running" }
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def cycling_sport_type
|
|
127
|
+
{ "sportTypeId" => 2, "sportTypeKey" => "cycling" }
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def swimming_sport_type
|
|
131
|
+
{ "sportTypeId" => 5, "sportTypeKey" => "swimming" }
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def walking_sport_type
|
|
135
|
+
{ "sportTypeId" => 9, "sportTypeKey" => "walking" }
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def hiking_sport_type
|
|
139
|
+
{ "sportTypeId" => 3, "sportTypeKey" => "hiking" }
|
|
140
|
+
end
|
|
60
141
|
end
|
|
61
142
|
end
|
|
62
143
|
end
|