nuntium_api 0.11 → 0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/nuntium.rb +18 -6
  2. data/lib/nuntium_api.rb +1 -0
  3. metadata +6 -7
data/lib/nuntium.rb CHANGED
@@ -64,24 +64,24 @@ class Nuntium
64
64
 
65
65
  # Returns a chnanel given its name, or nil if the channel doesn't exist
66
66
  def channel(name)
67
- channel = self.class.get "#{@url}/api/channels/#{name}.json", :basic_auth => @auth
68
- return nil if channel.class <= String
69
- read_configuration channel
70
- channel
67
+ response = self.class.get "#{@url}/api/channels/#{name}.json", :basic_auth => @auth
68
+ return_channel response
71
69
  end
72
70
 
73
71
  # Creates a channel.
74
72
  # create_channel :name => 'foo', :kind => 'qst_server', :protocol => 'sms', :configuration => {:password => 'bar'}
75
73
  def create_channel(channel)
76
74
  write_configuration channel
77
- self.class.post "#{@url}/api/channels.json", :basic_auth => @auth, :body => channel.to_json
75
+ response = self.class.post "#{@url}/api/channels.json", :basic_auth => @auth, :body => channel.to_json
76
+ return_channel response
78
77
  end
79
78
 
80
79
  # Updates a channel.
81
80
  # update_channel :name => 'foo', :kind => 'qst_server', :protocol => 'sms', :configuration => {:password => 'bar'}
82
81
  def update_channel(channel)
83
82
  write_configuration channel
84
- self.class.put "#{@url}/api/channels/#{channel['name']}.json", :basic_auth => @auth, :body => channel.to_json
83
+ response = self.class.put "#{@url}/api/channels/#{channel['name']}.json", :basic_auth => @auth, :body => channel.to_json
84
+ return_channel response
85
85
  end
86
86
 
87
87
  # Deletes a chnanel given its name.
@@ -151,5 +151,17 @@ class Nuntium
151
151
  end
152
152
  channel['configuration'] = configuration
153
153
  end
154
+
155
+ def return_channel(response)
156
+ return nil if response.class <= String
157
+ if response.response.class <= Net::HTTPSuccess
158
+ channel = response.parsed_response.with_indifferent_access
159
+ read_configuration channel
160
+ channel
161
+ else
162
+ # TODO should wrap in exception
163
+ response
164
+ end
165
+ end
154
166
 
155
167
  end
@@ -0,0 +1 @@
1
+ require 'nuntium'
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: 29
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 11
9
- version: "0.11"
8
+ - 12
9
+ version: "0.12"
10
10
  platform: ruby
11
11
  authors:
12
12
  - InsTEDD
@@ -14,8 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-06-10 00:00:00 +07:00
18
- default_executable:
17
+ date: 2011-06-10 00:00:00 Z
19
18
  dependencies:
20
19
  - !ruby/object:Gem::Dependency
21
20
  name: httparty
@@ -54,8 +53,8 @@ extensions: []
54
53
  extra_rdoc_files: []
55
54
 
56
55
  files:
56
+ - lib/nuntium_api.rb
57
57
  - lib/nuntium.rb
58
- has_rdoc: true
59
58
  homepage: http://code.google.com/p/nuntium-api-ruby
60
59
  licenses: []
61
60
 
@@ -85,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
84
  requirements: []
86
85
 
87
86
  rubyforge_project:
88
- rubygems_version: 1.4.2
87
+ rubygems_version: 1.8.6
89
88
  signing_key:
90
89
  specification_version: 3
91
90
  summary: Access the Nuntium API in ruby