nuntium_api 0.17 → 0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/nuntium.rb +27 -12
  2. metadata +3 -3
data/lib/nuntium.rb CHANGED
@@ -112,7 +112,10 @@ class Nuntium
112
112
  raise Nuntium::Exception.new error.message if error
113
113
 
114
114
  channels = JSON.parse response.body
115
- channels.each { |channel| read_configuration channel }
115
+ channels.each do |channel|
116
+ read_configuration channel
117
+ with_indifferent_access channel
118
+ end
116
119
  channels
117
120
  end
118
121
  end
@@ -126,7 +129,7 @@ class Nuntium
126
129
 
127
130
  channel = JSON.parse response.body
128
131
  read_configuration channel
129
- channel
132
+ with_indifferent_access channel
130
133
  end
131
134
  end
132
135
 
@@ -145,7 +148,7 @@ class Nuntium
145
148
 
146
149
  channel = JSON.parse response.body
147
150
  read_configuration channel
148
- channel
151
+ with_indifferent_access channel
149
152
  end
150
153
  end
151
154
 
@@ -166,7 +169,7 @@ class Nuntium
166
169
 
167
170
  channel = JSON.parse response.body
168
171
  read_configuration channel
169
- channel
172
+ with_indifferent_access channel
170
173
  end
171
174
  end
172
175
 
@@ -208,17 +211,19 @@ class Nuntium
208
211
  post "/#{@account}/#{@application}/send_ao.json", messages.to_json do |response, error|
209
212
  raise Nuntium::Exception.new error.message if error
210
213
 
211
- {:token => response.headers[:x_nuntium_token]}
214
+ with_indifferent_access({:token => response.headers[:x_nuntium_token]})
212
215
  end
213
216
  else
214
217
  get "/#{@account}/#{@application}/send_ao?#{to_query messages}" do |response, error|
215
218
  raise Nuntium::Exception.new error.message if error
216
219
 
217
- {
218
- :id => response.headers[:x_nuntium_id],
219
- :guid => response.headers[:x_nuntium_guid],
220
- :token => response.headers[:x_nuntium_token],
221
- }
220
+ with_indifferent_access(
221
+ {
222
+ :id => response.headers[:x_nuntium_id],
223
+ :guid => response.headers[:x_nuntium_guid],
224
+ :token => response.headers[:x_nuntium_token],
225
+ }
226
+ )
222
227
  end
223
228
  end
224
229
  end
@@ -280,7 +285,9 @@ class Nuntium
280
285
  get(path) do |response, error|
281
286
  raise Nuntium::Exception.new error.message if error
282
287
 
283
- JSON.parse response.body
288
+ elem = JSON.parse response.body
289
+ elem.map! { |x| with_indifferent_access x } if elem.is_a? Array
290
+ elem
284
291
  end
285
292
  end
286
293
 
@@ -289,7 +296,10 @@ class Nuntium
289
296
  raise Nuntium::Exception.new error.message if error
290
297
 
291
298
  channels = JSON.parse response.body
292
- channels.each { |channel| read_configuration channel }
299
+ channels.each do |channel|
300
+ read_configuration channel
301
+ with_indifferent_access channel
302
+ end
293
303
  channels
294
304
  end
295
305
  end
@@ -339,4 +349,9 @@ class Nuntium
339
349
  end
340
350
  query
341
351
  end
352
+
353
+ def with_indifferent_access(hash)
354
+ hash = hash.with_indifferent_access if hash.respond_to? :with_indifferent_access
355
+ hash
356
+ end
342
357
  end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nuntium_api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 41
4
+ hash: 47
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 17
9
- version: "0.17"
8
+ - 18
9
+ version: "0.18"
10
10
  platform: ruby
11
11
  authors:
12
12
  - InsTEDD