qst_client 0.2 → 0.3

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/qst_client.rb +10 -6
  2. metadata +3 -3
data/lib/qst_client.rb CHANGED
@@ -11,8 +11,7 @@
11
11
  #
12
12
  # client = QstClient.new 'service_url', 'username', 'psasword'
13
13
  # last_id = client.put_messages [{'id' => '2', 'from' => 'sms://1234', 'to' => 'sms://5678', 'text' => 'Hello!', 'properties' => {'foo' => 'bar'}}]
14
- # messages = client.get_messages
15
- # messages = client.get_messages 'from_id'
14
+ # messages = client.get_messages :from_id => 'some_id', :max => 5
16
15
  require 'rubygems'
17
16
  require 'httparty'
18
17
  require 'builder'
@@ -39,10 +38,16 @@ class QstClient
39
38
  response['etag']
40
39
  end
41
40
 
42
- # Get messages from the server, optionally saying from which id to start.
41
+ # Get messages from the server.
43
42
  # Returns an array of hashes similar to the one you would use to put_messages.
44
- def get_messages(from_id = nil)
45
- response = self.class.get "#{@url}/outgoing", :basic_auth => @auth
43
+ # Options:
44
+ # - :from_id: the id from which to return messages, exclusive
45
+ # - :max: the maximum amount of messages to get
46
+ def get_messages(options = {:max => 10})
47
+ params = {:basic_auth => @auth}
48
+ params[:headers] = {'if-none-match' => options[:from_id]} if options[:from_id]
49
+
50
+ response = self.class.get "#{@url}/outgoing?max=#{options[:max]}", params
46
51
  raise QstClient::Exception.new response unless (200 ... 400).include? response.code
47
52
 
48
53
  messages = []
@@ -110,7 +115,6 @@ class QstClient
110
115
 
111
116
  response = self.class.post "#{@url}/incoming", :basic_auth => @auth, :body => xml.target!, :headers => {'Content-Type' => 'application/xml'}
112
117
  raise QstClient::Exception.new response unless (200 ... 400).include? response.code
113
- response['etag']
114
118
  end
115
119
 
116
120
  end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qst_client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
9
- version: "0.2"
8
+ - 3
9
+ version: "0.3"
10
10
  platform: ruby
11
11
  authors:
12
12
  - InsTEDD