Class: UqamGradeNotification::Notifier

Inherits:
Object
  • Object
show all
Defined in:
lib/uqam_grade_notification/notifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Notifier

Returns a new instance of Notifier.



7
8
9
10
11
12
13
# File 'lib/uqam_grade_notification/notifier.rb', line 7

def initialize args
  args = HashWithIndifferentAccess.new(args)
  @phone = args.fetch("phone")
   = args.fetch("twilio_account_id")
  @twilio_token = args.fetch("twilio_token")
  @twilio_phone = args.fetch("twilio_phone")
end

Instance Attribute Details

#phoneObject (readonly)

Returns the value of attribute phone.



5
6
7
# File 'lib/uqam_grade_notification/notifier.rb', line 5

def phone
  @phone
end

Instance Method Details

#sms(message) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/uqam_grade_notification/notifier.rb', line 15

def sms(message)
  client = Twilio::REST::Client.new , @twilio_token

  client..messages.create({
    from: @twilio_phone,
    to: @phone,
    body: message
  })
end