esendex 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/esendex/account.rb +1 -1
- data/lib/esendex/version.rb +1 -1
- data/readme.md +5 -4
- data/spec/account_spec.rb +12 -1
- metadata +1 -1
data/lib/esendex/account.rb
CHANGED
@@ -16,7 +16,7 @@ module Esendex
|
|
16
16
|
def messages_remaining
|
17
17
|
response = api_connection.get "/v1.0/accounts/#{@reference}"
|
18
18
|
doc = Nokogiri::XML(response.body)
|
19
|
-
doc.at_xpath(
|
19
|
+
(doc.at_xpath("//accounts/account/reference[contains(.,'#{@reference}')]").parent > "messagesremaining").first.content.to_i
|
20
20
|
end
|
21
21
|
|
22
22
|
def send_message(args={})
|
data/lib/esendex/version.rb
CHANGED
data/readme.md
CHANGED
@@ -33,15 +33,16 @@ 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
37
|
|
37
38
|
```ruby
|
38
|
-
account = Account.new
|
39
|
+
account = Account.new
|
40
|
+
batch_id = account.send_message( to: "07777111222", body: "Saying hello to the world with the help of Esendex")
|
39
41
|
```
|
40
|
-
|
41
|
-
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.
|
42
|
+
You can specify a different account to the default by passing the reference in as an initialization argument
|
42
43
|
|
43
44
|
```ruby
|
44
|
-
|
45
|
+
account = Account.new('EX23847')
|
45
46
|
```
|
46
47
|
|
47
48
|
Multiple messages are sent by passing an array of `Messages` to the send_messages method
|
data/spec/account_spec.rb
CHANGED
@@ -6,7 +6,18 @@ describe Account do
|
|
6
6
|
let(:messages_remaining) { random_integer }
|
7
7
|
let(:account_xml) {
|
8
8
|
"<?xml version=\"1.0\" encoding=\"utf-8\"?>
|
9
|
-
<accounts
|
9
|
+
<accounts>
|
10
|
+
<account id=\"2b4a326c-41de-4a57-a577-c7d742dc145c\" uri=\"http://api.esendex.com/v1.0/accounts/2b4a326c-41de-4a57-a577-c7d742dc145c\">
|
11
|
+
<balanceremaining domesticmessages=\"100\" internationalmessages=\"100\">$0.00</balanceremaining>
|
12
|
+
<reference>#{"not this one"}</reference>
|
13
|
+
<address>447786204254</address>
|
14
|
+
<type>Professional</type>
|
15
|
+
<messagesremaining>#{1234}</messagesremaining>
|
16
|
+
<expireson>2015-12-31T00:00:00</expireson>
|
17
|
+
<role>PowerUser</role>
|
18
|
+
<defaultdialcode>44</defaultdialcode>
|
19
|
+
<settings uri=\"http://api.esendex.com/v1.0/accounts/2b4a326c-41de-4a57-a577-c7d742dc145c/settings\" />
|
20
|
+
</account>
|
10
21
|
<account id=\"2b4a326c-41de-4a57-a577-c7d742dc145c\" uri=\"http://api.esendex.com/v1.0/accounts/2b4a326c-41de-4a57-a577-c7d742dc145c\">
|
11
22
|
<balanceremaining domesticmessages=\"100\" internationalmessages=\"100\">$0.00</balanceremaining>
|
12
23
|
<reference>#{account_reference}</reference>
|