fitgem 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83ba31846e167d458f59cebdd7402d1e504b3fec
4
- data.tar.gz: 74bacff3769f0a5e390582a347f5b9f8200be40f
3
+ metadata.gz: a534f6ac957147e5bb9500d25b9271834cebc5c4
4
+ data.tar.gz: b5134949fe7c2c08d6eb3382daba3f6e59fb6a7d
5
5
  SHA512:
6
- metadata.gz: 31af46def4469ddaf15e8d0e97ac15d137079f9c0ad06df4a5098ef8fca038083224755759bc7f9f69e8432cd1cf9e0dfc304125ef1291220e325a8447f98697
7
- data.tar.gz: 46206bae93b252713dea225cc1bb2286d773f750d23f06d269c4453a16ae14bc0e526c4cd47217c6ba95999ed035d07d64c7e4ac37f94206a62218ea64dd0a86
6
+ metadata.gz: 0b83e502cbaa924a6a21c4030d8711ffa23d8fb8afc3165110a84c51e3de43467d9125484b9ce3b78ba4ac16aaf2965fd7b8bd782a04a6935b988b83b5d36629
7
+ data.tar.gz: 780a27f9d646dbbe230dc8a92711da02ebf6f4bbccc0897b166fc937e217fd500d94455bb0273d3acaf0e58f6a16832b1b47be52742120d9e8512c8c3d5e274f
@@ -17,6 +17,7 @@ require 'fitgem/devices'
17
17
  require 'fitgem/notifications'
18
18
  require 'fitgem/alarms'
19
19
  require 'fitgem/badges'
20
+ require 'fitgem/locales'
20
21
  require 'date'
21
22
  require 'uri'
22
23
 
@@ -46,6 +47,23 @@ module Fitgem
46
47
  # }
47
48
  attr_accessor :api_unit_system
48
49
 
50
+ # Sets or gets the api locale to be used in API calls
51
+ #
52
+ # @return [String]
53
+ #
54
+ # @example Set this using the {Fitgem::ApiLocale}
55
+ # client.api_locale = Fitgem::ApiLocale.UK
56
+ # @example May also be set in the constructor call
57
+ # client = Fitgem::Client {
58
+ # :consumer_key => my_key,
59
+ # :consumer_secret => my_secret,
60
+ # :token => fitbit_oauth_token,
61
+ # :secret => fitbit_oauth_secret,
62
+ # :unit_system => Fitgem::ApiUnitSystem.METRIC,
63
+ # :locale => Fitgem::ApiLocale.JP
64
+ # }
65
+ attr_accessor :api_locale
66
+
49
67
  # Sets or gets the user id to be used in API calls
50
68
  #
51
69
  # @return [String]
@@ -76,6 +94,9 @@ module Fitgem
76
94
  # @option opts [Symbol] :unit_system The unit system to use for API
77
95
  # calls; use {Fitgem::ApiUnitSystem} to set during initialization.
78
96
  # DEFAULT: {Fitgem::ApiUnitSystem.US}
97
+ # @option opts [Symbol] :locale The locale to use for API calls;
98
+ # use {Fitgem::ApiLocale} to set during initialization.
99
+ # DEFAULT: {Fitgem::ApiLocale.US}
79
100
  #
80
101
  # @example User has not yet authorized with fitbit
81
102
  # client = Fitgem::Client.new { :consumer_key => my_key, :consumer_secret => my_secret }
@@ -106,6 +127,7 @@ module Fitgem
106
127
 
107
128
  @api_unit_system = opts[:unit_system] || Fitgem::ApiUnitSystem.US
108
129
  @api_version = API_VERSION
130
+ @api_locale = opts[:locale] || Fitgem::ApiLocale.US
109
131
  end
110
132
 
111
133
  # Finalize authentication and retrieve an oauth access token
@@ -196,7 +218,8 @@ module Fitgem
196
218
  end
197
219
 
198
220
  def raw_get(path, headers={})
199
- headers.merge!('User-Agent' => "fitgem gem v#{Fitgem::VERSION}", 'Accept-Language' => @api_unit_system)
221
+ headers.merge!('User-Agent' => "fitgem gem v#{Fitgem::VERSION}", 'Accept-Language' => @api_unit_system,
222
+ 'Accept-Locale' => @api_locale)
200
223
  uri = "/#{@api_version}#{path}"
201
224
  access_token.get(uri, headers)
202
225
  end
@@ -206,7 +229,8 @@ module Fitgem
206
229
  end
207
230
 
208
231
  def raw_post(path, body='', headers={})
209
- headers.merge!('User-Agent' => "fitgem gem v#{Fitgem::VERSION}", 'Accept-Language' => @api_unit_system)
232
+ headers.merge!('User-Agent' => "fitgem gem v#{Fitgem::VERSION}", 'Accept-Language' => @api_unit_system,
233
+ 'Accept-Locale' => @api_locale)
210
234
  uri = "/#{@api_version}#{path}"
211
235
  access_token.post(uri, body, headers)
212
236
  end
@@ -216,7 +240,8 @@ module Fitgem
216
240
  end
217
241
 
218
242
  def raw_delete(path, headers={})
219
- headers.merge!('User-Agent' => "fitgem gem v#{Fitgem::VERSION}", 'Accept-Language' => @api_unit_system)
243
+ headers.merge!('User-Agent' => "fitgem gem v#{Fitgem::VERSION}", 'Accept-Language' => @api_unit_system,
244
+ 'Accept-Locale' => @api_locale)
220
245
  uri = "/#{@api_version}#{path}"
221
246
  access_token.delete(uri, headers)
222
247
  end
@@ -1,3 +1,3 @@
1
1
  module Fitgem
2
- VERSION = '0.11.0'
2
+ VERSION = '0.12.0'
3
3
  end
@@ -32,6 +32,27 @@ describe Fitgem do
32
32
  it 'should default to a user id of \'-\', the currently-logged in user' do
33
33
  expect(@client.user_id).to eq '-'
34
34
  end
35
+
36
+ it 'should default to the US locale' do
37
+ expect(@client.api_locale).to eq Fitgem::ApiLocale.US
38
+ end
39
+
40
+ it 'should allow the locale to be set to other types' do
41
+ @client.api_locale = Fitgem::ApiLocale.AU
42
+ expect(@client.api_locale).to eq Fitgem::ApiLocale.AU
43
+ @client.api_locale = Fitgem::ApiLocale.FR
44
+ expect(@client.api_locale).to eq Fitgem::ApiLocale.FR
45
+ @client.api_locale = Fitgem::ApiLocale.DE
46
+ expect(@client.api_locale).to eq Fitgem::ApiLocale.DE
47
+ @client.api_locale = Fitgem::ApiLocale.JP
48
+ expect(@client.api_locale).to eq Fitgem::ApiLocale.JP
49
+ @client.api_locale = Fitgem::ApiLocale.NZ
50
+ expect(@client.api_locale).to eq Fitgem::ApiLocale.NZ
51
+ @client.api_locale = Fitgem::ApiLocale.ES
52
+ expect(@client.api_locale).to eq Fitgem::ApiLocale.ES
53
+ @client.api_locale = Fitgem::ApiLocale.UK
54
+ expect(@client.api_locale).to eq Fitgem::ApiLocale.UK
55
+ end
35
56
  end
36
57
 
37
58
  describe '#reconnect' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fitgem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zachery Moneypenny