nuntium_api 0.17 → 0.18
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.
- data/lib/nuntium.rb +27 -12
- 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
|
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
|
-
|
219
|
-
|
220
|
-
|
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
|
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