Class: PushToSNS::SendPushNotification
- Inherits:
-
Object
- Object
- PushToSNS::SendPushNotification
- Defined in:
- lib/push_to_sns/send_push_notification.rb
Instance Method Summary collapse
-
#initialize(device, configuration = PushToSNS.configuration) ⇒ SendPushNotification
constructor
A new instance of SendPushNotification.
- #perform(payload) ⇒ Object
Constructor Details
#initialize(device, configuration = PushToSNS.configuration) ⇒ SendPushNotification
Returns a new instance of SendPushNotification.
3 4 5 6 |
# File 'lib/push_to_sns/send_push_notification.rb', line 3 def initialize(device, configuration = PushToSNS.configuration) self.device = device self.configuration = configuration end |
Instance Method Details
#perform(payload) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/push_to_sns/send_push_notification.rb', line 8 def perform(payload) ensure_endpoint_arn_is_enabled notification = build_push_notification(payload) response = AWS.sns.client.publish( message_structure: "json", message: notification..to_json, target_arn: configuration.apply(:read_endpoint_arn, device) ) response[:message_id] rescue AWS::SNS::Errors::EndpointDisabled => _exception perform(payload) end |