Class: Osm::Sms
- Inherits:
-
Object
- Object
- Osm::Sms
- Defined in:
- lib/osm/sms.rb
Defined Under Namespace
Classes: DeliveryReport
Class Method Summary collapse
-
.send_sms(api, section, members, mobile_numbers, source_address, message) ⇒ Hash
Get delivery reports.
Class Method Details
.send_sms(api, section, members, mobile_numbers, source_address, message) ⇒ Hash
Get delivery reports
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/osm/sms.rb', line 13 def self.send_sms(api, section, members, mobile_numbers, source_address, ) raise ArgumentError, 'mobile_numbers must be either :all, :first or a String containing numbers 1-4' unless ([:all, :first, :one].include?(mobile_numbers) || mobile_numbers.match(/[1234]{1,4}/)) Osm::Model.require_access_to_section(api, section) mobile_numbers = :one if mobile_numbers.eql?(:first) data = api.perform_query("sms.php?action=sendText§ionid=#{section.to_i}", { 'msg' => , 'scouts' => [*members].join(','), 'source' => source_address, 'type' => mobile_numbers, 'scheduled' => 'now', }) data.select!{ |k,v| !['debug', 'config'].include?(k) } data = data.map do |k,v| k = 'message' if k.eql?('msg') k = 'sent' if k.eql?('sent_to') [k.to_sym, v] end return Hash[*data.flatten] end |