module StupidSMS

Constants

MAX_THREADS
VERSION

Attributes

configuration[RW]

Public Class Methods

configure() { |configuration| ... } click to toggle source
# File lib/stupid_sms.rb, line 47
def self.configure
  self.configuration ||= Configuration.new
  yield(configuration)
end
send_in_bulk(csv_string:, template:, delimiter: ',', dry_run: false, max_threads: MAX_THREADS) click to toggle source
# File lib/stupid_sms.rb, line 17
def self.send_in_bulk(csv_string:, template:, delimiter: ',', dry_run: false, max_threads: MAX_THREADS)
  csv = HoneyFormat::CSV.new(csv_string, delimiter: delimiter)

  sms_queue = Queue.new
  csv.each_row { |person| sms_queue << person }

  summary = ProcessQueue.call(
    sms_queue: sms_queue,
    template: template,
    dry_run: dry_run,
    max_threads: max_threads
  )

  puts '============================'
  puts "Thread count:  #{max_threads}"
  puts "Dry run:       #{dry_run}"
  puts "Longest sms:   #{summary.fetch(:longest_body)}"
  puts "Recipients:    #{summary.fetch(:recipients_count)}"
  puts "Failed count:  #{summary.fetch(:failed_count)}"
  puts "Sent messages: #{summary.fetch(:successfully_sent_count)}"
end

Public Instance Methods

send(crecipient:, body:) click to toggle source
# File lib/stupid_sms.rb, line 39
def send(crecipient:, body:)
  SMS.send(recipient: recipient, body: body)
end