nuntium_api 0.16 → 0.17

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.
Files changed (2) hide show
  1. data/lib/nuntium.rb +13 -3
  2. metadata +4 -4
data/lib/nuntium.rb CHANGED
@@ -121,7 +121,13 @@ class Nuntium
121
121
  #
122
122
  # Raises Nuntium::Exception if something goes wrong.
123
123
  def channel(name)
124
- get_channels "/api/channels/#{name}.json"
124
+ get("/api/channels/#{name}.json") do |response, error|
125
+ raise Nuntium::Exception.new error.message if error
126
+
127
+ channel = JSON.parse response.body
128
+ read_configuration channel
129
+ channel
130
+ end
125
131
  end
126
132
 
127
133
  # Creates a channel.
@@ -131,11 +137,13 @@ class Nuntium
131
137
  # Raises Nuntium::Exception if something goes wrong. You can access specific errors on properties via the properties
132
138
  # accessor of the exception.
133
139
  def create_channel(channel)
140
+ channel = channel.dup
141
+
134
142
  write_configuration channel
135
143
  post "/api/channels.json", channel.to_json do |response, error|
136
144
  handle_channel_error error if error
137
145
 
138
- channel = JSON.parse response
146
+ channel = JSON.parse response.body
139
147
  read_configuration channel
140
148
  channel
141
149
  end
@@ -148,6 +156,8 @@ class Nuntium
148
156
  # Raises Nuntium::Exception if something goes wrong. You can access specific errors on properties via the properties
149
157
  # accessor of the exception.
150
158
  def update_channel(channel)
159
+ channel = channel.dup
160
+
151
161
  write_configuration channel
152
162
  channel_name = channel['name'] || channel[:name]
153
163
 
@@ -288,7 +298,7 @@ class Nuntium
288
298
  resource = RestClient::Resource.new @url, @options
289
299
  resource = resource[path].post(data)
290
300
  yield resource, nil
291
- rescue => ex
301
+ rescue => ex
292
302
  yield nil, ex
293
303
  end
294
304
 
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: 43
4
+ hash: 41
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 16
9
- version: "0.16"
8
+ - 17
9
+ version: "0.17"
10
10
  platform: ruby
11
11
  authors:
12
12
  - InsTEDD
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-09-22 00:00:00 Z
17
+ date: 2011-09-23 00:00:00 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: rest-client