Class: NotificationHub::Channels::Sms::Aws

Inherits:
Base
  • Object
show all
Defined in:
lib/notification_hub/channels/sms/aws.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Aws

Returns a new instance of Aws.



9
10
11
# File 'lib/notification_hub/channels/sms/aws.rb', line 9

def initialize(configuration)
	super
end

Class Method Details

.send_message(event_code, data, options) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/notification_hub/channels/sms/aws.rb', line 14

def send_message(event_code, data, options)						
	event = event_code.split(".")

	begin 
		string = ActionController::Base.new.
				render_to_string("#{gateway_options[:template_path]}/#{event[0]}/#{event[1]}", locals: data)

		sns_client = ::Aws::SNS::Client.new
  			sns_client.publish(phone_number: options[:phone_number].gsub(/[^0-9]+/, ''), 
  				message: string)      			
 			rescue => exception
	  raise "Sms::Aws Error: #{exception.message}"
	end
end