Module: TreatanyoneCommonApi::Publisher
- Defined in:
- lib/treatanyone_common_api/publisher.rb
Class Attribute Summary collapse
-
.event_object ⇒ Object
Returns the value of attribute event_object.
-
.topic_arn ⇒ Object
Returns the value of attribute topic_arn.
Class Method Summary collapse
- .created(message, message_group_id = nil) ⇒ Object
- .deleted(message, message_group_id = nil) ⇒ Object
-
.publish(event_type, message, message_group_id = nil) ⇒ Object
Note: message_group_id is used for FIFO SNS Topics only.
- .updated(message, message_group_id = nil) ⇒ Object
Class Attribute Details
.event_object ⇒ Object
Returns the value of attribute event_object.
8 9 10 |
# File 'lib/treatanyone_common_api/publisher.rb', line 8 def event_object @event_object end |
.topic_arn ⇒ Object
Returns the value of attribute topic_arn.
8 9 10 |
# File 'lib/treatanyone_common_api/publisher.rb', line 8 def topic_arn @topic_arn end |
Class Method Details
.created(message, message_group_id = nil) ⇒ Object
25 26 27 |
# File 'lib/treatanyone_common_api/publisher.rb', line 25 def created(, = nil) publish('created', , ) end |
.deleted(message, message_group_id = nil) ⇒ Object
33 34 35 |
# File 'lib/treatanyone_common_api/publisher.rb', line 33 def deleted(, = nil) publish('deleted', , ) end |
.publish(event_type, message, message_group_id = nil) ⇒ Object
Note: message_group_id is used for FIFO SNS Topics only
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/treatanyone_common_api/publisher.rb', line 11 def publish(event_type, , = nil) params = { topic_arn: topic_arn, message: JSON.generate(), message_attributes: { event_object: { data_type: 'String', string_value: event_object }, event_type: { data_type: 'String', string_value: event_type } } } params.merge!(message_group_id: ) if .present? sns.publish(**params) end |
.updated(message, message_group_id = nil) ⇒ Object
29 30 31 |
# File 'lib/treatanyone_common_api/publisher.rb', line 29 def updated(, = nil) publish('updated', , ) end |