Class: MerlinGateway::SmsMessage
- Inherits:
-
Object
- Object
- MerlinGateway::SmsMessage
- Defined in:
- lib/merlin_gateway/sms_message.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#message ⇒ Object
Returns the value of attribute message.
-
#price ⇒ Object
Returns the value of attribute price.
-
#target_number ⇒ Object
Returns the value of attribute target_number.
Instance Method Summary collapse
- #deliver! ⇒ Object
-
#initialize(target_number, message, options = {}) ⇒ SmsMessage
constructor
A new instance of SmsMessage.
- #to_xml ⇒ Object
Constructor Details
#initialize(target_number, message, options = {}) ⇒ SmsMessage
Returns a new instance of SmsMessage.
7 8 9 10 11 12 |
# File 'lib/merlin_gateway/sms_message.rb', line 7 def initialize(target_number, , ={}) @target_number = target_number = @client = [:client] @price = [:price] || 0 end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/merlin_gateway/sms_message.rb', line 5 def client @client end |
#message ⇒ Object
Returns the value of attribute message.
4 5 6 |
# File 'lib/merlin_gateway/sms_message.rb', line 4 def end |
#price ⇒ Object
Returns the value of attribute price.
4 5 6 |
# File 'lib/merlin_gateway/sms_message.rb', line 4 def price @price end |
#target_number ⇒ Object
Returns the value of attribute target_number.
4 5 6 |
# File 'lib/merlin_gateway/sms_message.rb', line 4 def target_number @target_number end |
Instance Method Details
#deliver! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/merlin_gateway/sms_message.rb', line 14 def deliver! xml_data = self.to_xml response = Typhoeus::Request.post( 'http://www.mobile-entry.com/gate/service', #:method => :post, :headers => {'Content-type' => 'text/xml'}, :username => client.username, :password => client.password, :body => xml_data ) end |
#to_xml ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/merlin_gateway/sms_message.rb', line 26 def to_xml builder = Builder::XmlMarkup.new#(:indent=>2) builder.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8" xml_data = builder.gate do |gate| gate.country client.country gate.accessNumber client.access_number gate.senderNumber client.sender_number gate.targetNumber target_number gate.price price gate.sms do |sms| sms.content do |content| content.cdata! end end end end |