Class: JPushApiRubyClient::Client
- Inherits:
-
Object
- Object
- JPushApiRubyClient::Client
- Includes:
- MsgType, PlatformType, ReceiverType
- Defined in:
- lib/jpush_api_ruby_client/client.rb
Constant Summary
Constants included from PlatformType
PlatformType::ANDROID, PlatformType::BOTH, PlatformType::IOS
Constants included from MsgType
MsgType::MESSAGE, MsgType::NOTIFICATION
Constants included from ReceiverType
ReceiverType::ALIAS, ReceiverType::BROADCAST, ReceiverType::IMEI, ReceiverType::TAG
Instance Attribute Summary collapse
-
#app_key ⇒ Object
Returns the value of attribute app_key.
-
#https ⇒ Object
Returns the value of attribute https.
-
#master_secret ⇒ Object
Returns the value of attribute master_secret.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#time_to_live ⇒ Object
Returns the value of attribute time_to_live.
Instance Method Summary collapse
-
#enable_ssl(https = false) ⇒ Object
-
是否启用https ssl连接,缺省false * @param [Object] true or false.
-
-
#generate_send_no ⇒ Object
-
当前时间戳生成send_no * @return [Integer].
-
-
#initialize(app_key, master_secret, opts = {}, &block) ⇒ Client
constructor
-
@param [String] app_key * @param [String] master_secret * @param [Hash] opts opts可选参数可包含time_to_live、platform.
-
-
#send_message_with_alias(send_no, alias_, msg_title, msg_content, opts = {}) ⇒ Object
-
发送带别名推送的自定义消息 * @param [Integer] send_no * @param [String] alias_ * @param [String] msg_title * @param [String] msg_content * @param [Hash] opts opts参数可包含 extras、override_msg_id * @return [Hash] sendno、msg_id、errcode、errmsg.
-
-
#send_message_with_appkey(send_no, msg_title, msg_content, opts = {}) ⇒ Object
-
发送使用 appkey 推送的自定义消息 * @param [Integer] send_no * @param [String] msg_title * @param [String] msg_content * @param [Hash] opts opts可选参数包含 extras、override_msg_id * @return [Hash] sendno、msg_id、errcode、errmsg.
-
-
#send_message_with_imei(send_no, imei, msg_title, msg_content, opts = {}) ⇒ Object
-
发送带 imei 推送的自定义消息 * @param [Integer] send_no * @param [String] imei * @param [String] msg_title * @param [String] msg_content * @param [Hash] opts opts参数可包含 extras、override_msg_id * @return [Hash] sendno、msg_id、errcode、errmsg.
-
-
#send_message_with_tag(send_no, tag, msg_title, msg_content, opts = {}) ⇒ Object
-
发送标签带推送的自定义消息 * @param [Integer] send_no * @param [String] tag * @param [String] msg_title * @param [String] msg_content * @param [Hash] opts opts参数可包含 extras、override_msg_id * @return [Hash] sendno、msg_id、errcode、errmsg.
-
-
#send_notification_with_alias(send_no, alias_, msg_title, msg_content, opts = {}) ⇒ Object
-
发送带别名推送的通知 * @param [Integer] send_no * @param [String] alias_ * @param [String] msg_title * @param [String] msg_content * @param [Hash] opts opts参数可包含builder_id 、extras、override_msg_id * @return [Hash] sendno、msg_id、errcode、errmsg.
-
-
#send_notification_with_appkey(send_no, msg_title, msg_content, opts = {}) ⇒ Object
-
发送使用 appkey 推送的通知 * @param [Integer] send_no * @param [String] msg_title * @param [String] msg_content * @param [Hash] opts opts参数可包含 builder_id 、extras 、override_msg_id * @return [Hash] sendno、msg_id、errcode、errmsg.
-
-
#send_notification_with_imei(send_no, imei, msg_title, msg_content, opts = {}) ⇒ Object
-
发送带IMEI号推送的通知 * @param [Integer] send_no * @param [String] imei * @param [String] msg_title * @param [String] msg_content * @param [Hash] opts opts参数可包含 builder_id、extras、override_msg_id * @return [Hash] sendno、msg_id、errcode、errmsg.
-
-
#send_notification_with_tag(send_no, tag, msg_title, msg_content, opts = {}) ⇒ Object
-
发送带标签推送的通知 * @param [Integer] send_no * @param [String] tag * @param [String] msg_title * @param [String] msg_content * @param [Hash] opts opts参数可包含 builder_id 、extras、override_msg_id * @return [Hash] sendno、msg_id、errcode、errmsg.
-
Constructor Details
#initialize(app_key, master_secret, opts = {}, &block) ⇒ Client
-
@param [String] app_key
* @param [String] master_secret * @param [Hash] opts opts可选参数可包含time_to_live、platform
20 21 22 23 24 25 |
# File 'lib/jpush_api_ruby_client/client.rb', line 20 def initialize(app_key, master_secret, opts ={}, &block) @app_key = app_key @master_secret = master_secret @time_to_live = opts['time_to_live'] || 86400 @platform = opts['platform'] || PlatformType::BOTH end |
Instance Attribute Details
#app_key ⇒ Object
Returns the value of attribute app_key.
13 14 15 |
# File 'lib/jpush_api_ruby_client/client.rb', line 13 def app_key @app_key end |
#https ⇒ Object
Returns the value of attribute https.
13 14 15 |
# File 'lib/jpush_api_ruby_client/client.rb', line 13 def https @https end |
#master_secret ⇒ Object
Returns the value of attribute master_secret.
13 14 15 |
# File 'lib/jpush_api_ruby_client/client.rb', line 13 def master_secret @master_secret end |
#platform ⇒ Object
Returns the value of attribute platform.
13 14 15 |
# File 'lib/jpush_api_ruby_client/client.rb', line 13 def platform @platform end |
#time_to_live ⇒ Object
Returns the value of attribute time_to_live.
13 14 15 |
# File 'lib/jpush_api_ruby_client/client.rb', line 13 def time_to_live @time_to_live end |
Instance Method Details
#enable_ssl(https = false) ⇒ Object
-
是否启用https ssl连接,缺省false
* @param [Object] true or false
39 40 41 |
# File 'lib/jpush_api_ruby_client/client.rb', line 39 def enable_ssl(https = false) @https = https end |
#generate_send_no ⇒ Object
-
当前时间戳生成send_no
* @return [Integer]
31 32 33 |
# File 'lib/jpush_api_ruby_client/client.rb', line 31 def generate_send_no Integer(Time.new) end |
#send_message_with_alias(send_no, alias_, msg_title, msg_content, opts = {}) ⇒ Object
-
发送带别名推送的自定义消息
* @param [Integer] send_no * @param [String] alias_ * @param [String] msg_title * @param [String] msg_content * @param [Hash] opts opts参数可包含 extras、override_msg_id * @return [Hash] sendno、msg_id、errcode、errmsg
80 81 82 83 84 |
# File 'lib/jpush_api_ruby_client/client.rb', line 80 def (send_no, alias_, msg_title, msg_content, opts = {}) receiver = {:receiver_type => ReceiverType::ALIAS, :receiver_value => alias_} (send_no, msg_title, msg_content, receiver, opts) end |
#send_message_with_appkey(send_no, msg_title, msg_content, opts = {}) ⇒ Object
-
发送使用 appkey 推送的自定义消息
* @param [Integer] send_no * @param [String] msg_title * @param [String] msg_content * @param [Hash] opts opts可选参数包含 extras、override_msg_id * @return [Hash] sendno、msg_id、errcode、errmsg
51 52 53 54 |
# File 'lib/jpush_api_ruby_client/client.rb', line 51 def (send_no, msg_title, msg_content, opts = {}) receiver = {:receiver_type => ReceiverType::BROADCAST} (send_no, msg_title, msg_content, receiver, opts) end |
#send_message_with_imei(send_no, imei, msg_title, msg_content, opts = {}) ⇒ Object
-
发送带 imei 推送的自定义消息
* @param [Integer] send_no * @param [String] imei * @param [String] msg_title * @param [String] msg_content * @param [Hash] opts opts参数可包含 extras、override_msg_id * @return [Hash] sendno、msg_id、errcode、errmsg
95 96 97 98 99 |
# File 'lib/jpush_api_ruby_client/client.rb', line 95 def (send_no, imei, msg_title, msg_content, opts = {}) receiver = {:receiver_type => ReceiverType::IMEI, :receiver_value => imei} (send_no, msg_title, msg_content, receiver, opts) end |
#send_message_with_tag(send_no, tag, msg_title, msg_content, opts = {}) ⇒ Object
-
发送标签带推送的自定义消息
* @param [Integer] send_no * @param [String] tag * @param [String] msg_title * @param [String] msg_content * @param [Hash] opts opts参数可包含 extras、override_msg_id * @return [Hash] sendno、msg_id、errcode、errmsg
65 66 67 68 69 |
# File 'lib/jpush_api_ruby_client/client.rb', line 65 def (send_no, tag, msg_title, msg_content, opts = {}) receiver = {:receiver_type => ReceiverType::TAG, :receiver_value => tag} (send_no, msg_title, msg_content, receiver, opts) end |
#send_notification_with_alias(send_no, alias_, msg_title, msg_content, opts = {}) ⇒ Object
-
发送带别名推送的通知
* @param [Integer] send_no * @param [String] alias_ * @param [String] msg_title * @param [String] msg_content * @param [Hash] opts opts参数可包含builder_id 、extras、override_msg_id * @return [Hash] sendno、msg_id、errcode、errmsg
139 140 141 142 143 |
# File 'lib/jpush_api_ruby_client/client.rb', line 139 def send_notification_with_alias(send_no, alias_, msg_title, msg_content, opts = {}) receiver = {:receiver_type => ReceiverType::ALIAS, :receiver_value => alias_} send_notification(send_no, msg_title, msg_content, receiver, opts) end |
#send_notification_with_appkey(send_no, msg_title, msg_content, opts = {}) ⇒ Object
-
发送使用 appkey 推送的通知
* @param [Integer] send_no * @param [String] msg_title * @param [String] msg_content * @param [Hash] opts opts参数可包含 builder_id 、extras 、override_msg_id * @return [Hash] sendno、msg_id、errcode、errmsg
109 110 111 112 113 |
# File 'lib/jpush_api_ruby_client/client.rb', line 109 def send_notification_with_appkey(send_no, msg_title, msg_content, opts = {}) receiver = {:receiver_type => ReceiverType::BROADCAST, :receiver_value => ''} send_notification(send_no, msg_title, msg_content, receiver, opts) end |
#send_notification_with_imei(send_no, imei, msg_title, msg_content, opts = {}) ⇒ Object
-
发送带IMEI号推送的通知
* @param [Integer] send_no * @param [String] imei * @param [String] msg_title * @param [String] msg_content * @param [Hash] opts opts参数可包含 builder_id、extras、override_msg_id * @return [Hash] sendno、msg_id、errcode、errmsg
154 155 156 157 158 |
# File 'lib/jpush_api_ruby_client/client.rb', line 154 def send_notification_with_imei(send_no, imei, msg_title, msg_content, opts = {}) receiver = {:receiver_type => ReceiverType::IMEI, :receiver_value => imei} send_notification(send_no, msg_title, msg_content, receiver, opts) end |
#send_notification_with_tag(send_no, tag, msg_title, msg_content, opts = {}) ⇒ Object
-
发送带标签推送的通知
* @param [Integer] send_no * @param [String] tag * @param [String] msg_title * @param [String] msg_content * @param [Hash] opts opts参数可包含 builder_id 、extras、override_msg_id * @return [Hash] sendno、msg_id、errcode、errmsg
124 125 126 127 128 |
# File 'lib/jpush_api_ruby_client/client.rb', line 124 def send_notification_with_tag(send_no, tag, msg_title, msg_content, opts = {}) receiver = {:receiver_type => ReceiverType::TAG, :receiver_value => tag} send_notification(send_no, msg_title, msg_content, receiver, opts) end |