Class: Moromi::Aws::Sns::Message::Apns
- Defined in:
- lib/moromi/aws/sns/message/apns.rb
Instance Attribute Summary collapse
-
#alert ⇒ Object
readonly
Returns the value of attribute alert.
-
#badge ⇒ Object
readonly
Returns the value of attribute badge.
-
#category ⇒ Object
readonly
Returns the value of attribute category.
-
#content_available ⇒ Object
readonly
Returns the value of attribute content_available.
-
#custom_data ⇒ Object
readonly
Returns the value of attribute custom_data.
-
#mutable_content ⇒ Object
readonly
Returns the value of attribute mutable_content.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#sound ⇒ Object
readonly
Returns the value of attribute sound.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(alert:, badge:, sound: 'default', content_available: 1, mutable_content: 0, category: nil, priority: 10, type: nil, custom_data: {}) ⇒ Apns
constructor
A new instance of Apns.
- #to_hash ⇒ Object
- #to_message_json ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(alert:, badge:, sound: 'default', content_available: 1, mutable_content: 0, category: nil, priority: 10, type: nil, custom_data: {}) ⇒ Apns
Returns a new instance of Apns.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/moromi/aws/sns/message/apns.rb', line 16 def initialize(alert:, badge:, sound: 'default', content_available: 1, mutable_content: 0, category: nil, priority: 10, type: nil, custom_data: {}) @alert = alert @badge = badge @sound = sound @content_available = content_available @mutable_content = mutable_content @category = category @priority = priority @type = type || self.class.name @custom_data = setup_initial_custom_data({type: @type}.merge(custom_data)) end |
Instance Attribute Details
#alert ⇒ Object (readonly)
Returns the value of attribute alert.
6 7 8 |
# File 'lib/moromi/aws/sns/message/apns.rb', line 6 def alert @alert end |
#badge ⇒ Object (readonly)
Returns the value of attribute badge.
7 8 9 |
# File 'lib/moromi/aws/sns/message/apns.rb', line 7 def badge @badge end |
#category ⇒ Object (readonly)
Returns the value of attribute category.
11 12 13 |
# File 'lib/moromi/aws/sns/message/apns.rb', line 11 def category @category end |
#content_available ⇒ Object (readonly)
Returns the value of attribute content_available.
9 10 11 |
# File 'lib/moromi/aws/sns/message/apns.rb', line 9 def content_available @content_available end |
#custom_data ⇒ Object (readonly)
Returns the value of attribute custom_data.
14 15 16 |
# File 'lib/moromi/aws/sns/message/apns.rb', line 14 def custom_data @custom_data end |
#mutable_content ⇒ Object (readonly)
Returns the value of attribute mutable_content.
10 11 12 |
# File 'lib/moromi/aws/sns/message/apns.rb', line 10 def mutable_content @mutable_content end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
12 13 14 |
# File 'lib/moromi/aws/sns/message/apns.rb', line 12 def priority @priority end |
#sound ⇒ Object (readonly)
Returns the value of attribute sound.
8 9 10 |
# File 'lib/moromi/aws/sns/message/apns.rb', line 8 def sound @sound end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
13 14 15 |
# File 'lib/moromi/aws/sns/message/apns.rb', line 13 def type @type end |
Class Method Details
.build_silent_push_message(priority: 10, custom_data: {}) ⇒ Object
58 59 60 |
# File 'lib/moromi/aws/sns/message/apns.rb', line 58 def (priority: 10, custom_data: {}) new('', nil, sound: nil, content_available: 1, priority: priority, custom_data: custom_data) end |
Instance Method Details
#to_hash ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/moromi/aws/sns/message/apns.rb', line 29 def to_hash { alert: @alert, badge: @badge, sound: @sound, content_available: @content_available, mutable_content: @mutable_content, category: @category, priority: @priority, type: @type, custom_data: @custom_data } end |
#to_message_json ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/moromi/aws/sns/message/apns.rb', line 43 def aps = to_hash %i[custom_data type content_available mutable_content].each { |k| aps.delete(k) } aps['content-available'] = @content_available aps['mutable-content'] = @mutable_content @custom_data.merge({aps: aps}).to_json end |