module Oura::Apis::SleepPeriod

SleepPeriod is a nearly continuous, longish period of time spent lying down in bed.

Constants

REQUEST_PATH

Public Instance Methods

sleep_period(start_date:, end_date: Time.current.to_date) click to toggle source

@param [Date] start_date @param [Date] end_date @example response body {

"sleep": [{"summary_date": "2016-10-11", ...}, {"summary_date": "2016-10-12", ...}, ...]

} @return [Oura::Model::SleepPeriod]

# File lib/oura/apis/sleep_period.rb, line 20
def sleep_period(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::SleepPeriod.new(symbolized_json)
end