Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class Esendex | ||
module Responses | ||
class Account | ||
extend Serialisable | ||
|
||
root 'account' | ||
|
||
attribute :id, 'id' | ||
attribute :uri, 'uri' | ||
|
||
element :reference, 'reference' | ||
element :label, 'label' | ||
element :address, 'address' | ||
element :type, 'type' | ||
element :messages_remaining, 'messagesremaining', Parser.for(&:to_i) | ||
element :expires_on, 'expireson' | ||
element :role, 'role' | ||
element :settings, Class.new { | ||
extend Serialisable | ||
root 'settings' | ||
attribute :uri, 'uri' | ||
} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Esendex | ||
module Responses | ||
class Accounts | ||
extend Serialisable | ||
|
||
root 'accounts' | ||
elements :accounts, Account | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require_relative '../../helper' | ||
|
||
describe Esendex::Responses::Account do | ||
describe '.deserialise' do | ||
|
||
let(:id) { "A00F0218-510D-423D-A74E-5A65342FE070" } | ||
let(:uri) { "http://api.esendex.com/v1.0/accounts/A00F0218-510D-423D-A74E-5A65342FE070" } | ||
let(:reference) { "EX0000000" } | ||
let(:label) { "label" } | ||
let(:address) { "447700900654" } | ||
let(:type) { "Professional" } | ||
let(:messagesremaining) { 2000 } | ||
let(:expireson) { "2999-02-25T00:00:00" } | ||
let(:role) { "PowerUser" } | ||
let(:settings_uri) { "http://api.esendex.com/v1.0/accounts/A00F0218-510D-423D-A74E-5A65342FE070/settings" } | ||
|
||
let(:xml) { | ||
<<EOS | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<account id="#{id}" uri="#{uri}" xmlns="http://api.esendex.com/ns/"> | ||
<reference>#{reference}</reference> | ||
<label>#{label}</label> | ||
<address>#{address}</address> | ||
<type>#{type}</type> | ||
<messagesremaining>#{messagesremaining}</messagesremaining> | ||
<expireson>#{expireson}</expireson> | ||
<role>#{role}</role> | ||
<settings uri="#{settings_uri}" /> | ||
</account> | ||
EOS | ||
} | ||
|
||
it 'deserialises xml into an Account instance' do | ||
account = Esendex::Responses::Account.deserialise(xml) | ||
|
||
account.id.must_equal id | ||
account.uri.must_equal uri | ||
account.reference.must_equal reference | ||
account.label.must_equal label | ||
account.address.must_equal address | ||
account.type.must_equal type | ||
account.messages_remaining.must_equal messagesremaining | ||
account.expires_on.must_equal expireson | ||
account.role.must_equal role | ||
account.settings.uri.must_equal settings_uri | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
require_relative '../../helper' | ||
|
||
describe Esendex::Responses::Accounts do | ||
describe '.deserialise' do | ||
|
||
let(:id) { "A00F0218-510D-423D-A74E-5A65342FE070" } | ||
let(:uri) { "http://api.esendex.com/v1.0/accounts/A00F0218-510D-423D-A74E-5A65342FE070" } | ||
let(:reference) { "EX0000000" } | ||
let(:label) { "label" } | ||
let(:address) { "447700900654" } | ||
let(:type) { "Professional" } | ||
let(:messagesremaining) { 2000 } | ||
let(:expireson) { "2999-02-25T00:00:00" } | ||
let(:role) { "PowerUser" } | ||
let(:settings_uri) { "http://api.esendex.com/v1.0/accounts/A00F0218-510D-423D-A74E-5A65342FE070/settings" } | ||
|
||
let(:xml) { | ||
<<EOS | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<accounts xmlns="http://api.esendex.com/ns/"> | ||
<account id="#{id}" uri="#{uri}"> | ||
<reference>#{reference}</reference> | ||
<label>#{label}</label> | ||
<address>#{address}</address> | ||
<type>#{type}</type> | ||
<messagesremaining>#{messagesremaining}</messagesremaining> | ||
<expireson>#{expireson}</expireson> | ||
<role>#{role}</role> | ||
<settings uri="#{settings_uri}" /> | ||
</account> | ||
</accounts> | ||
EOS | ||
} | ||
|
||
it 'deserialises xml into an Accounts instance' do | ||
accounts = Esendex::Responses::Accounts.deserialise(xml) | ||
account = accounts.accounts.first | ||
|
||
account.id.must_equal id | ||
account.uri.must_equal uri | ||
account.reference.must_equal reference | ||
account.label.must_equal label | ||
account.address.must_equal address | ||
account.type.must_equal type | ||
account.messages_remaining.must_equal messagesremaining | ||
account.expires_on.must_equal expireson | ||
account.role.must_equal role | ||
account.settings.uri.must_equal settings_uri | ||
end | ||
end | ||
end |