esendex 0.1.0 → 0.1.1
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.
- data/Rakefile +2 -0
- data/esendex.gemspec +2 -1
- data/lib/esendex.rb +1 -0
- data/lib/esendex/account.rb +7 -3
- data/lib/esendex/version.rb +9 -0
- data/test/test_account.rb +2 -2
- metadata +4 -3
data/Rakefile
CHANGED
@@ -10,6 +10,7 @@ end
|
|
10
10
|
require 'rake'
|
11
11
|
|
12
12
|
require 'jeweler'
|
13
|
+
require './lib/esendex/version'
|
13
14
|
Jeweler::Tasks.new do |gem|
|
14
15
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
16
|
gem.name = "esendex"
|
@@ -19,6 +20,7 @@ Jeweler::Tasks.new do |gem|
|
|
19
20
|
gem.description = ""
|
20
21
|
gem.email = "support@esendex.com"
|
21
22
|
gem.authors = ["Adam Bird"]
|
23
|
+
gem.version = Esendex::Version::STRING
|
22
24
|
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
25
|
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
26
|
gem.add_dependency 'nokogiri', '>=1.4.4'
|
data/esendex.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{esendex}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Adam Bird"]
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
"lib/esendex/exceptions.rb",
|
31
31
|
"lib/esendex/message.rb",
|
32
32
|
"lib/esendex/message_batch_submission.rb",
|
33
|
+
"lib/esendex/version.rb",
|
33
34
|
"test/helper.rb",
|
34
35
|
"test/integration/test_account.rb",
|
35
36
|
"test/test_account.rb",
|
data/lib/esendex.rb
CHANGED
data/lib/esendex/account.rb
CHANGED
@@ -6,7 +6,7 @@ module Esendex
|
|
6
6
|
attr_accessor :account_reference, :username, :password
|
7
7
|
attr_reader :messages_remaining
|
8
8
|
|
9
|
-
def initialize(account_reference, username, password, connection = Nestful::Connection.new('
|
9
|
+
def initialize(account_reference, username, password, connection = Nestful::Connection.new('http://api.esendex.com'))
|
10
10
|
@account_reference = account_reference
|
11
11
|
@username = username
|
12
12
|
@password = password
|
@@ -17,7 +17,7 @@ module Esendex
|
|
17
17
|
@connection.auth_type = :basic
|
18
18
|
|
19
19
|
begin
|
20
|
-
response = @connection.get "/v0.1/accounts/#{@account_reference}"
|
20
|
+
response = @connection.get "/v0.1/accounts/#{@account_reference}", default_headers
|
21
21
|
doc = Nokogiri::XML(response.body)
|
22
22
|
@messages_remaining = doc.at_xpath('//api:accounts/api:account/api:messagesremaining', 'api' => Esendex::API_NAMESPACE).content.to_i
|
23
23
|
rescue Exception => exception
|
@@ -25,6 +25,10 @@ module Esendex
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
def default_headers
|
29
|
+
{"User-Agent" => "Esendex Gem #{Esendex::Version::STRING}"}
|
30
|
+
end
|
31
|
+
|
28
32
|
def send_message(message)
|
29
33
|
self.send_messages([message])
|
30
34
|
end
|
@@ -34,7 +38,7 @@ module Esendex
|
|
34
38
|
batch_submission = MessageBatchSubmission.new(@account_reference, messages)
|
35
39
|
|
36
40
|
begin
|
37
|
-
response = @connection.post "/v1.0/messagedispatcher", batch_submission.to_s
|
41
|
+
response = @connection.post "/v1.0/messagedispatcher", batch_submission.to_s, default_headers
|
38
42
|
doc = Nokogiri::XML(response.body)
|
39
43
|
doc.at_xpath('//api:messageheaders', 'api' => Esendex::API_NAMESPACE)['batchid']
|
40
44
|
rescue Exception => exception
|
data/test/test_account.rb
CHANGED
@@ -20,7 +20,7 @@ class TestAccount < Test::Unit::TestCase
|
|
20
20
|
account_initialisation_response = mock()
|
21
21
|
account_initialisation_response.expects(:body).returns("<?xml version=\"1.0\" encoding=\"utf-8\"?><accounts xmlns=\"http://api.esendex.com/ns/\"><account id=\"2b4a326c-41de-4a57-a577-c7d742dc145c\" uri=\"http://api.esendex.com/v1.0/accounts/2b4a326c-41de-4a57-a577-c7d742dc145c\"><balanceremaining domesticmessages=\"100\" internationalmessages=\"100\">$0.00</balanceremaining><reference>EX0068832</reference><address>447786204254</address><type>Professional</type><messagesremaining>100</messagesremaining><expireson>2015-12-31T00:00:00</expireson><role>PowerUser</role><defaultdialcode>44</defaultdialcode><settings uri=\"http://api.esendex.com/v1.0/accounts/2b4a326c-41de-4a57-a577-c7d742dc145c/settings\" /></account></accounts>")
|
22
22
|
|
23
|
-
connection.expects(:get).with("/v0.1/accounts/#{@account_reference}").returns(account_initialisation_response)
|
23
|
+
connection.expects(:get).with("/v0.1/accounts/#{@account_reference}", anything).returns(account_initialisation_response)
|
24
24
|
connection
|
25
25
|
end
|
26
26
|
|
@@ -48,7 +48,7 @@ class TestAccount < Test::Unit::TestCase
|
|
48
48
|
|
49
49
|
message_send_response = mock()
|
50
50
|
message_send_response.expects(:body).returns("<?xml version=\"1.0\" encoding=\"utf-8\"?> <messageheaders batchid=\"#{batch_id}\" xmlns=\"http://api.esendex.com/ns/\"> <messageheader\ uri=\"http://api.esendex.com/v1.0/MessageHeaders/00000000-0000-0000-0000-000000000000\" id=\"00000000-0000-0000-0000-000000000000\" /></messageheaders>")
|
51
|
-
connection.expects(:post).with("/v1.0/messagedispatcher", anything).returns(message_send_response)
|
51
|
+
connection.expects(:post).with("/v1.0/messagedispatcher", anything, anything).returns(message_send_response)
|
52
52
|
|
53
53
|
code_challenge_account = Account.new(@account_reference, @user, @password, connection)
|
54
54
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esendex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Adam Bird
|
@@ -209,6 +209,7 @@ files:
|
|
209
209
|
- lib/esendex/exceptions.rb
|
210
210
|
- lib/esendex/message.rb
|
211
211
|
- lib/esendex/message_batch_submission.rb
|
212
|
+
- lib/esendex/version.rb
|
212
213
|
- test/helper.rb
|
213
214
|
- test/integration/test_account.rb
|
214
215
|
- test/test_account.rb
|