diff --git a/CHANGELOG.md b/CHANGELOG.md index 7008426..5c57449 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +0.8.3 +----- +- Fix bug regarding optional `params` parsing for GET requests. + 0.8.2 ----- - Fix `#activity_logs_list` to allow passing in expected URL params. diff --git a/LICENSE.txt b/LICENSE.txt index 8c4b06f..2a6992c 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2017 Zoran Pesic +Copyright (c) 2018 Zoran Pesic Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/lib/fitbit_api/activities.rb b/lib/fitbit_api/activities.rb index 9c6294b..77251af 100644 --- a/lib/fitbit_api/activities.rb +++ b/lib/fitbit_api/activities.rb @@ -56,14 +56,15 @@ def all_activities(opts={}) # * +:limit+ - the max of the number of entries returned (max: 20) def activity_logs_list(opts={}) - params = {} + opts[:params] = {} param_defaults = { before_date: Date.today, after_date: nil, sort: 'desc', limit: 20, offset: 0 } - # merge defaults without overwriting specified values, then split params from options - opts.merge!(param_defaults) { |_key, val, _default| val } - param_defaults.keys.each { |i| params[i] = opts.delete(i) } + # move param values from top-level opts into :params sub-hash + param_defaults.each do |key, default_val| + opts[:params][key] = opts.delete(key) || default_val + end - get("user/#{user_id}/activities/list.json", opts, params: params) + get("user/#{user_id}/activities/list.json", opts) end # Returns the details of a specific activity in the Fitbit activities database in the format requested. diff --git a/lib/fitbit_api/client.rb b/lib/fitbit_api/client.rb index 8714b1b..bf7f8e1 100644 --- a/lib/fitbit_api/client.rb +++ b/lib/fitbit_api/client.rb @@ -67,7 +67,8 @@ def request_headers } end - def get(path, opts={}, params: {}) + def get(path, opts={}) + params = opts.delete(:params) || {} response = token.get(("#{@api_version}/" + path), params: deep_keys_to_camel_case!(params), headers: request_headers).response object = MultiJson.load(response.body) unless response.status == 204 process_keys!(object, opts) diff --git a/lib/fitbit_api/version.rb b/lib/fitbit_api/version.rb index 9f2e70f..37a0c81 100644 --- a/lib/fitbit_api/version.rb +++ b/lib/fitbit_api/version.rb @@ -1,4 +1,4 @@ module FitbitAPI - VERSION = '0.8.2' + VERSION = '0.8.3' REPO_URL = 'https://github.com/zokioki/fitbit_api' end