Created
August 11, 2017 08:33
-
-
Save asvetly/f48f47c5ba69157e547664a97d3488b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ReportSender | |
def initialize(report, account) | |
@report = report | |
@account = account | |
end | |
def send_report(way_of_sending = :email) | |
case way_of_sending | |
when :email | |
Mailer.deliver( | |
from: 'foo@bar.com', | |
to: @account.email, | |
subject: 'Report', | |
body: @report | |
) | |
when :sms | |
client = Twilio::REST::Client.new('ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', @account.auth_token) | |
client.account.messages.create( | |
from: '+66613371337', | |
to: @account.phone, | |
body: @report | |
) | |
else | |
raise raise NotImplementedError | |
end | |
end | |
end | |
class ReportGenerator | |
# report generation | |
end | |
report = ReportGenerator.new(data).generate | |
ReportSender.new(report, account).send_report(:sms) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment