Method: Clockwork::XML::SMS.build_multiple

Defined in:
lib/clockwork/xml/sms.rb

.build_multiple(collection) ⇒ string

Build the XML data to send multiple SMS messages using the XML API.

Parameters:

Returns:

  • (string)

    XML data



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/clockwork/xml/sms.rb', line 33

def self.build_multiple collection
  builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
    xml.Message {
      if collection.api.api_key
        xml.Key collection.api.api_key
      else
        xml.Username collection.api.username
        xml.Password collection.api.password                
      end
      collection.messages.each do |sms|
        xml.SMS {
          sms.translated_attributes.each do |k, v|
            xml.send "#{k}", v
          end
        }
      end
    }
  end
  builder.to_xml
end