Class: Noticed::DeliveryMethods::TwilioMessaging
Instance Attribute Summary
#config, #event, #notification
Instance Method Summary
collapse
#evaluate_option, #fetch_constant, #perform
Methods included from ApiClient
#post_request
Instance Method Details
#account_sid ⇒ Object
20
21
22
|
# File 'lib/noticed/delivery_methods/twilio_messaging.rb', line 20
def account_sid
evaluate_option(:account_sid) || credentials.fetch(:account_sid)
end
|
#auth_token ⇒ Object
24
25
26
|
# File 'lib/noticed/delivery_methods/twilio_messaging.rb', line 24
def auth_token
evaluate_option(:auth_token) || credentials.fetch(:auth_token)
end
|
#credentials ⇒ Object
32
33
34
|
# File 'lib/noticed/delivery_methods/twilio_messaging.rb', line 32
def credentials
evaluate_option(:credentials) || Rails.application.credentials.twilio
end
|
#deliver ⇒ Object
4
5
6
|
# File 'lib/noticed/delivery_methods/twilio_messaging.rb', line 4
def deliver
post_request url, basic_auth: {user: account_sid, pass: auth_token}, form: json.stringify_keys
end
|
#json ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/noticed/delivery_methods/twilio_messaging.rb', line 8
def json
evaluate_option(:json) || {
From: phone_number,
To: recipient.phone_number,
Body: params.fetch(:message)
}
end
|
#phone_number ⇒ Object
28
29
30
|
# File 'lib/noticed/delivery_methods/twilio_messaging.rb', line 28
def phone_number
evaluate_option(:phone_number) || credentials.fetch(:phone_number)
end
|
#url ⇒ Object
16
17
18
|
# File 'lib/noticed/delivery_methods/twilio_messaging.rb', line 16
def url
evaluate_option(:url) || "https://api.twilio.com/2010-04-01/Accounts/#{account_sid}/Messages.json"
end
|