Class: ASPSMS::Request::SendTextSMS

Inherits:
Abstract
  • Object
show all
Defined in:
lib/aspsms.rb

Instance Attribute Summary collapse

Attributes inherited from Abstract

#password, #userkey

Instance Method Summary collapse

Methods inherited from Abstract

#to_s

Constructor Details

#initialize(cfg) ⇒ SendTextSMS

Returns a new instance of SendTextSMS.



190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/aspsms.rb', line 190

def initialize(cfg)
  super(cfg)
  @originator = @cfg.originator
  @recipients = []
  @text = ''
  @flashing = false
  @blinking = false
  @tx_refs = []
  @url_buffered = ''
  @url_delivery = ''
  @url_nondelivery = ''
end

Instance Attribute Details

#blinkingObject

Returns the value of attribute blinking.



188
189
190
# File 'lib/aspsms.rb', line 188

def blinking
  @blinking
end

#flashingObject

Returns the value of attribute flashing.



188
189
190
# File 'lib/aspsms.rb', line 188

def flashing
  @flashing
end

#originatorObject

Returns the value of attribute originator.



188
189
190
# File 'lib/aspsms.rb', line 188

def originator
  @originator
end

#recipientsObject

Returns the value of attribute recipients.



188
189
190
# File 'lib/aspsms.rb', line 188

def recipients
  @recipients
end

#textObject

Returns the value of attribute text.



188
189
190
# File 'lib/aspsms.rb', line 188

def text
  @text
end

#tx_refsObject

Returns the value of attribute tx_refs.



188
189
190
# File 'lib/aspsms.rb', line 188

def tx_refs
  @tx_refs
end

#url_bufferedObject

Returns the value of attribute url_buffered.



188
189
190
# File 'lib/aspsms.rb', line 188

def url_buffered
  @url_buffered
end

#url_deliveryObject

Returns the value of attribute url_delivery.



188
189
190
# File 'lib/aspsms.rb', line 188

def url_delivery
  @url_delivery
end

#url_nondeliveryObject

Returns the value of attribute url_nondelivery.



188
189
190
# File 'lib/aspsms.rb', line 188

def url_nondelivery
  @url_nondelivery
end

Instance Method Details

#each_element {|REXML::Element.new('Originator').add_text(@cfg.utf8(originator))| ... } ⇒ Object

Yields:

  • (REXML::Element.new('Originator').add_text(@cfg.utf8(originator)))


202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/aspsms.rb', line 202

def each_element
  yield REXML::Element.new('Originator').add_text(@cfg.utf8(originator))
  @recipients = [ @recipients ] unless @recipients.kind_of?(Array)
  txr = @tx_refs.dup
  recipients.each do |recipient|
    rcpt = REXML::Element.new('Recipient')
    rcpt.elements.add(Element.new('PhoneNumber').
                      add_text(@cfg.utf8(recipient)))
    rcpt.elements.add(Element.new('TransRefNumber').
                      add_text(txr.shift)) unless txr.empty?
    yield rcpt
  end
  yield REXML::Element.new('MessageData').add_text(@cfg.utf8(text))
  yield REXML::Element.new('UsedCredits').add_text('1')
  yield REXML::Element.new('FlashingSMS').add_text('1') if flashing
  yield REXML::Element.new('BlinkingSMS').add_text('1') if blinking
  yield REXML::Element.new('URLBufferedMessageNotification').
      add_text(@cfg.utf8(url_buffered)) unless url_buffered.empty?
  yield REXML::Element.new('URLDeliveryNotification').
      add_text(@cfg.utf8(url_delivery)) unless url_delivery.empty?
  yield REXML::Element.new('URLNonDeliveryNotification').
      add_text(@cfg.utf8(url_nondelivery)) unless url_nondelivery.empty?
end