jawbone-up-api
jawbone-up-api copied to clipboard
Get data on specific day
I can't see any examples for getting data on a certain date or with a starting and ending times,, am i missing something ??
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
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
Thank You @dsjoerg very much