Class: OneSignal::Notification
- Inherits:
-
Object
- Object
- OneSignal::Notification
- Defined in:
- lib/onesignal/notification.rb,
lib/onesignal/notification/contents.rb,
lib/onesignal/notification/headings.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#attachments ⇒ Object
readonly
Returns the value of attribute attachments.
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#excluded_segments ⇒ Object
readonly
Returns the value of attribute excluded_segments.
-
#headings ⇒ Object
readonly
Returns the value of attribute headings.
-
#included_segments ⇒ Object
readonly
Returns the value of attribute included_segments.
-
#included_targets ⇒ Object
readonly
Returns the value of attribute included_targets.
-
#send_after ⇒ Object
readonly
Returns the value of attribute send_after.
-
#sounds ⇒ Object
readonly
Returns the value of attribute sounds.
-
#template_id ⇒ Object
readonly
Returns the value of attribute template_id.
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#initialize(**params) ⇒ Notification
constructor
A new instance of Notification.
Constructor Details
#initialize(**params) ⇒ Notification
Returns a new instance of Notification.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/onesignal/notification.rb', line 11 def initialize **params unless params.include?(:contents) || params.include?(:template_id) raise ArgumentError, 'missing contents or template_id' end @contents = params[:contents] @headings = params[:headings] @template_id = params[:template_id] @included_segments = params[:included_segments] @excluded_segments = params[:excluded_segments] @included_targets = params[:included_targets] @send_after = params[:send_after].to_s @attachments = params[:attachments] @filters = params[:filters] @sounds = params[:sounds] end |
Instance Attribute Details
#attachments ⇒ Object (readonly)
Returns the value of attribute attachments.
8 9 10 |
# File 'lib/onesignal/notification.rb', line 8 def @attachments end |
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
8 9 10 |
# File 'lib/onesignal/notification.rb', line 8 def contents @contents end |
#excluded_segments ⇒ Object (readonly)
Returns the value of attribute excluded_segments.
8 9 10 |
# File 'lib/onesignal/notification.rb', line 8 def excluded_segments @excluded_segments end |
#headings ⇒ Object (readonly)
Returns the value of attribute headings.
8 9 10 |
# File 'lib/onesignal/notification.rb', line 8 def headings @headings end |
#included_segments ⇒ Object (readonly)
Returns the value of attribute included_segments.
8 9 10 |
# File 'lib/onesignal/notification.rb', line 8 def included_segments @included_segments end |
#included_targets ⇒ Object (readonly)
Returns the value of attribute included_targets.
8 9 10 |
# File 'lib/onesignal/notification.rb', line 8 def included_targets @included_targets end |
#send_after ⇒ Object (readonly)
Returns the value of attribute send_after.
8 9 10 |
# File 'lib/onesignal/notification.rb', line 8 def send_after @send_after end |
#sounds ⇒ Object (readonly)
Returns the value of attribute sounds.
8 9 10 |
# File 'lib/onesignal/notification.rb', line 8 def sounds @sounds end |
#template_id ⇒ Object (readonly)
Returns the value of attribute template_id.
8 9 10 |
# File 'lib/onesignal/notification.rb', line 8 def template_id @template_id end |
Instance Method Details
#as_json(options = {}) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/onesignal/notification.rb', line 28 def as_json = {} super() .except('attachments', 'sounds', 'included_targets') .merge(@attachments&.as_json() || {}) .merge(@sounds&.as_json() || {}) .merge(@included_targets&.as_json() || {}) .select { |_k, v| v.present? } end |