Class: NotificationService::Sms::Silverstreet::Service
- Inherits:
-
Object
- Object
- NotificationService::Sms::Silverstreet::Service
- Includes:
- APIConfig
- Defined in:
- app/services/notification_service/sms/silverstreet/service.rb
Instance Attribute Summary collapse
-
#default_error_message ⇒ Object
readonly
Returns the value of attribute default_error_message.
-
#service_provider ⇒ Object
readonly
Returns the value of attribute service_provider.
Instance Method Summary collapse
- #handle_response(params, res, msg, phones, reservation_id) ⇒ Object
-
#initialize ⇒ Service
constructor
A new instance of Service.
- #make_request(params) ⇒ Object
-
#send_sms(msg, phones, reservation_id) ⇒ Boolean
Sends an SMS message using the Silverstreet service.
-
#sms_sent?(message_id) ⇒ Boolean
Checks if an SMS message has been sent.
Methods included from APIConfig
Constructor Details
#initialize ⇒ Service
Returns a new instance of Service.
7 8 9 10 |
# File 'app/services/notification_service/sms/silverstreet/service.rb', line 7 def initialize @default_error_message = 'Failed to send SMS using Silverstreet' @service_provider = 'silverstreet' end |
Instance Attribute Details
#default_error_message ⇒ Object (readonly)
Returns the value of attribute default_error_message.
5 6 7 |
# File 'app/services/notification_service/sms/silverstreet/service.rb', line 5 def @default_error_message end |
#service_provider ⇒ Object (readonly)
Returns the value of attribute service_provider.
5 6 7 |
# File 'app/services/notification_service/sms/silverstreet/service.rb', line 5 def service_provider @service_provider end |
Instance Method Details
#handle_response(params, res, msg, phones, reservation_id) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'app/services/notification_service/sms/silverstreet/service.rb', line 32 def handle_response(params, res, msg, phones, reservation_id) if sms_not_sent?(res) handle_sms_not_sent(msg, phones, reservation_id, res.body) raise else handle_successful_sms(reservation_id, params, res.body) end end |
#make_request(params) ⇒ Object
25 26 27 28 29 30 |
# File 'app/services/notification_service/sms/silverstreet/service.rb', line 25 def make_request(params) Faraday.post(endpoint, params) rescue StandardError => e handle_error(e) raise end |
#send_sms(msg, phones, reservation_id) ⇒ Boolean
Sends an SMS message using the Silverstreet service.
19 20 21 22 23 |
# File 'app/services/notification_service/sms/silverstreet/service.rb', line 19 def send_sms(msg, phones, reservation_id) params = build_params(msg, phones, reservation_id) res = make_request(params) handle_response(params, res, msg, phones, reservation_id) end |
#sms_sent?(message_id) ⇒ Boolean
Checks if an SMS message has been sent.
45 46 47 48 |
# File 'app/services/notification_service/sms/silverstreet/service.rb', line 45 def sms_sent?() true # TODO: implement this method end |