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.
-
#buttons ⇒ Object
readonly
Returns the value of attribute buttons.
-
#contents ⇒ Object
readonly
Returns the value of attribute contents.
-
#email_body ⇒ Object
readonly
Returns the value of attribute email_body.
-
#email_subject ⇒ Object
readonly
Returns the value of attribute email_subject.
-
#excluded_segments ⇒ Object
readonly
Returns the value of attribute excluded_segments.
-
#external_id ⇒ Object
readonly
Returns the value of attribute external_id.
-
#headings ⇒ Object
readonly
Returns the value of attribute headings.
-
#icons ⇒ Object
readonly
Returns the value of attribute icons.
-
#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.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/onesignal/notification.rb', line 12 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] @email_subject = params[:email_subject] @email_body = params[:email_body] @send_after = params[:send_after].to_s @attachments = params[:attachments] @filters = params[:filters] @sounds = params[:sounds] @buttons = params[:buttons] @icons = params[:icons] @external_id = params[:external_id] 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 |
#buttons ⇒ Object (readonly)
Returns the value of attribute buttons.
8 9 10 |
# File 'lib/onesignal/notification.rb', line 8 def @buttons end |
#contents ⇒ Object (readonly)
Returns the value of attribute contents.
8 9 10 |
# File 'lib/onesignal/notification.rb', line 8 def contents @contents end |
#email_body ⇒ Object (readonly)
Returns the value of attribute email_body.
8 9 10 |
# File 'lib/onesignal/notification.rb', line 8 def email_body @email_body end |
#email_subject ⇒ Object (readonly)
Returns the value of attribute email_subject.
8 9 10 |
# File 'lib/onesignal/notification.rb', line 8 def email_subject @email_subject 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 |
#external_id ⇒ Object (readonly)
Returns the value of attribute external_id.
8 9 10 |
# File 'lib/onesignal/notification.rb', line 8 def external_id @external_id end |
#headings ⇒ Object (readonly)
Returns the value of attribute headings.
8 9 10 |
# File 'lib/onesignal/notification.rb', line 8 def headings @headings end |
#icons ⇒ Object (readonly)
Returns the value of attribute icons.
8 9 10 |
# File 'lib/onesignal/notification.rb', line 8 def icons @icons 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
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/onesignal/notification.rb', line 34 def as_json = {} super() .except('attachments', 'sounds', 'included_targets', 'icons') .merge(@attachments&.as_json() || {}) .merge(@sounds&.as_json() || {}) .merge(@buttons&.as_json() || {}) .merge(@included_targets&.as_json() || {}) .merge(@icons&.as_json() || {}) .select { |_k, v| v.present? } end |