elk 0.0.3p0

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.
@@ -0,0 +1,91 @@
1
+ Elk
2
+ ===
3
+
4
+ Ruby client for 46elks "Voice, SMS & MMS" service. http://46elks.com/
5
+ At the moment the API only supports sending SMS messages.
6
+
7
+ ## Requirements
8
+
9
+ * API account at 46elks.com
10
+
11
+ ## Install
12
+
13
+ Install via RubyGems
14
+
15
+ gem install elk
16
+
17
+ ## Source and development
18
+
19
+ The source for Elk is available on Github:
20
+
21
+ https://github.com/jage/elk
22
+
23
+ elk uses rspec and webmock for testing, do a `bundle install` for all the development requirements.
24
+
25
+ ## Usage
26
+
27
+ elk can be used to allocate a phone numbers, manage the numbers and send/recieve messages through these numbers.
28
+
29
+ ### Authentication and configuration
30
+
31
+ First thing when using elk is to set the authentication parameters
32
+
33
+ require 'elk'
34
+
35
+ Elk.configure do |config|
36
+ config.username = 'USERNAME'
37
+ config.password = 'PASSWORD'
38
+ end
39
+
40
+ ### Numbers
41
+
42
+ To be able to send and recieve messages, a number is needed. Several numbers can be allocated.
43
+
44
+ number = Elk::Number.allocate(:sms_url => 'http://myservice.se/callback/newsms.php', :country => 'se')
45
+ # => #<Elk::Number:0x0000010282aa70 @country="se", @sms_url="http://myservice.se/callback/newsms.php", @status="yes", @number_id="n03e7db70cc06c1ff85e09a2b3f86dd62", @number="+46766861034", @capabilities=[:sms], @loaded_at=2011-07-17 15:23:55 +0200>
46
+
47
+ Get all numbers
48
+
49
+ numbers = Elk::Number.all
50
+ # => [#<Elk::Number ...>, #<Elk::Number ...>]
51
+
52
+ Change number settings
53
+
54
+ number.sms_url = 'http://myservice.se/callback/newsms.php'
55
+ number.country = 'no'
56
+ number.save
57
+ # => true
58
+
59
+ Deallocate a number.
60
+ Beware that there is no way to get your number back once it has been deallocated!
61
+
62
+ number.deallocate!
63
+ # => true
64
+ number.status
65
+ # => :deallocated
66
+
67
+ ### SMS
68
+
69
+ Send SMS. Messages can be sent from one of the allocated numbers or an arbitrary alphanumeric string of at most 11 characters.
70
+
71
+ Elk::SMS.send(:from => 'MyService', :to => '+46704508449', :message => 'Your order #171 has now been sent!')
72
+ # => #<Elk::SMS:0x0000010179d7e8 @from="MyService", @to="+46704508449", @message="Your order #171 has now been sent!", @message_id="sdc39a7926d37159b6985283e32f43251", @created_at=2011-07-17 16:21:13 +0200, @loaded_at=2011-07-17 16:21:13 +0200>
73
+
74
+ Receiving SMS does not require Elk, but should be of interest anyway.
75
+ Example with Sinatra:
76
+
77
+ post '/receive' do
78
+ if request.params['message'] == 'Hello'
79
+ # Sends a return SMS with message "world!"
80
+ "world!"
81
+ end
82
+ end
83
+
84
+ SMS history
85
+
86
+ Elk::SMS.all
87
+ # => [#<Elk::SMS ...>, #<Elk::SMS ...>, <Elk::SMS ...>]
88
+
89
+ ## Copyright
90
+
91
+ Copyright (c) 2011 Johan Eckerström. See LICENSE for details.
@@ -0,0 +1,56 @@
1
+ # External
2
+ require 'json/pure'
3
+ require 'open-uri'
4
+ require 'rest_client'
5
+ require 'time'
6
+ # Internal
7
+ require 'elk/number'
8
+ require 'elk/sms'
9
+
10
+ module Elk
11
+ BASE_DOMAIN = 'api.46elks.com'
12
+ API_VERSION = 'a1'
13
+ VERSION = '0.0.3'
14
+
15
+ class AuthError < RuntimeError; end
16
+ class ServerError < RuntimeError; end
17
+ class BadResponse < RuntimeError; end
18
+
19
+ class << self
20
+ attr_accessor :username
21
+ attr_accessor :password
22
+ attr_accessor :base_domain
23
+
24
+ def configure
25
+ yield self
26
+ end
27
+
28
+ def base_url
29
+ "https://#{username}:#{password}@#{(base_domain || BASE_DOMAIN)}/#{API_VERSION}"
30
+ end
31
+
32
+ def get(path, parameters = {})
33
+ execute(:get, path, parameters)
34
+ end
35
+
36
+ def post(path, parameters = {})
37
+ execute(:post, path, parameters)
38
+ end
39
+
40
+ def execute(method, path, parameters, headers={:accept => :json}, &block)
41
+ payload = {}.merge(parameters)
42
+ url = base_url + path
43
+ RestClient::Request.execute(:method => method, :url => url, :payload => payload, :headers => headers, &block)
44
+ rescue RestClient::Unauthorized
45
+ raise AuthError, "Authentication failed"
46
+ rescue RestClient::InternalServerError
47
+ raise ServerError, "Server error"
48
+ end
49
+
50
+ def parse_json(body)
51
+ JSON.parse(body, :symbolize_names => true)
52
+ rescue JSON::ParserError
53
+ raise BadResponse, "Can't parse JSON"
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,63 @@
1
+ module Elk
2
+ class Number
3
+ attr_reader :number_id, :number, :capabilities, :loaded_at
4
+ attr_accessor :country, :sms_url
5
+
6
+ def initialize(parameters)
7
+ set_paramaters(parameters)
8
+ end
9
+
10
+ def set_paramaters(parameters)
11
+ @country = parameters[:country]
12
+ @sms_url = parameters[:sms_url]
13
+ @status = parameters[:active]
14
+ @number_id = parameters[:id]
15
+ @number = parameters[:number]
16
+ @capabilities = parameters[:capabilities].collect {|c| c.to_sym }
17
+ @loaded_at = Time.now
18
+ end
19
+
20
+ def status
21
+ case @status
22
+ when 'yes'
23
+ :active
24
+ when 'no'
25
+ :deallocated
26
+ else
27
+ nil
28
+ end
29
+ end
30
+
31
+ def reload
32
+ response = Elk.get("/Numbers/#{self.number_id}")
33
+ self.set_paramaters(Elk.parse_json(response.body))
34
+ response.code == 200
35
+ end
36
+
37
+ def save
38
+ response = Elk.post("/Numbers/#{self.number_id}", {:country => self.country, :sms_url => self.sms_url})
39
+ response.code == 200
40
+ end
41
+
42
+ def deallocate!
43
+ response = Elk.post("/Numbers/#{self.number_id}", {:active => 'no'})
44
+ @status = 'no'
45
+ response.code == 200
46
+ end
47
+
48
+ class << self
49
+ def allocate(parameters)
50
+ response = Elk.post('/Numbers', parameters)
51
+ self.new(Elk.parse_json(response.body))
52
+ end
53
+
54
+ def all
55
+ response = Elk.get('/Numbers')
56
+
57
+ Elk.parse_json(response.body)[:numbers].collect do |n|
58
+ self.new(n)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,45 @@
1
+ module Elk
2
+ class SMS
3
+ attr_reader :from, :to, :message, :message_id, :created_at, :loaded_at
4
+
5
+ def initialize(parameters)
6
+ set_parameters(parameters)
7
+ end
8
+
9
+ def set_parameters(parameters)
10
+ @from = parameters[:from]
11
+ @to = parameters[:to]
12
+ @message = parameters[:message]
13
+ @message_id = parameters[:id]
14
+ @created_at = Time.parse(parameters[:created])
15
+ @loaded_at = Time.now
16
+ end
17
+
18
+ def reload
19
+ response = Elk.get("/SMS/#{self.message_id}")
20
+ self.set_parameters(Elk.parse_json(response.body))
21
+ response.code == 200
22
+ end
23
+
24
+ class << self
25
+ def send(settings)
26
+ parameters = {}.merge(settings)
27
+ response = Elk.post('/SMS', parameters)
28
+ self.new(Elk.parse_json(response.body))
29
+ ensure
30
+ # Warn if the from string will be capped by the sms gateway
31
+ if parameters[:from].match(/^(\w{11,})$/)
32
+ warn "SMS 'from' value #{parameters[:from]} will be capped at 11 chars"
33
+ end
34
+ end
35
+
36
+ def all
37
+ response = Elk.get('/SMS')
38
+ Elk.parse_json(response.body)[:smses].collect do |n|
39
+ self.new(n)
40
+ end
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,225 @@
1
+ require 'spec_helper'
2
+ require 'elk'
3
+
4
+ describe Elk do
5
+ describe Elk::Number do
6
+ it 'allocates a number' do
7
+ stub_request(:post, "https://USERNAME:PASSWORD@api.46elks.com/a1/Numbers").
8
+ with(:body => {"country" => "se", "sms_url" => "http://localhost/receive"},
9
+ :headers => {'Accept'=>'application/json', 'Content-Type'=>'application/x-www-form-urlencoded'}).
10
+ to_return(fixture('allocates_a_number.txt'))
11
+
12
+ configure_elk
13
+
14
+ number = Elk::Number.allocate(:sms_url => 'http://localhost/receive', :country => 'se')
15
+ number.status.should == :active
16
+ number.sms_url.should == 'http://localhost/receive'
17
+ number.country.should == 'se'
18
+ number.number.should == '+46766861012'
19
+ number.capabilities.should == [:sms]
20
+ end
21
+
22
+ it 'gets allocated numbers' do
23
+ stub_request(:get, "https://USERNAME:PASSWORD@api.46elks.com/a1/Numbers").
24
+ with(:headers => {'Accept'=>'application/json'}).
25
+ to_return(fixture('gets_allocated_numbers.txt'))
26
+
27
+ configure_elk
28
+
29
+ numbers = Elk::Number.all
30
+ numbers.size.should == 2
31
+ numbers[0].number_id.should == 'nea19c8e291676fb7003fa1d63bba7899'
32
+ numbers[0].number.should == '+46704508449'
33
+ numbers[0].sms_url == 'http://localhost/receive1'
34
+
35
+ numbers[1].number_id.should == 'nea19c8e291676fb7003fa1d63bba789A'
36
+ numbers[1].number.should == '+46761042247'
37
+ numbers[0].sms_url == 'http://localhost/receive2'
38
+ end
39
+
40
+ it 'updates a number' do
41
+ stub_request(:get, "https://USERNAME:PASSWORD@api.46elks.com/a1/Numbers").
42
+ with(:headers => {'Accept'=>'application/json'}).
43
+ to_return(fixture('gets_allocated_numbers.txt'))
44
+ stub_request(:post, "https://USERNAME:PASSWORD@api.46elks.com/a1/Numbers/nea19c8e291676fb7003fa1d63bba7899").
45
+ with(:body => {"country" => "no", "sms_url" => "http://otherhost/receive"},
46
+ :headers => {'Accept'=>'application/json', 'Content-Type'=>'application/x-www-form-urlencoded'}).
47
+ to_return(fixture('updates_a_number.txt'))
48
+
49
+ configure_elk
50
+
51
+ number = Elk::Number.all[0]
52
+ number.country = 'no'
53
+ number.sms_url = 'http://otherhost/receive'
54
+ number.save.should == true
55
+ number.country.should == 'no'
56
+ number.sms_url.should == 'http://otherhost/receive'
57
+ end
58
+
59
+ it 'deallocates a number' do
60
+ stub_request(:get, "https://USERNAME:PASSWORD@api.46elks.com/a1/Numbers").
61
+ with(:headers => {'Accept'=>'application/json'}).
62
+ to_return(fixture('gets_allocated_numbers.txt'))
63
+ stub_request(:post, "https://USERNAME:PASSWORD@api.46elks.com/a1/Numbers/nea19c8e291676fb7003fa1d63bba7899").
64
+ with(:body => {"active" => "no"},
65
+ :headers => {'Accept'=>'application/json', 'Content-Type'=>'application/x-www-form-urlencoded'}).
66
+ to_return(fixture('deallocates_a_number.txt'))
67
+
68
+ configure_elk
69
+
70
+ number = Elk::Number.all[0]
71
+ number.status.should == :active
72
+ number.deallocate!.should == true
73
+ number.status.should == :deallocated
74
+ end
75
+
76
+ it 'reloads a number' do
77
+ stub_request(:get, "https://USERNAME:PASSWORD@api.46elks.com/a1/Numbers").
78
+ with(:headers => {'Accept'=>'application/json'}).
79
+ to_return(fixture('gets_allocated_numbers.txt'))
80
+ stub_request(:get, "https://USERNAME:PASSWORD@api.46elks.com/a1/Numbers/nea19c8e291676fb7003fa1d63bba7899").
81
+ with(:headers => {'Accept'=>'application/json'}).
82
+ to_return(fixture('reloads_a_number.txt'))
83
+
84
+ configure_elk
85
+
86
+ number = Elk::Number.all[0]
87
+ object_id = number.object_id
88
+ loaded_at = number.loaded_at
89
+ number.country = 'blah'
90
+ number.reload.should == true
91
+ number.country.should == 'se'
92
+ number.object_id.should == object_id
93
+ number.loaded_at.should_not == loaded_at
94
+ end
95
+
96
+ it 'has wrong password' do
97
+ stub_request(:get, "https://USERNAME:WRONG@api.46elks.com/a1/Numbers").
98
+ with(:headers => {'Accept'=>'application/json'}).
99
+ to_return(fixture('auth_error.txt'))
100
+
101
+ Elk.configure do |config|
102
+ config.username = 'USERNAME'
103
+ config.password = 'WRONG'
104
+ end
105
+
106
+ expect {
107
+ Elk::Number.all
108
+ }.to raise_error(Elk::AuthError)
109
+ end
110
+
111
+ it 'gets server error when looking for all numbers' do
112
+ stub_request(:get, "https://USERNAME:PASSWORD@api.46elks.com/a1/Numbers").
113
+ with(:headers => {'Accept'=>'application/json'}).
114
+ to_return(fixture('server_error.txt'))
115
+
116
+ configure_elk
117
+
118
+ expect {
119
+ Elk::Number.all
120
+ }.to raise_error(Elk::ServerError)
121
+ end
122
+
123
+ it 'gets garbage numbers' do
124
+ bad_response_body = fixture('bad_response_body.txt').read
125
+
126
+ expect {
127
+ Elk.parse_json(bad_response_body)
128
+ }.to raise_error(Elk::BadResponse)
129
+ end
130
+ end
131
+
132
+ describe Elk::SMS do
133
+ it 'sends a SMS' do
134
+ stub_request(:post, "https://USERNAME:PASSWORD@api.46elks.com/a1/SMS").
135
+ with(:body => {"from" => "+46761042247", :message => "Your order #171 has now been sent!", :to => "+46704508449"},
136
+ :headers => {'Accept'=>'application/json', 'Content-Type'=>'application/x-www-form-urlencoded'}).
137
+ to_return(fixture('sends_a_sms.txt'))
138
+
139
+ configure_elk
140
+
141
+ # Fake $stderr to check warnings
142
+ begin
143
+ old_stderr, $stderr = $stderr, StringIO.new
144
+
145
+ sms = Elk::SMS.send(:from => '+46761042247',
146
+ :to => '+46704508449',
147
+ :message => 'Your order #171 has now been sent!')
148
+
149
+ $stderr.string.should == ""
150
+ ensure
151
+ $stderr = old_stderr
152
+ end
153
+
154
+ sms.class.should == Elk::SMS
155
+ sms.from.should == '+46761042247'
156
+ sms.to.should == '+46704508449'
157
+ sms.message.should == 'Your order #171 has now been sent!'
158
+ end
159
+
160
+ it 'gets SMS-history' do
161
+ stub_request(:get, "https://USERNAME:PASSWORD@api.46elks.com/a1/SMS").
162
+ with(:headers => {'Accept'=>'application/json'}).
163
+ to_return(fixture('sms_history.txt'))
164
+
165
+ configure_elk
166
+
167
+ sms_history = Elk::SMS.all
168
+
169
+ sms_history.size.should == 3
170
+ sms_history[0].class.should == Elk::SMS
171
+ sms_history[0].created_at.class.should == Time
172
+
173
+ sms_history[0].message.should == "Your order #171 has now been sent!"
174
+ sms_history[1].message.should == "I'd like to order a pair of elks!"
175
+ sms_history[2].message.should == "Want an elk?"
176
+ end
177
+
178
+ it 'reloads a SMS' do
179
+ stub_request(:get, "https://USERNAME:PASSWORD@api.46elks.com/a1/SMS").
180
+ with(:headers => {'Accept'=>'application/json'}).
181
+ to_return(fixture('sms_history.txt'))
182
+ stub_request(:get, "https://USERNAME:PASSWORD@api.46elks.com/a1/SMS/s8952031bb83bf3e64f8e13b071c131c0").
183
+ with(:headers => {'Accept'=>'application/json'}).
184
+ to_return(fixture('reloads_a_sms.txt'))
185
+
186
+ configure_elk
187
+
188
+ sms_history = Elk::SMS.all
189
+ sms = sms_history[0]
190
+ loaded_at = sms.loaded_at
191
+ object_id = sms.object_id
192
+ sms.reload.should == true
193
+ sms.object_id.should == object_id
194
+ sms.loaded_at.should_not == loaded_at
195
+ end
196
+
197
+ it 'should warn about capped sms sender' do
198
+ stub_request(:post, "https://USERNAME:PASSWORD@api.46elks.com/a1/SMS").
199
+ with(:body => {"from" => "VeryVeryVeryVeryLongSenderName", :message => "Your order #171 has now been sent!", :to => "+46704508449"},
200
+ :headers => {'Accept'=>'application/json', 'Content-Type'=>'application/x-www-form-urlencoded'}).
201
+ to_return(fixture('sends_a_sms_with_long_sender.txt'))
202
+
203
+ configure_elk
204
+
205
+ # Fake $stderr to check warnings
206
+ begin
207
+ old_stderr, $stderr = $stderr, StringIO.new
208
+
209
+ sms = Elk::SMS.send(:from => 'VeryVeryVeryVeryLongSenderName',
210
+ :to => '+46704508449',
211
+ :message => 'Your order #171 has now been sent!')
212
+
213
+ $stderr.string.should == "SMS 'from' value VeryVeryVeryVeryLongSenderName will be capped at 11 chars\n"
214
+ ensure
215
+ $stderr = old_stderr
216
+ end
217
+
218
+ sms.class.should == Elk::SMS
219
+ sms.from.should == 'VeryVeryVeryVeryLongSenderName'
220
+ sms.to.should == '+46704508449'
221
+ sms.message.should == 'Your order #171 has now been sent!'
222
+ end
223
+
224
+ end
225
+ end
@@ -0,0 +1,8 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/0.7.67
3
+ Date: Wed, 06 Jul 2011 18:50:11 GMT
4
+ Content-Type: application/json
5
+ Connection: keep-alive
6
+ Content-Length: 167
7
+
8
+ {"country": "se", "number": "+46766861012", "capabilities": ["sms"], "active": "yes", "sms_url": "http://localhost/receive", "id": "n415f0b3b3d812ab5fb333c7ef605f329"}
@@ -0,0 +1,9 @@
1
+ HTTP/1.1 401 Authorization Required
2
+ Server: nginx/0.7.67
3
+ Date: Sun, 17 Jul 2011 16:18:36 GMT
4
+ Content-Type: text/plain
5
+ Connection: keep-alive
6
+ Www-Authenticate: Basic realm="46elks API"
7
+ Content-Length: 84
8
+
9
+ API access require proper Basic HTTP authentication. Read documentation or examples.
@@ -0,0 +1 @@
1
+ {"numbers": [{"country": "se", "number": "+46704508449", "capabilities": ["sms"], "active": "yes", "sms_url": "http://localhost/receive1", "id": "nea19c8e291676fb7003fa1d63bba7899"}, {"country": "se", "number": "+46761042247", "capabilities": ["sms"], "active": "yes", "sms_url": "http://localhost/receive2", "id": "nea19c8e29
@@ -0,0 +1,8 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/0.7.67
3
+ Date: Sun, 17 Jul 2011 10:34:54 GMT
4
+ Content-Type: application/json
5
+ Connection: keep-alive
6
+ Content-Length: 167
7
+
8
+ {"country": "se", "number": "+46704508449", "capabilities": ["sms"], "active": "no", "sms_url": "http://localhost/receive1", "id": "nea19c8e291676fb7003fa1d63bba7899"}
@@ -0,0 +1,8 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/0.7.67
3
+ Date: Wed, 06 Jul 2011 18:48:32 GMT
4
+ Content-Type: application/json
5
+ Connection: keep-alive
6
+ Content-Length: 353
7
+
8
+ {"numbers": [{"country": "se", "number": "+46704508449", "capabilities": ["sms"], "active": "yes", "sms_url": "http://localhost/receive1", "id": "nea19c8e291676fb7003fa1d63bba7899"}, {"country": "se", "number": "+46761042247", "capabilities": ["sms"], "active": "yes", "sms_url": "http://localhost/receive2", "id": "nea19c8e291676fb7003fa1d63bba789A"}]}
@@ -0,0 +1,8 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/0.7.67
3
+ Date: Sun, 17 Jul 2011 11:51:34 GMT
4
+ Content-Type: application/json
5
+ Connection: keep-alive
6
+ Content-Length: 168
7
+
8
+ {"country": "se", "number": "+46704508449", "capabilities": ["sms"], "active": "yes", "sms_url": "http://localhost/receive1", "id": "nea19c8e291676fb7003fa1d63bba7899"}
@@ -0,0 +1,8 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/0.7.67
3
+ Date: Sun, 17 Jul 2011 11:55:44 GMT
4
+ Content-Type: application/json
5
+ Connection: keep-alive
6
+ Content-Length: 179
7
+
8
+ {"to": "+46704508449", "message": "Your order #171 has now been sent!", "from": "+46761042247", "id": "s8952031bb83bf3e64f8e13b071c131c0", "created": "2011-07-17T10:58:57.130000"}
@@ -0,0 +1,8 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/0.7.67
3
+ Date: Tue, 05 Jul 2011 15:32:45 GMT
4
+ Content-Type: application/json
5
+ Connection: keep-alive
6
+ Content-Length: 179
7
+
8
+ {"to": "+46704508449", "message": "Your order #171 has now been sent!", "from": "+46761042247", "id": "scbc6667592e7245fa1abcdc74682f690", "created": "2011-07-05T15:32:45.296367"}
@@ -0,0 +1,8 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/0.7.67
3
+ Date: Tue, 05 Jul 2011 15:32:45 GMT
4
+ Content-Type: application/json
5
+ Connection: keep-alive
6
+ Content-Length: 197
7
+
8
+ {"to": "+46704508449", "message": "Your order #171 has now been sent!", "from": "VeryVeryVeryVeryLongSenderName", "id": "scbc6667592e7245fa1abcdc74682f690", "created": "2011-07-05T15:32:45.296367"}
@@ -0,0 +1,6 @@
1
+ HTTP/1.1 500 Internal Server Error
2
+ Server: nginx/0.7.67
3
+ Date: Tue, 05 Jul 2011 15:32:45 GMT
4
+ Content-Type: application/json
5
+ Connection: keep-alive
6
+ Content-Length: 0
@@ -0,0 +1,8 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/0.7.67
3
+ Date: Sun, 17 Jul 2011 11:13:02 GMT
4
+ Content-Type: application/json
5
+ Connection: keep-alive
6
+ Content-Length: 531
7
+
8
+ {"smses": [{"to": "+46704508449", "message": "Your order #171 has now been sent!", "from": "+46761042247", "id": "s8952031bb83bf3e64f8e13b071c131c0", "created": "2011-07-17T10:58:57.130000"}, {"to": "+46761042247", "message": "I'd like to order a pair of elks!", "from": "+46704508449", "id": "sf661a8a644b1a8e044e98b9003db5464", "created": "2011-07-05T14:40:08.481000"}, {"to": "+46704508449", "message": "Want an elk?", "from": "+46761042247", "id": "s698228b54946eb0452b66936da37cc66", "created": "2011-07-05T14:06:13.705000"}]}
@@ -0,0 +1,8 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/0.7.67
3
+ Date: Sun, 17 Jul 2011 10:34:54 GMT
4
+ Content-Type: application/json
5
+ Connection: keep-alive
6
+ Content-Length: 167
7
+
8
+ {"country": "no", "number": "+46704508449", "capabilities": ["sms"], "active": "yes", "sms_url": "http://otherhost/receive", "id": "nea19c8e291676fb7003fa1d63bba7899"}
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'rspec'
4
+ require 'webmock/rspec'
5
+
6
+ def fixture_path
7
+ File.expand_path(File.join('..', 'fixtures'), __FILE__)
8
+ end
9
+
10
+ def fixture(file)
11
+ File.new(File.join(fixture_path, file))
12
+ end
13
+
14
+ def configure_elk
15
+ Elk.configure do |config|
16
+ config.username = 'USERNAME'
17
+ config.password = 'PASSWORD'
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: elk
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: 5
5
+ version: 0.0.3p0
6
+ platform: ruby
7
+ authors:
8
+ - Johan Eckerstroem
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-07-17 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: json_pure
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 1.5.2
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: rest-client
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 1.6.3
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: rake
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.9.2
46
+ type: :development
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 2.6.0
57
+ type: :development
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: webmock
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 1.6.4
68
+ type: :development
69
+ version_requirements: *id005
70
+ description: elk can be used to allocate a phone numbers, manage the numbers and send/recieve messages through these numbers.
71
+ email: johan@duh.se
72
+ executables: []
73
+
74
+ extensions: []
75
+
76
+ extra_rdoc_files:
77
+ - README.MD
78
+ files:
79
+ - lib/elk/number.rb
80
+ - lib/elk/sms.rb
81
+ - lib/elk.rb
82
+ - spec/elk_spec.rb
83
+ - spec/fixtures/allocates_a_number.txt
84
+ - spec/fixtures/auth_error.txt
85
+ - spec/fixtures/bad_response_body.txt
86
+ - spec/fixtures/deallocates_a_number.txt
87
+ - spec/fixtures/gets_allocated_numbers.txt
88
+ - spec/fixtures/reloads_a_number.txt
89
+ - spec/fixtures/reloads_a_sms.txt
90
+ - spec/fixtures/sends_a_sms.txt
91
+ - spec/fixtures/sends_a_sms_with_long_sender.txt
92
+ - spec/fixtures/server_error.txt
93
+ - spec/fixtures/sms_history.txt
94
+ - spec/fixtures/updates_a_number.txt
95
+ - spec/spec_helper.rb
96
+ - README.MD
97
+ homepage: https://github.com/jage/elk
98
+ licenses: []
99
+
100
+ post_install_message:
101
+ rdoc_options: []
102
+
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: "0"
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">"
115
+ - !ruby/object:Gem::Version
116
+ version: 1.3.1
117
+ requirements: []
118
+
119
+ rubyforge_project:
120
+ rubygems_version: 1.8.5
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: Client library for 46elks SMS/MMS/Voice service.
124
+ test_files: []
125
+