jawbone-up-api icon indicating copy to clipboard operation
jawbone-up-api copied to clipboard

Get data on specific day

Open abouelsaadat opened this issue 10 years ago • 3 comments

I can't see any examples for getting data on a certain date or with a starting and ending times,, am i missing something ??

abouelsaadat avatar Feb 26 '15 15:02 abouelsaadat

The trick is that all the parameters supported by the underlying Jawbone API are supported, but they're not listed in this gem's source code.

So, for example, look at https://jawbone.com/up/developer/endpoints/sleeps

See how start_time and end_time are listed there as acceptable parameters?

Now, in my own code here's what I do:

def self.retrieve_jawbone_sleep_items(user, start_date, end_date)
  client = user.jawbone_data
  first_results = client.sleeps({:start_time => start_date.to_time.to_i - HALF_DAY,
                                :end_time => end_date.to_time.to_i + HALF_DAY})
  client.retrieve_all_items(first_results)
end

dsjoerg avatar Feb 26 '15 15:02 dsjoerg

retrieve_all_items is a function i wrote, it goes in client.rb. i didn't issue a PR for it because i haven't tested it carefully or thought about it too hard. but in case you're interested, here it is: http://pastebin.com/xj5uPbMh

dsjoerg avatar Feb 26 '15 15:02 dsjoerg

Thank You @dsjoerg very much

abouelsaadat avatar Feb 26 '15 16:02 abouelsaadat