Class: JPush::Push::PushPayload
- Inherits:
-
Object
- Object
- JPush::Push::PushPayload
- Defined in:
- lib/jpush/push/push_payload.rb
Instance Attribute Summary collapse
-
#cid ⇒ Object
readonly
Returns the value of attribute cid.
Instance Method Summary collapse
-
#initialize(platform:, audience:, notification: nil, message: nil) ⇒ PushPayload
constructor
A new instance of PushPayload.
- #set_cid(cid) ⇒ Object
- #set_message(msg_content, title: nil, content_type: nil, extras: nil) ⇒ Object
- #set_options(options) ⇒ Object
- #set_sms_message(sms_message) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(platform:, audience:, notification: nil, message: nil) ⇒ PushPayload
Returns a new instance of PushPayload.
10 11 12 13 14 15 |
# File 'lib/jpush/push/push_payload.rb', line 10 def initialize(platform: , audience: , notification: nil, message: nil) @platform = 'all' == platform ? 'all' : build_platform(platform) @audience = 'all' == audience ? 'all' : build_audience(audience) @notification = build_notification(notification) unless notification.nil? @message = () unless .nil? end |
Instance Attribute Details
#cid ⇒ Object (readonly)
Returns the value of attribute cid.
8 9 10 |
# File 'lib/jpush/push/push_payload.rb', line 8 def cid @cid end |
Instance Method Details
#set_cid(cid) ⇒ Object
32 33 34 35 |
# File 'lib/jpush/push/push_payload.rb', line 32 def set_cid(cid) @cid= cid self end |
#set_message(msg_content, title: nil, content_type: nil, extras: nil) ⇒ Object
17 18 19 20 |
# File 'lib/jpush/push/push_payload.rb', line 17 def (msg_content, title: nil, content_type: nil, extras: nil) @message = (msg_content, title, content_type, extras) self end |
#set_options(options) ⇒ Object
27 28 29 30 |
# File 'lib/jpush/push/push_payload.rb', line 27 def () @options = self end |
#set_sms_message(sms_message) ⇒ Object
22 23 24 25 |
# File 'lib/jpush/push/push_payload.rb', line 22 def () @sms_message = self end |
#to_hash ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/jpush/push/push_payload.rb', line 37 def to_hash @push_payload = { platform: @platform, audience: @audience, notification: @notification, message: @message, sms_message: @sms_message, options: { apns_production: false }.merge(@options.nil? ? {} : @options), cid: @cid }.select { |_, value| !value.nil? } end |