Sha256: 6ea4dd4eb99e8ad7066a00f221b348074ca6dfd7e10bfe30bb3c50aa667222eb

Contents?: true

Size: 908 Bytes

Versions: 4

Compression:

Stored size: 908 Bytes

Contents

# frozen_string_literal: true

require 'oura/utils/api'

module Oura
  module Apis
    # Activity summary contains daily activity summary values and detailed activity levels.
    module Activity
      include ::Oura::Utils::Api

      REQUEST_PATH = '/v1/activity'

      # @param [Date] start_date
      # @param [Date] end_date
      # @example response body
      # {
      #   "activity": [{"summary_date": "2016-10-11", ...}, {"summary_date": "2016-10-12", ...}, ...]
      # }
      # @return [Oura::Model::Activity]
      def activity(start_date:, end_date: Time.current.to_date)
        sdate, edate = [start_date, end_date].map { |date| transform_date(date) }
        response_body = get(REQUEST_PATH, params: { start: sdate, end: edate }).body
        symbolized_json = JSON.parse(response_body).deep_symbolize_keys

        ::Oura::Model::Activity.new(symbolized_json)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
oura-0.1.8 lib/oura/apis/activity.rb
oura-0.1.7 lib/oura/apis/activity.rb
oura-0.1.6 lib/oura/apis/activity.rb
oura-0.1.5 lib/oura/apis/activity.rb