Class: JPush::Push::PushPayload
- Inherits:
-
Object
- Object
- JPush::Push::PushPayload
- Extended by:
- Helper::ArgumentHelper
- Defined in:
- lib/jpush/push/push_payload.rb
Constant Summary collapse
- VALID_OPTION_KEY =
[:sendno, :time_to_live, :override_msg_id, :apns_production, :big_push_duration]
- MAX_SMS_CONTENT_SIZE =
480- MAX_SMS_DELAY_TIME =
24 * 60 * 60 (second)
86400
Constants included from Helper::ArgumentHelper
Helper::ArgumentHelper::MAX_ALIAS_ARRAY_SIZE, Helper::ArgumentHelper::MAX_MSG_IDS_ARRAY_SIZE, Helper::ArgumentHelper::MAX_REGISTRATION_ID_ARRAY_SIZE, Helper::ArgumentHelper::MAX_TAG_ARRAY_MAX_BYTESIZE, Helper::ArgumentHelper::MAX_TAG_ARRAY_SZIE
Constants included from Helper::Argument
Helper::Argument::MAX_ALIAS_BYTESIZE, Helper::Argument::MAX_TAG_BYTESIZE, Helper::Argument::MOBILE_RE
Instance Attribute Summary collapse
-
#audience ⇒ Object
readonly
Returns the value of attribute audience.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#notification ⇒ Object
readonly
Returns the value of attribute notification.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#sms_message ⇒ Object
readonly
Returns the value of attribute sms_message.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(platform:, audience:, notification: nil, message: nil) ⇒ PushPayload
constructor
A new instance of PushPayload.
- #set_message(msg_content, title: nil, content_type: nil, extras: nil) ⇒ Object
- #set_options(opts) ⇒ Object
- #set_sms_message(content, delay_time = 0) ⇒ Object
- #to_hash ⇒ Object
Methods included from Helper::ArgumentHelper
build_alias, build_extras, build_msg_ids, build_registration_ids, build_tags, extended
Methods included from Helper::Argument
#check_alias, #check_mobile, #check_platform, #check_registration_id, #check_tag, #ensure_argument_not_blank, #ensure_argument_required, #ensure_not_over_bytesize, #ensure_not_over_size, #ensure_word_valid
Constructor Details
#initialize(platform:, audience:, notification: nil, message: nil) ⇒ PushPayload
Returns a new instance of PushPayload.
17 18 19 20 21 22 |
# File 'lib/jpush/push/push_payload.rb', line 17 def initialize(platform: , audience: , notification: nil, message: nil) @platform = 'all' == platform ? JPush::Config.settings[:valid_platform] : build_platform(platform) @audience = 'all' == audience ? 'all' : build_audience(audience) @notification = build_notification(notification) unless notification.nil? = () unless .nil? end |
Instance Attribute Details
#audience ⇒ Object (readonly)
Returns the value of attribute audience.
11 12 13 |
# File 'lib/jpush/push/push_payload.rb', line 11 def audience @audience end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
11 12 13 |
# File 'lib/jpush/push/push_payload.rb', line 11 def end |
#notification ⇒ Object (readonly)
Returns the value of attribute notification.
11 12 13 |
# File 'lib/jpush/push/push_payload.rb', line 11 def notification @notification end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/jpush/push/push_payload.rb', line 11 def end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
11 12 13 |
# File 'lib/jpush/push/push_payload.rb', line 11 def platform @platform end |
#sms_message ⇒ Object (readonly)
Returns the value of attribute sms_message.
11 12 13 |
# File 'lib/jpush/push/push_payload.rb', line 11 def end |
Instance Method Details
#build ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/jpush/push/push_payload.rb', line 39 def build raise Utils::Exceptions::MissingArgumentError.new(['audience']) unless @audience err_msg = 'missing notification or message' raise Utils::Exceptions::JPushError, err_msg unless @notification || @push_payload = { platform: @platform, audience: @audience, notification: @notification, message: , sms_message: , options: }.compact self end |
#set_message(msg_content, title: nil, content_type: nil, extras: nil) ⇒ Object
24 25 26 27 |
# File 'lib/jpush/push/push_payload.rb', line 24 def (msg_content, title: nil, content_type: nil, extras: nil) = (msg_content, title, content_type, extras) self end |
#set_options(opts) ⇒ Object
34 35 36 37 |
# File 'lib/jpush/push/push_payload.rb', line 34 def (opts) = (opts) self end |
#set_sms_message(content, delay_time = 0) ⇒ Object
29 30 31 32 |
# File 'lib/jpush/push/push_payload.rb', line 29 def (content, delay_time = 0) = (content, delay_time) self end |
#to_hash ⇒ Object
54 55 56 |
# File 'lib/jpush/push/push_payload.rb', line 54 def to_hash @push_payload end |