Skip to content

Instantly share code, notes, and snippets.

@kevinkang88
Last active August 29, 2015 14:01
Show Gist options
  • Save kevinkang88/f2ea71934d772d91f6ce to your computer and use it in GitHub Desktop.
Save kevinkang88/f2ea71934d772d91f6ce to your computer and use it in GitHub Desktop.
require 'csv'
require 'twilio-ruby'
#################################################
class Student
attr_reader :name, :phone_number
def initialize(args = {})
@name = args[:name]
@phone_number = args[:phone_number]
end
end
#################################################
class PairGenerator
attr_reader :list
def initialize
file_name = 'data.txt'
@people = Array.new
CSV.foreach(file_name,:headers => true,header_converters: :symbol) do |row|
@people << Student.new(row)
end
end
def pair_up
randomized_people = @people.shuffle
final = Hash.new
i = 0
randomized_people.each_slice(2) do |pair|
final[i = i+1] = pair
end
final
end
end
#################################################
class TextSender
def initialize
@account_sid = 'ACb2d18876409ec23f2409b9d3b5986e98'
@auth_token = 'ab303b1c15f3cafd62494e87c908def2'
@client = Twilio::REST::Client.new @account_sid, @auth_token
self.send_text
end
def send_text
pairgenerator = PairGenerator.new
pair_hsh = pairgenerator.pair_up
pair_hsh.each do |k,v|
@client.account.sms.messages.create(
:from => '+18052887205',
:to => "+#{v.first.phone_number}",
:body => "you are in a pair_group - #{k} with #{v.last.name}")
@client.account.sms.messages.create(
:from => '+18052887205',
:to => "+#{v.last.phone_number}",
:body => "you are in a pair_group - #{k} with #{v.first.name}")
end
end
end
#################################################
text_sender = TextSender.new
name,phone_number
Adam Dziuk,8057944927
Adam Ryssdal, 8057944927
Aki Suzuki, 8057944927
Allison Wong, 8057944927
Andra Lally, 8057944927
Anup Pradhan, 8057944927
CJ Jameson, 8057944927
Christiane Kammerl, 8057944927
Christopher Aubuchon, 8057944927
Clark Hinchcliff, 8057944927
Devin A Johnson, 8057944927
Dominick Oddo, 8057944927
Dong Kevin Kang, 8057944927
Eiko Seino, 8057944927
Eoin McMillan, 8057944927
Hunter T. Chapman, 8057944927
Jacob Persing, 8057944927
Jon Pabico, 8057944927
Joshua Rosaaen, 8057944927
Nadia Koroleva, 8057944927
Parjam Davoody, 8057944927
Renee Schaaf, 8057944927
Samuel Davis, 8057944927
Sebastian Belmar, 8057944927
Shawn Seibert, 8057944927
William Butler Bushyhead,8057944927
Yuzu Sajio,8057944927
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment