Module: FitbitClient::Resources::Activity

Included in:
FitbitClient::Resources
Defined in:
lib/fitbit_client/resources/activity.rb

Instance Method Summary collapse

Instance Method Details

#activity_time_series(resource, date, period_or_end_date, options = {}) ⇒ Object

The Get Activity Time Series endpoint returns time series data in the specified range for a given resource in the format requested using units in the unit system that corresponds to the Accept-Language header provided.



32
33
34
35
36
# File 'lib/fitbit_client/resources/activity.rb', line 32

def activity_time_series(resource, date, period_or_end_date, options = {})
  period = period_or_date_param(period_or_end_date)
  path = "/activities/#{resource}/date/#{iso_date(date)}/#{period}"
  get_json(path_user_version(path, options))
end

#activity_type(activity_id, options = {}) ⇒ Object

Returns the details of a specific activity in the Fitbit activities database in the format requested. If activity has levels, also returns a list of activity level details.

activity_id : The activity id


53
54
55
56
# File 'lib/fitbit_client/resources/activity.rb', line 53

def activity_type(activity_id, options = {})
  skip_user_options!(options)
  get_json(path_user_version("/activities/#{activity_id}", options))
end

#add_favorite_activity(activity_id) ⇒ Object

The Add Favorite Activity endpoint adds the activity with the given ID to user’s list of favorite activities.

activity_id : The ID of the activity to add to user's favorites.


80
81
82
# File 'lib/fitbit_client/resources/activity.rb', line 80

def add_favorite_activity(activity_id)
  successful_post?(post(path_user_version("/activities/favorite/#{activity_id}")))
end

#browse_activity_types(options = {}) ⇒ Object

Get a tree of all valid Fitbit public activities from the activities catalog as well as private custom activities the user created in the format requested.

If the activity has levels, also get a list of activity level details.



43
44
45
46
# File 'lib/fitbit_client/resources/activity.rb', line 43

def browse_activity_types(options = {})
  skip_user_options!(options)
  get_json(path_user_version('/activities', options))
end

#daily_activity_summary(date, options = {}) ⇒ Object

The Get Daily Activity Summary endpoint retrieves a summary and list of a user’s activities and activity log entries for a given day in the format requested using units in the unit system which corresponds to the Accept-Language header provided.



24
25
26
# File 'lib/fitbit_client/resources/activity.rb', line 24

def daily_activity_summary(date, options = {})
  get_json(path_user_version("/activities/date/#{iso_date(date)}", options))
end

#delete_favorite_activity(activity_id) ⇒ Object

The Delete Favorite Activity removes the activity with the given ID from a user’s list of favorite activities.

activity_id : The ID of the activity to be removed.


88
89
90
# File 'lib/fitbit_client/resources/activity.rb', line 88

def delete_favorite_activity(activity_id)
  successful_delete?(delete(path_user_version("/activities/favorite/#{activity_id}")))
end

#favorite_activitiesObject

The Get Favorite Activities endpoint returns a list of a user’s favorite activities.



72
73
74
# File 'lib/fitbit_client/resources/activity.rb', line 72

def favorite_activities
  get_json(path_user_version('/activities/favorite'))
end

#lifetime_stats(options = {}) ⇒ Object

The Get Lifetime Stats endpoint retrieves the user’s activity statistics in the format requested using units in the unit system which corresponds to the Accept-Language header provided.

Activity statistics includes Lifetime and Best achievement values from the My Achievements tile on the website dashboard.

Response contains both statistics from the tracker device and total numbers including tracker data and manual activity log entries as seen on the Fitbit website dashboard.



16
17
18
# File 'lib/fitbit_client/resources/activity.rb', line 16

def lifetime_stats(options = {})
  get_json(path_user_version('/activities', options))
end

#recent_activity_types(options = {}) ⇒ Object

The Get Recent Activity Types endpoint retrieves a list of a user’s recent activities types logged with some details of the last activity log of that type using units in the unit system which corresponds to the Accept-Language header provided.

The record retrieved can be used to log the activity via the Log Activity endpoint with the same or adjusted values for distance and duration.



66
67
68
# File 'lib/fitbit_client/resources/activity.rb', line 66

def recent_activity_types(options = {})
  get_json(path_user_version('/activities/recent', options))
end