Class: ActivityNotification::OptionalTarget::AmazonSNS
- Defined in:
- lib/activity_notification/optional_targets/amazon_sns.rb
Overview
Optional target implementation for mobile push notification or SMS using Amazon SNS.
Instance Method Summary collapse
-
#initialize_target(options = {}) ⇒ Object
Initialize method to prepare Aws::SNS::Client.
-
#notify(notification, options = {}) ⇒ Object
Publishes notification message to Amazon SNS.
Methods inherited from Base
#initialize, #to_optional_target_name
Constructor Details
This class inherits a constructor from ActivityNotification::OptionalTarget::Base
Instance Method Details
#initialize_target(options = {}) ⇒ Object
Initialize method to prepare Aws::SNS::Client
17 18 19 20 21 22 |
# File 'lib/activity_notification/optional_targets/amazon_sns.rb', line 17 def initialize_target( = {}) @topic_arn = .delete(:topic_arn) @target_arn = .delete(:target_arn) @phone_number = .delete(:phone_number) @sns_client = Aws::SNS::Client.new() end |
#notify(notification, options = {}) ⇒ Object
Publishes notification message to Amazon SNS
36 37 38 39 40 41 42 43 |
# File 'lib/activity_notification/optional_targets/amazon_sns.rb', line 36 def notify(notification, = {}) @sns_client.publish( topic_arn: notification.target.resolve_value(.delete(:topic_arn) || @topic_arn), target_arn: notification.target.resolve_value(.delete(:target_arn) || @target_arn), phone_number: notification.target.resolve_value(.delete(:phone_number) || @phone_number), message: (notification, ) ) end |