esendex 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/lib/esendex.rb +2 -2
- data/lib/esendex/account.rb +13 -7
- data/lib/esendex/api_connection.rb +22 -21
- data/lib/esendex/dispatcher_result.rb +25 -0
- data/lib/esendex/message_batch_submission.rb +8 -6
- data/lib/esendex/version.rb +1 -1
- data/readme.md +14 -4
- data/spec/account_spec.rb +139 -14
- data/spec/api_connection_spec.rb +8 -8
- data/spec/dummy/script/rails +0 -0
- data/spec/message_batch_submission_spec.rb +23 -5
- data/spec/message_spec.rb +2 -2
- data/spec/spec_helper.rb +5 -1
- metadata +12 -15
- data/spec/dummy/log/development.log +0 -83
- data/spec/dummy/log/test.log +0 -14
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
M2I2ZDkyODUwMDY3NWRkNDhhYjUwOTMzZGI4OThiNzk5MWY4Njk4MzgwYTRj
|
10
|
-
OGRiYTkzZjg5Y2Y5MDgzNDAxOWI1OTlkNGNhMmQ1NGFkZWFmZGM4MmFjZDJl
|
11
|
-
NTkwZGQ4MWY4MjJiOTViNTE3Yjc1YTRiMDdiYzY0MjkzNjhjYWU=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MjNlYjFjZTY0NzdhNjhjNDgyYTBhM2QzNmFiNjM5MTM2NDIyNmU0NWY4N2Ji
|
14
|
-
NjI3NDRiYWMxZWRmNGRkNWYwMDg2ZDU5YTBmMGNkN2JmMGI4YzIyMWNmMGVh
|
15
|
-
Yzk0NzViZjE0YTFiMDRlOTI0MjgxMmE0NjRmMzZhMGYxNzIzZTA=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f9cb035158a9964f5fb7f6bb2719915755e0b6e6
|
4
|
+
data.tar.gz: dd8655c31f2d0712ed387d596a714ad6901e5b3c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 30b5201c1c965b9ae62a6dc148ffc42c9d14983a76ee635a42378279bb4e3d77984eb15d35c804316ba26e23b7dbd1407165af3152f5b7ca34627b2a26e7964b
|
7
|
+
data.tar.gz: db9c603a303f20819bbfa00e0dbe6c453f53761aad3a76319289881a6897e01e9102a408f307f764652560cb71a8e4b3e7dad8af4d4120cb0993104ac9c35ee2
|
data/lib/esendex.rb
CHANGED
@@ -5,6 +5,7 @@ module Esendex
|
|
5
5
|
require_relative 'esendex/hash_serialisation'
|
6
6
|
|
7
7
|
require_relative 'esendex/account'
|
8
|
+
require_relative 'esendex/dispatcher_result'
|
8
9
|
require_relative 'esendex/inbound_message'
|
9
10
|
require_relative 'esendex/message'
|
10
11
|
require_relative 'esendex/message_batch_submission'
|
@@ -19,7 +20,6 @@ module Esendex
|
|
19
20
|
|
20
21
|
API_NAMESPACE = 'http://api.esendex.com/ns/'
|
21
22
|
API_HOST = 'https://api.esendex.com'
|
22
|
-
API_VERSION = 'v1.0'
|
23
23
|
|
24
24
|
# Public - used to configure the gem prior to use
|
25
25
|
#
|
@@ -42,7 +42,7 @@ module Esendex
|
|
42
42
|
|
43
43
|
# behaviour config
|
44
44
|
attr_accessor :suppress_error_backtrace
|
45
|
-
|
45
|
+
|
46
46
|
def account_reference
|
47
47
|
@account_reference ||= ENV['ESENDEX_ACCOUNT']
|
48
48
|
end
|
data/lib/esendex/account.rb
CHANGED
@@ -2,6 +2,8 @@ require 'nokogiri'
|
|
2
2
|
|
3
3
|
module Esendex
|
4
4
|
class Account
|
5
|
+
DEFAULT_DATE_OFFSET = 90
|
6
|
+
|
5
7
|
attr_accessor :reference
|
6
8
|
|
7
9
|
def initialize(account_reference = Esendex.account_reference)
|
@@ -15,24 +17,28 @@ module Esendex
|
|
15
17
|
def messages_remaining
|
16
18
|
response = api_connection.get "/v1.0/accounts"
|
17
19
|
doc = Nokogiri::XML(response.body)
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
node = doc.at_xpath("//api:account[api:reference='#{@reference}']/api:messagesremaining", 'api' => Esendex::API_NAMESPACE)
|
21
|
+
raise AccountReferenceError.new if node.nil?
|
22
|
+
node.content.to_i
|
21
23
|
end
|
22
24
|
|
23
25
|
def send_message(args={})
|
24
26
|
raise ArgumentError.new(":to required") unless args[:to]
|
25
27
|
raise ArgumentError.new(":body required") unless args[:body]
|
26
28
|
|
27
|
-
send_messages
|
29
|
+
send_messages [Message.new(args[:to], args[:body], args[:from])]
|
28
30
|
end
|
29
31
|
|
30
32
|
def send_messages(messages)
|
31
33
|
batch_submission = MessageBatchSubmission.new(@reference, messages)
|
32
|
-
response = api_connection.post
|
33
|
-
|
34
|
-
doc.at_xpath('//api:messageheaders', 'api' => Esendex::API_NAMESPACE)['batchid']
|
34
|
+
response = api_connection.post("/v1.0/messagedispatcher", batch_submission.to_s)
|
35
|
+
DispatcherResult.from_xml response.body
|
35
36
|
end
|
36
37
|
|
38
|
+
def sent_messages(args={})
|
39
|
+
SentMessageClient
|
40
|
+
.new(api_connection)
|
41
|
+
.get_messages(args.merge(account_reference: reference))
|
42
|
+
end
|
37
43
|
end
|
38
44
|
end
|
@@ -1,28 +1,29 @@
|
|
1
1
|
require 'nestful'
|
2
2
|
|
3
|
-
|
3
|
+
module Esendex
|
4
|
+
class ApiConnection
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
def initialize
|
7
|
+
@connection = Nestful::Connection.new(Esendex::API_HOST)
|
8
|
+
@connection.user = Esendex.username
|
9
|
+
@connection.password = Esendex.password
|
10
|
+
@connection.auth_type = :basic
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def default_headers
|
14
|
+
{ 'User-Agent' => Esendex.user_agent }
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
def get(url)
|
18
|
+
@connection.get url, default_headers
|
19
|
+
rescue => e
|
20
|
+
raise Esendex::ApiErrorFactory.new.get_api_error(e)
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
def post(url, body)
|
24
|
+
@connection.post url, body, default_headers
|
25
|
+
rescue => e
|
26
|
+
raise Esendex::ApiErrorFactory.new.get_api_error(e)
|
27
|
+
end
|
26
28
|
end
|
27
|
-
|
28
|
-
end
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Esendex
|
4
|
+
class DispatcherResult
|
5
|
+
attr_reader :batch_id, :messages
|
6
|
+
|
7
|
+
def initialize(batch_id, messages)
|
8
|
+
@batch_id = batch_id
|
9
|
+
@messages = messages
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.from_xml(source)
|
13
|
+
doc = Nokogiri::XML source
|
14
|
+
batch_id = doc.at_xpath('//api:messageheaders', 'api' => Esendex::API_NAMESPACE)['batchid']
|
15
|
+
messages = doc.xpath('//api:messageheader', 'api' => Esendex::API_NAMESPACE).map do |header|
|
16
|
+
{ id: header['id'], uri: header['uri'] }
|
17
|
+
end
|
18
|
+
DispatcherResult.new batch_id, messages
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
batch_id
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -17,9 +17,11 @@ module Esendex
|
|
17
17
|
attr_accessor :account_reference, :messages, :send_at
|
18
18
|
|
19
19
|
def initialize(account_reference, messages)
|
20
|
+
raise AccountReferenceError unless account_reference
|
21
|
+
raise StandardError, "Need at least one message" unless messages.kind_of?(Array) && !messages.empty?
|
22
|
+
|
20
23
|
@account_reference = account_reference
|
21
24
|
@messages = messages
|
22
|
-
@send_at = send_at
|
23
25
|
end
|
24
26
|
|
25
27
|
def xml_node
|
@@ -29,10 +31,10 @@ module Esendex
|
|
29
31
|
account_reference.content = self.account_reference
|
30
32
|
doc.root.add_child(account_reference)
|
31
33
|
|
32
|
-
if
|
33
|
-
|
34
|
-
|
35
|
-
doc.root.add_child(
|
34
|
+
if send_at
|
35
|
+
send_at_node = Nokogiri::XML::Node.new 'sendat', doc
|
36
|
+
send_at_node.content = send_at.strftime("%Y-%m-%dT%H:%M:%S")
|
37
|
+
doc.root.add_child(send_at_node)
|
36
38
|
end
|
37
39
|
|
38
40
|
@messages.each do |message|
|
@@ -43,7 +45,7 @@ module Esendex
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def to_s
|
46
|
-
|
48
|
+
xml_node.to_s
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
data/lib/esendex/version.rb
CHANGED
data/readme.md
CHANGED
@@ -33,11 +33,11 @@ You can also specify these using the environment variables `ESENDEX_USERNAME`, `
|
|
33
33
|
### Sending Messages
|
34
34
|
|
35
35
|
First instantiate an Account with the reference. You can omit the reference if you've already configured one to use in the *Esendex.configure* step.
|
36
|
-
Then, call the send method on the account object with a hash describing the message. The return value is a *batch_id* you can use to obtain the status of the messages you have sent.
|
36
|
+
Then, call the send method on the account object with a hash describing the message. The return value is a *DispatcherResult* which has the *batch_id* you can use to obtain the status of the *messages* you have sent.
|
37
37
|
|
38
38
|
```ruby
|
39
39
|
account = Account.new
|
40
|
-
|
40
|
+
result = account.send_message( to: "07777111222", body: "Saying hello to the world with the help of Esendex")
|
41
41
|
```
|
42
42
|
You can specify a different account to the default by passing the reference in as an initialization argument
|
43
43
|
|
@@ -48,7 +48,17 @@ account = Account.new('EX23847')
|
|
48
48
|
Multiple messages are sent by passing an array of `Messages` to the `send_messages` method
|
49
49
|
|
50
50
|
```ruby
|
51
|
-
|
51
|
+
result = account.send_messages([Message.new("07777111222", "Hello"), Message.new("07777111333", "Hi")])
|
52
|
+
```
|
53
|
+
|
54
|
+
Sent messages can be retrieved by calling the `sent_messages` method. The return value is a *SentMessagesResult*
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
result = account.sent_messages
|
58
|
+
puts result
|
59
|
+
result.messages.each do |message|
|
60
|
+
puts message
|
61
|
+
end
|
52
62
|
```
|
53
63
|
|
54
64
|
### Testing Configuration
|
@@ -86,7 +96,7 @@ Classes are provided in the gem for deserialising the notifications: `MessageDel
|
|
86
96
|
message = InboundMessage.from_xml request.body
|
87
97
|
```
|
88
98
|
|
89
|
-
### Rails 3
|
99
|
+
### Rails 3 / Rails 4
|
90
100
|
|
91
101
|
In order to simplify receipt of push notifications for Rails 3 users, the gem ships with mountable Rails controllers to handle the receipt of these notifications.
|
92
102
|
|
data/spec/account_spec.rb
CHANGED
@@ -38,34 +38,71 @@ describe Account do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
describe "#messages_remaining" do
|
41
|
-
|
42
41
|
subject { account.messages_remaining }
|
43
42
|
|
44
43
|
it "should get the account resource" do
|
45
44
|
api_connection.should_receive(:get).with("/v1.0/accounts")
|
46
45
|
subject
|
47
46
|
end
|
47
|
+
|
48
48
|
it "should get the messages remaining from the document" do
|
49
49
|
subject.should eq(messages_remaining)
|
50
50
|
end
|
51
|
+
|
52
|
+
context "with invalid reference" do
|
53
|
+
before(:each) do
|
54
|
+
account.reference = "invalid"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should raise AccountReferenceError" do
|
58
|
+
expect { account.messages_remaining }.to raise_error(AccountReferenceError)
|
59
|
+
end
|
60
|
+
end
|
51
61
|
end
|
52
|
-
|
53
|
-
describe "#
|
62
|
+
|
63
|
+
describe "#send_message" do
|
64
|
+
let(:batch_id) { random_string }
|
65
|
+
let(:send_response_xml) {
|
66
|
+
"<?xml version=\"1.0\" encoding=\"utf-8\"?>
|
67
|
+
<messageheaders batchid=\"#{batch_id}\" xmlns=\"http://api.esendex.com/ns/\">
|
68
|
+
<messageheader\ uri=\"http://api.esendex.com/v1.0/MessageHeaders/00000000-0000-0000-0000-000000000001\" id=\"00000000-0000-0000-0000-000000000001\" />
|
69
|
+
</messageheaders>"
|
70
|
+
}
|
71
|
+
|
54
72
|
before(:each) do
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
73
|
+
api_connection.stub(:post) { mock('Response', :body => send_response_xml) }
|
74
|
+
end
|
75
|
+
|
76
|
+
subject { account.send_message(to: "447815777555", body: "Hello from the Esendex Ruby Gem") }
|
77
|
+
|
78
|
+
it "should post to the message dispatcher resource" do
|
79
|
+
api_connection.should_receive(:post).with("/v1.0/messagedispatcher", anything)
|
80
|
+
subject
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should return the batch_id when treated as string" do
|
84
|
+
subject.to_s.should eq(batch_id)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should return the batch_id in the result" do
|
88
|
+
subject.batch_id.should eq(batch_id)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should provide a list of messages with a single message" do
|
92
|
+
subject.messages.should have(1).items
|
60
93
|
end
|
61
94
|
end
|
62
95
|
|
63
|
-
describe "#
|
96
|
+
describe "#send_messages" do
|
64
97
|
let(:batch_id) { random_string }
|
98
|
+
let(:uri_prefix) { "https://api.esendex.com/messages/" }
|
99
|
+
let(:message_one_id) { random_guid }
|
100
|
+
let(:message_two_id) { random_guid }
|
65
101
|
let(:send_response_xml) {
|
66
102
|
"<?xml version=\"1.0\" encoding=\"utf-8\"?>
|
67
103
|
<messageheaders batchid=\"#{batch_id}\" xmlns=\"http://api.esendex.com/ns/\">
|
68
|
-
<messageheader\ uri=\"
|
104
|
+
<messageheader\ uri=\"#{uri_prefix}#{message_one_id}\" id=\"#{message_one_id}\" />
|
105
|
+
<messageheader\ uri=\"#{uri_prefix}#{message_two_id}\" id=\"#{message_two_id}\" />
|
69
106
|
</messageheaders>"
|
70
107
|
}
|
71
108
|
|
@@ -75,12 +112,100 @@ describe Account do
|
|
75
112
|
|
76
113
|
subject { account.send_message(to: "447815777555", body: "Hello from the Esendex Ruby Gem") }
|
77
114
|
|
78
|
-
it "
|
115
|
+
it "should post to the message dispatcher resource" do
|
79
116
|
api_connection.should_receive(:post).with("/v1.0/messagedispatcher", anything)
|
80
117
|
subject
|
81
118
|
end
|
82
|
-
|
83
|
-
|
119
|
+
|
120
|
+
it "should provide a list containing two messages" do
|
121
|
+
subject.messages.should have(2).items
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should have message one in the message list" do
|
125
|
+
subject.messages.should include(id: "#{message_one_id}", uri: "#{uri_prefix}#{message_one_id}")
|
84
126
|
end
|
85
|
-
|
127
|
+
|
128
|
+
it "should have message two in the message list" do
|
129
|
+
subject.messages.should include(id: "#{message_two_id}", uri: "#{uri_prefix}#{message_two_id}")
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe "#sent_messages" do
|
134
|
+
let(:sent_message_client) { stub("sent_message_client") }
|
135
|
+
let(:sent_messages_result) { Class.new }
|
136
|
+
|
137
|
+
before(:each) do
|
138
|
+
stub_const("Esendex::SentMessageClient", sent_message_client)
|
139
|
+
sent_message_client
|
140
|
+
.should_receive(:new)
|
141
|
+
.with(api_connection)
|
142
|
+
.and_return(sent_message_client)
|
143
|
+
end
|
144
|
+
|
145
|
+
context "with no args" do
|
146
|
+
before(:each) do
|
147
|
+
sent_message_client
|
148
|
+
.should_receive(:get_messages)
|
149
|
+
.with({account_reference: account_reference})
|
150
|
+
.and_return(sent_messages_result)
|
151
|
+
end
|
152
|
+
|
153
|
+
subject { account.sent_messages() }
|
154
|
+
|
155
|
+
it "should return expected result" do
|
156
|
+
subject.should eq(sent_messages_result)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
context "with start and finish dates" do
|
161
|
+
it "should pass dates without adjustment" do
|
162
|
+
start_date = DateTime.now - 30
|
163
|
+
finish_date = DateTime.now - 15
|
164
|
+
sent_message_client
|
165
|
+
.should_receive(:get_messages)
|
166
|
+
.with({account_reference: account_reference, start: start_date, finish: finish_date})
|
167
|
+
.and_return(sent_messages_result)
|
168
|
+
|
169
|
+
account.sent_messages({start: start_date, finish: finish_date}).should_not be_nil
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
context "with start date" do
|
174
|
+
it "should specify start date and default finish date" do
|
175
|
+
start_date = DateTime.now - 1
|
176
|
+
sent_message_client
|
177
|
+
.should_receive(:get_messages)
|
178
|
+
.with({account_reference: account_reference, start: start_date})
|
179
|
+
.and_return(sent_messages_result)
|
180
|
+
|
181
|
+
account.sent_messages({start: start_date}).should_not be_nil
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
context "with finish date" do
|
186
|
+
it "should specify default start date and finish date" do
|
187
|
+
finish_date = DateTime.now - 1
|
188
|
+
start_date = finish_date - 90
|
189
|
+
sent_message_client
|
190
|
+
.should_receive(:get_messages)
|
191
|
+
.with({account_reference: account_reference, finish: finish_date})
|
192
|
+
.and_return(sent_messages_result)
|
193
|
+
|
194
|
+
account.sent_messages({finish: finish_date}).should_not be_nil
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
context "with start index and count" do
|
199
|
+
it "should pass expected arguments" do
|
200
|
+
start_index = 3
|
201
|
+
count = 35
|
202
|
+
sent_message_client
|
203
|
+
.should_receive(:get_messages)
|
204
|
+
.with({account_reference: account_reference, start_index: start_index, count: count})
|
205
|
+
.and_return(sent_messages_result)
|
206
|
+
|
207
|
+
account.sent_messages({start_index: start_index, count: count}).should_not be_nil
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
86
211
|
end
|
data/spec/api_connection_spec.rb
CHANGED
@@ -15,22 +15,22 @@ describe ApiConnection do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
describe "#initialise" do
|
18
|
-
|
19
18
|
subject { ApiConnection.new }
|
20
19
|
|
21
20
|
it "should set the username" do
|
22
21
|
subject
|
23
22
|
@connection.user.should eq(Esendex.username)
|
24
23
|
end
|
24
|
+
|
25
25
|
it "should set the password" do
|
26
26
|
subject
|
27
27
|
@connection.password.should eq(Esendex.password)
|
28
28
|
end
|
29
|
+
|
29
30
|
it "should set the auth to basic" do
|
30
31
|
subject
|
31
32
|
@connection.auth_type.should eq(:basic)
|
32
33
|
end
|
33
|
-
|
34
34
|
end
|
35
35
|
|
36
36
|
|
@@ -48,11 +48,11 @@ describe ApiConnection do
|
|
48
48
|
before(:each) do
|
49
49
|
@connection.stub(:get) { raise Nestful::ForbiddenAccess.new(nil) }
|
50
50
|
end
|
51
|
-
|
52
|
-
|
51
|
+
|
52
|
+
it "raises an ForbiddenError" do
|
53
|
+
expect { subject }.to raise_error(ForbiddenError)
|
53
54
|
end
|
54
55
|
end
|
55
|
-
|
56
56
|
end
|
57
57
|
|
58
58
|
describe "#post" do
|
@@ -70,10 +70,10 @@ describe ApiConnection do
|
|
70
70
|
before(:each) do
|
71
71
|
@connection.stub(:post) { raise Nestful::ForbiddenAccess.new(nil) }
|
72
72
|
end
|
73
|
-
|
74
|
-
|
73
|
+
|
74
|
+
it "raises an ForbiddenError" do
|
75
|
+
expect { subject }.to raise_error(ForbiddenError)
|
75
76
|
end
|
76
77
|
end
|
77
|
-
|
78
78
|
end
|
79
79
|
end
|
data/spec/dummy/script/rails
CHANGED
File without changes
|
@@ -9,29 +9,47 @@ describe MessageBatchSubmission do
|
|
9
9
|
|
10
10
|
subject { message_batch.xml_node }
|
11
11
|
|
12
|
-
it "
|
12
|
+
it "creates message nodes" do
|
13
13
|
subject.xpath('//messages/message').count.should eq(messages.count)
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
|
+
it "sets the message to" do
|
16
17
|
(0..1).each do |i|
|
17
18
|
subject.xpath('//messages/message/to')[i].content.should eq(messages[i].to)
|
18
19
|
end
|
19
20
|
end
|
20
|
-
|
21
|
+
|
22
|
+
it "sets the message body" do
|
21
23
|
(0..1).each do |i|
|
22
24
|
subject.xpath('//messages/message/body')[i].content.should eq(messages[i].body)
|
23
25
|
end
|
24
26
|
end
|
25
|
-
|
27
|
+
|
28
|
+
context "when #send_at set" do
|
26
29
|
let(:target_time) { Time.local(2011, 4, 7, 15, 0, 0) }
|
27
30
|
|
28
31
|
before(:each) do
|
29
32
|
message_batch.send_at = target_time
|
30
33
|
end
|
31
34
|
|
32
|
-
it "
|
35
|
+
it "creates a properly formatted sendat node" do
|
33
36
|
subject.at_xpath('//messages/sendat').content.should eq("2011-04-07T15:00:00")
|
34
37
|
end
|
35
38
|
end
|
36
39
|
end
|
40
|
+
|
41
|
+
describe "#initialize" do
|
42
|
+
context "with nil account reference" do
|
43
|
+
it "raises AccountReferenceError" do
|
44
|
+
messages = [Message.new(random_mobile, random_string)]
|
45
|
+
expect { MessageBatchSubmission.new nil, messages }.to raise_error(AccountReferenceError)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "with empty message array" do
|
50
|
+
it "raises expected error" do
|
51
|
+
expect { MessageBatchSubmission.new account, [] }.to raise_error("Need at least one message")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
37
55
|
end
|
data/spec/message_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esendex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Bird
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nestful
|
@@ -28,14 +28,14 @@ dependencies:
|
|
28
28
|
name: nokogiri
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.4.4.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.4.4.1
|
41
41
|
description: Send SMS from your application using the Esendex API
|
@@ -53,8 +53,10 @@ files:
|
|
53
53
|
- app/controllers/esendex/message_failed_events_controller.rb
|
54
54
|
- app/controllers/esendex/push_notification_handler.rb
|
55
55
|
- config/routes.rb
|
56
|
+
- lib/esendex.rb
|
56
57
|
- lib/esendex/account.rb
|
57
58
|
- lib/esendex/api_connection.rb
|
59
|
+
- lib/esendex/dispatcher_result.rb
|
58
60
|
- lib/esendex/engine.rb
|
59
61
|
- lib/esendex/exceptions.rb
|
60
62
|
- lib/esendex/hash_serialisation.rb
|
@@ -65,7 +67,6 @@ files:
|
|
65
67
|
- lib/esendex/message_failed_event.rb
|
66
68
|
- lib/esendex/railtie.rb
|
67
69
|
- lib/esendex/version.rb
|
68
|
-
- lib/esendex.rb
|
69
70
|
- lib/tasks/esendex.rake
|
70
71
|
- licence.txt
|
71
72
|
- readme.md
|
@@ -73,11 +74,14 @@ files:
|
|
73
74
|
- spec/api_connection_spec.rb
|
74
75
|
- spec/controllers/message_delivered_events_controller_spec.rb
|
75
76
|
- spec/controllers/push_notification_handler_spec.rb
|
77
|
+
- spec/dummy/README.rdoc
|
78
|
+
- spec/dummy/Rakefile
|
76
79
|
- spec/dummy/app/assets/javascripts/application.js
|
77
80
|
- spec/dummy/app/assets/stylesheets/application.css
|
78
81
|
- spec/dummy/app/controllers/application_controller.rb
|
79
82
|
- spec/dummy/app/helpers/application_helper.rb
|
80
83
|
- spec/dummy/app/views/layouts/application.html.erb
|
84
|
+
- spec/dummy/config.ru
|
81
85
|
- spec/dummy/config/application.rb
|
82
86
|
- spec/dummy/config/boot.rb
|
83
87
|
- spec/dummy/config/environment.rb
|
@@ -92,15 +96,10 @@ files:
|
|
92
96
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
93
97
|
- spec/dummy/config/locales/en.yml
|
94
98
|
- spec/dummy/config/routes.rb
|
95
|
-
- spec/dummy/config.ru
|
96
|
-
- spec/dummy/log/development.log
|
97
|
-
- spec/dummy/log/test.log
|
98
99
|
- spec/dummy/public/404.html
|
99
100
|
- spec/dummy/public/422.html
|
100
101
|
- spec/dummy/public/500.html
|
101
102
|
- spec/dummy/public/favicon.ico
|
102
|
-
- spec/dummy/Rakefile
|
103
|
-
- spec/dummy/README.rdoc
|
104
103
|
- spec/dummy/script/rails
|
105
104
|
- spec/hash_serialisation_spec.rb
|
106
105
|
- spec/inbound_message_spec.rb
|
@@ -118,17 +117,17 @@ require_paths:
|
|
118
117
|
- lib
|
119
118
|
required_ruby_version: !ruby/object:Gem::Requirement
|
120
119
|
requirements:
|
121
|
-
- -
|
120
|
+
- - '>='
|
122
121
|
- !ruby/object:Gem::Version
|
123
122
|
version: '0'
|
124
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
124
|
requirements:
|
126
|
-
- -
|
125
|
+
- - '>='
|
127
126
|
- !ruby/object:Gem::Version
|
128
127
|
version: '0'
|
129
128
|
requirements: []
|
130
129
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.4.8
|
132
131
|
signing_key:
|
133
132
|
specification_version: 4
|
134
133
|
summary: Gem for interacting with the Esendex API
|
@@ -157,8 +156,6 @@ test_files:
|
|
157
156
|
- spec/dummy/config/locales/en.yml
|
158
157
|
- spec/dummy/config/routes.rb
|
159
158
|
- spec/dummy/config.ru
|
160
|
-
- spec/dummy/log/development.log
|
161
|
-
- spec/dummy/log/test.log
|
162
159
|
- spec/dummy/public/404.html
|
163
160
|
- spec/dummy/public/422.html
|
164
161
|
- spec/dummy/public/500.html
|
@@ -1,83 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Started GET "/esendex/message_delivered_events" for 127.0.0.1 at 2013-02-26 09:20:04 +0000
|
4
|
-
Connecting to database specified by database.yml
|
5
|
-
|
6
|
-
ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished):
|
7
|
-
activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
|
8
|
-
activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
|
9
|
-
activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
|
10
|
-
activerecord (3.2.12) lib/active_record/query_cache.rb:67:in `rescue in call'
|
11
|
-
activerecord (3.2.12) lib/active_record/query_cache.rb:61:in `call'
|
12
|
-
activerecord (3.2.12) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
|
13
|
-
actionpack (3.2.12) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
|
14
|
-
activesupport (3.2.12) lib/active_support/callbacks.rb:405:in `_run__3535235831481479337__call__1320289842362401676__callbacks'
|
15
|
-
activesupport (3.2.12) lib/active_support/callbacks.rb:405:in `__run_callback'
|
16
|
-
activesupport (3.2.12) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
|
17
|
-
activesupport (3.2.12) lib/active_support/callbacks.rb:81:in `run_callbacks'
|
18
|
-
actionpack (3.2.12) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
|
19
|
-
actionpack (3.2.12) lib/action_dispatch/middleware/reloader.rb:65:in `call'
|
20
|
-
actionpack (3.2.12) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
|
21
|
-
actionpack (3.2.12) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
|
22
|
-
actionpack (3.2.12) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
|
23
|
-
railties (3.2.12) lib/rails/rack/logger.rb:32:in `call_app'
|
24
|
-
railties (3.2.12) lib/rails/rack/logger.rb:16:in `block in call'
|
25
|
-
activesupport (3.2.12) lib/active_support/tagged_logging.rb:22:in `tagged'
|
26
|
-
railties (3.2.12) lib/rails/rack/logger.rb:16:in `call'
|
27
|
-
actionpack (3.2.12) lib/action_dispatch/middleware/request_id.rb:22:in `call'
|
28
|
-
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
|
29
|
-
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
|
30
|
-
activesupport (3.2.12) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
|
31
|
-
rack (1.4.5) lib/rack/lock.rb:15:in `call'
|
32
|
-
actionpack (3.2.12) lib/action_dispatch/middleware/static.rb:62:in `call'
|
33
|
-
railties (3.2.12) lib/rails/engine.rb:479:in `call'
|
34
|
-
railties (3.2.12) lib/rails/application.rb:223:in `call'
|
35
|
-
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
|
36
|
-
railties (3.2.12) lib/rails/rack/log_tailer.rb:17:in `call'
|
37
|
-
rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
|
38
|
-
/Users/adambird/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
|
39
|
-
/Users/adambird/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
|
40
|
-
/Users/adambird/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
|
41
|
-
|
42
|
-
|
43
|
-
Rendered /Users/adambird/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.12/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.9ms)
|
44
|
-
Rendered /Users/adambird/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.12/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.3ms)
|
45
|
-
Rendered /Users/adambird/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.12/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (10.7ms)
|
46
|
-
|
47
|
-
|
48
|
-
Started GET "/esendex/message_delivered_events" for 127.0.0.1 at 2013-02-26 09:23:48 +0000
|
49
|
-
|
50
|
-
ActionController::RoutingError (No route matches [GET] "/esendex/message_delivered_events"):
|
51
|
-
actionpack (3.2.12) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
|
52
|
-
actionpack (3.2.12) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
|
53
|
-
railties (3.2.12) lib/rails/rack/logger.rb:32:in `call_app'
|
54
|
-
railties (3.2.12) lib/rails/rack/logger.rb:16:in `block in call'
|
55
|
-
activesupport (3.2.12) lib/active_support/tagged_logging.rb:22:in `tagged'
|
56
|
-
railties (3.2.12) lib/rails/rack/logger.rb:16:in `call'
|
57
|
-
actionpack (3.2.12) lib/action_dispatch/middleware/request_id.rb:22:in `call'
|
58
|
-
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
|
59
|
-
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
|
60
|
-
activesupport (3.2.12) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
|
61
|
-
rack (1.4.5) lib/rack/lock.rb:15:in `call'
|
62
|
-
actionpack (3.2.12) lib/action_dispatch/middleware/static.rb:62:in `call'
|
63
|
-
railties (3.2.12) lib/rails/engine.rb:479:in `call'
|
64
|
-
railties (3.2.12) lib/rails/application.rb:223:in `call'
|
65
|
-
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
|
66
|
-
railties (3.2.12) lib/rails/rack/log_tailer.rb:17:in `call'
|
67
|
-
rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
|
68
|
-
/Users/adambird/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
|
69
|
-
/Users/adambird/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
|
70
|
-
/Users/adambird/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
|
71
|
-
|
72
|
-
|
73
|
-
Rendered /Users/adambird/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.12/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.7ms)
|
74
|
-
|
75
|
-
|
76
|
-
Started POST "/esendex/message_delivered_events" for 127.0.0.1 at 2013-02-26 09:24:19 +0000
|
77
|
-
Processing by Esendex::MessageDeliveredEventsController#create as */*
|
78
|
-
Completed 200 OK in 0ms (Views: 0.2ms)
|
79
|
-
|
80
|
-
|
81
|
-
Started POST "/esendex/message_delivered_events" for 127.0.0.1 at 2013-02-26 09:43:03 +0000
|
82
|
-
Processing by Esendex::MessageDeliveredEventsController#create as */*
|
83
|
-
Completed 200 OK in 0ms (Views: 0.1ms)
|
data/spec/dummy/log/test.log
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
Processing by Esendex::MessageDeliveredEventsController#create as HTML
|
2
|
-
Completed 200 OK in 0ms (Views: 0.2ms)
|
3
|
-
Processing by Esendex::MessageDeliveredEventsController#create as HTML
|
4
|
-
Completed 200 OK in 0ms (Views: 0.1ms)
|
5
|
-
Processing by Esendex::MessageDeliveredEventsController#create as HTML
|
6
|
-
Completed 200 OK in 0ms (Views: 0.1ms)
|
7
|
-
Processing by Esendex::MessageDeliveredEventsController#create as HTML
|
8
|
-
Completed 200 OK in 0ms (Views: 0.1ms)
|
9
|
-
Processing by Esendex::MessageDeliveredEventsController#create as HTML
|
10
|
-
Completed 200 OK in 0ms (Views: 0.1ms)
|
11
|
-
Received MessageDeliveredEvent but no handler configured
|
12
|
-
Rendered text template (0.0ms)
|
13
|
-
Received MessageDeliveredEvent but no handler configured
|
14
|
-
Rendered text template (0.0ms)
|