Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace class with method in class << self to modules #3799

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions app/services/court_report_due_sms_reminder_service.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class CourtReportDueSmsReminderService < SmsReminderService
GENERATE_CASE_COURT_REPORT_LINK = "/case_court_reports"
module CourtReportDueSmsReminderService
extend self
include SmsReminderService
include SmsBodyHelper

class << self
include SmsBodyHelper
GENERATE_CASE_COURT_REPORT_LINK = "/case_court_reports"

def court_report_reminder(user, report_due_date)
short_link = create_short_link(GENERATE_CASE_COURT_REPORT_LINK)
message = court_report_due_msg(report_due_date, short_link)
send_reminder(user, message)
end
def court_report_reminder(user, report_due_date)
short_link = create_short_link(GENERATE_CASE_COURT_REPORT_LINK)
message = court_report_due_msg(report_due_date, short_link)
send_reminder(user, message)
end
end
18 changes: 9 additions & 9 deletions app/services/no_contact_made_sms_reminder_service.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class NoContactMadeSmsReminderService < SmsReminderService
NEW_CASE_CONTACT_LINK = "/case_contacts/new"
module NoContactMadeSmsReminderService
extend self
include SmsReminderService
include SmsBodyHelper

class << self
include SmsBodyHelper
NEW_CASE_CONTACT_LINK = "/case_contacts/new"

def no_contact_made_reminder(user, contact_type)
short_link = create_short_link(NEW_CASE_CONTACT_LINK)
message = no_contact_made_msg(contact_type, short_link)
send_reminder(user, message)
end
def no_contact_made_reminder(user, contact_type)
short_link = create_short_link(NEW_CASE_CONTACT_LINK)
message = no_contact_made_msg(contact_type, short_link)
send_reminder(user, message)
end
end
41 changes: 20 additions & 21 deletions app/services/sms_reminder_service.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
class SmsReminderService
module SmsReminderService
extend self

BASE_URL = Rails.application.credentials[:BASE_URL]
def send_reminder(user, message)
return if !user[:receive_sms_notifications] || user[:phone_number].blank?

class << self
def send_reminder(user, message)
return if !user[:receive_sms_notifications] || user[:phone_number].blank?
user_casa_org = user.casa_org
twilio_service = TwilioService.new(user_casa_org.twilio_api_key_sid, user_casa_org.twilio_api_key_secret, user_casa_org.twilio_account_sid)
sms_params = {
From: user_casa_org.twilio_phone_number,
Body: message,
To: user.phone_number
}
twilio_service.send_sms(sms_params)
end

user_casa_org = user.casa_org
twilio_service = TwilioService.new(user_casa_org.twilio_api_key_sid, user_casa_org.twilio_api_key_secret, user_casa_org.twilio_account_sid)
sms_params = {
From: user_casa_org.twilio_phone_number,
Body: message,
To: user.phone_number
}
twilio_service.send_sms(sms_params)
def create_short_link(path)
if BASE_URL.blank?
raise "BASE_URL environment variable not defined"
end

def create_short_link(path)
if BASE_URL.blank?
raise "BASE_URL environment variable not defined"
end

short_url_service = ShortUrlService.new
short_url_service.create_short_url(BASE_URL + path)
short_url_service.short_url
end
short_url_service = ShortUrlService.new
short_url_service.create_short_url(BASE_URL + path)
short_url_service.short_url
end
end