nuntium_api 0.10 → 0.11

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 +14 -2
  2. metadata +4 -4
data/lib/nuntium.rb CHANGED
@@ -100,15 +100,27 @@ class Nuntium
100
100
  end
101
101
  end
102
102
 
103
- # Sends one or many AO messages. Returns an HTTParty::Response instance.
103
+ # Sends one or many AO messages.
104
+ # Returns an enhanced HTTParty::Response instance with id, guid and token readers that matches those x-headers
105
+ # returned by Nuntium.
106
+ # To send a token, just include it in the message as :token => 'my_token'
104
107
  # send_ao :from => 'sms://1', :to => 'sms://2', :subject => 'hello', :body => 'hi!'
105
108
  # send_ao [{:from => 'sms://1', :to => 'sms://2', :subject => 'hello', :body => 'hi!'}, {...}]
106
109
  def send_ao(messages)
107
- if messages.is_a? Array
110
+ response = if messages.is_a? Array
108
111
  self.class.post "#{@url}/#{@account}/#{@application}/send_ao.json", :basic_auth => @auth, :body => messages.to_json
109
112
  else
110
113
  self.class.post "#{@url}/#{@account}/#{@application}/send_ao", :basic_auth => @auth, :body => messages
111
114
  end
115
+ def response.id; headers['x-nuntium-id']; end
116
+ def response.token; headers['x-nuntium-token']; end
117
+ def response.guid; headers['x-nuntium-guid']; end
118
+ response
119
+ end
120
+
121
+ # Gets AO messages that have the given token. The response is an array of hashes with the messages' attributes.
122
+ def get_ao(token)
123
+ self.class.get "#{@url}/#{@account}/#{@application}/get_ao.json?token=#{token}", :basic_auth => @auth
112
124
  end
113
125
 
114
126
  # Gets the custom attributes specified for a given address. Returns a hash with the attributes
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: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 10
9
- version: "0.10"
8
+ - 11
9
+ version: "0.11"
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: 2010-06-08 00:00:00 +08:00
17
+ date: 2011-06-10 00:00:00 +07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency