Module: Smslist::Client::Sms
- Included in:
- Smslist::Client
- Defined in:
- lib/smslist/client/sms.rb
Instance Method Summary collapse
-
#send_sms(text, recipients = [], options = {}) ⇒ Hash
Send sms message for a list of recipients.
Instance Method Details
#send_sms(text, recipients = [], options = {}) ⇒ Hash
Send sms message for a list of recipients
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/smslist/client/sms.rb', line 15 def send_sms(text, recipients = [], = {}) unless sms_sender = sender raise Smslist::NoSenderError.new('You must set a sender') end body = build_xml_body do |xml| xml.(type:"#{ 'flash' if options[:flash] }sms") { xml.sender sms_sender xml.text_ text.encode(xml: :text) recipients.each_with_index do |recipient, index| xml.abonent phone: recipient, number_sms: index + 1 end } end response = parse_xml(post body.to_xml) parse_send_sms_response(response, recipients) end |