Sha256: 0f0b13284663d2b02403f21c39cb9e69a7e93951abab17289c011639dc5e3330

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

module FitbitAPI
  class Client
    def breathing_rate_summary(opts={})
      date       = opts[:date] || Date.today
      start_date = opts[:start_date]
      end_date   = opts[:end_date]

      if start_date && !end_date
        end_date = Date.today
      end

      unless date || start_date
        raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
      end

      if start_date
        result = get("user/#{user_id}/br/date/#{format_date(start_date)}/#{format_date(end_date)}.json")
      else
        result = get("user/#{user_id}/br/date/#{format_date(date)}.json")
      end

      # remove root key from response
      result.values[0]
    end

    def breathing_rate_intraday(opts={})
      date       = opts[:date] || Date.today
      start_date = opts[:start_date]
      end_date   = opts[:end_date]

      if start_date && !end_date
        end_date = Date.today
      end

      unless date || start_date
        raise FitbitAPI::InvalidArgumentError, 'A date or start_date and end_date are required.'
      end

      if start_date
        result = get("user/#{user_id}/br/date/#{format_date(start_date)}/#{format_date(end_date)}/all.json")
      else
        result = get("user/#{user_id}/br/date/#{format_date(date)}/all.json")
      end

      # remove root key from response
      result.values[0]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fitbit_api-0.14.0 lib/fitbit_api/breathing_rate.rb