Class: Messagemedia::SOAP::Message
- Inherits:
-
Object
- Object
- Messagemedia::SOAP::Message
- Defined in:
- lib/messagemedia/soap/message.rb
Overview
This class is a light-weight wrapper around the message structure used by the MessageMedia SOAP Client interface.
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#delivery_report ⇒ Object
Returns the value of attribute delivery_report.
-
#format ⇒ Object
Returns the value of attribute format.
-
#origin ⇒ Object
Returns the value of attribute origin.
-
#recipients ⇒ Object
Returns the value of attribute recipients.
-
#sequence_number ⇒ Object
Returns the value of attribute sequence_number.
-
#validity_period ⇒ Object
Returns the value of attribute validity_period.
Instance Method Summary collapse
-
#add_recipient(message_id, recipient) ⇒ Object
Add a recipient.
-
#initialize ⇒ Message
constructor
Initialize an empty Message object.
-
#to_api_hash ⇒ Object
Return a hash that can be passed to the Savon SOAP library to represent a message.
Constructor Details
#initialize ⇒ Message
Initialize an empty Message object
By default, delivery reports will be enabled, the validity period will be set to 10 minutes, and the message will be sent as an SMS.
22 23 24 25 26 27 28 |
# File 'lib/messagemedia/soap/message.rb', line 22 def initialize @recipients = [] @delivery_report = true @validity_period = 1 @sequence_number = 0 @format = FORMAT_SMS end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
12 13 14 |
# File 'lib/messagemedia/soap/message.rb', line 12 def content @content end |
#delivery_report ⇒ Object
Returns the value of attribute delivery_report.
12 13 14 |
# File 'lib/messagemedia/soap/message.rb', line 12 def delivery_report @delivery_report end |
#format ⇒ Object
Returns the value of attribute format.
12 13 14 |
# File 'lib/messagemedia/soap/message.rb', line 12 def format @format end |
#origin ⇒ Object
Returns the value of attribute origin.
12 13 14 |
# File 'lib/messagemedia/soap/message.rb', line 12 def origin @origin end |
#recipients ⇒ Object
Returns the value of attribute recipients.
12 13 14 |
# File 'lib/messagemedia/soap/message.rb', line 12 def recipients @recipients end |
#sequence_number ⇒ Object
Returns the value of attribute sequence_number.
12 13 14 |
# File 'lib/messagemedia/soap/message.rb', line 12 def sequence_number @sequence_number end |
#validity_period ⇒ Object
Returns the value of attribute validity_period.
12 13 14 |
# File 'lib/messagemedia/soap/message.rb', line 12 def validity_period @validity_period end |
Instance Method Details
#add_recipient(message_id, recipient) ⇒ Object
Add a recipient.
An optional message ID (message_id) may be provided. This allows for the correlation of replies and delivery reports with messages that have been sent.
A recipient number (recipient) must be provided.
39 40 41 |
# File 'lib/messagemedia/soap/message.rb', line 39 def add_recipient(, recipient) @recipients.push(Recipient.new(, recipient)) end |
#to_api_hash ⇒ Object
Return a hash that can be passed to the Savon SOAP library to represent a message.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/messagemedia/soap/message.rb', line 47 def to_api_hash hash = { :'api:content' => @content, :'api:recipients' => { :'api:recipient' => @recipients.map { |r| r.destination_number }, :attributes! => { :'api:recipient' => { :uid => @recipients.map { |r| r. } } } } } unless @format.nil? hash[:'@format'] = @format end unless @sequence_number.nil? hash[:'@sequenceNumber'] = @sequence_number end unless @delivery_report.nil? hash[:'api:deliveryReport'] = @delivery_report end unless @validity_period.nil? hash[:'api:validityPeriod'] = @validity_period end unless @origin.nil? hash[:'api:origin'] = @origin end hash end |