Class: Xiaomi::Push::Services::Messages
- Inherits:
-
Object
- Object
- Xiaomi::Push::Services::Messages
- Defined in:
- lib/xiaomi/push/services/messages.rb
Overview
消息类 API
允许向多个设备发送不同的推送消息
设备的标识支持 reg_id/alias/user_account
Constant Summary collapse
- MESSAGE_TYPE =
消息类型模板
{ reg_id: { uri: 'regids', keys: [:reg_id, :regid, :registration_id] }, alias: { uri: 'aliases', keys: [:alias, :aliass, :aliases] }, user: { uri: 'user_accounts', keys: [:user, :account, :useraccount, :user_account] } }
Instance Attribute Summary collapse
-
#context ⇒ Client
The current value of context.
Instance Method Summary collapse
-
#initialize(context) ⇒ Messages
constructor
A new instance of Messages.
-
#send(type, messages = []) ⇒ Hash
推送消息.
Constructor Details
#initialize(context) ⇒ Messages
Returns a new instance of Messages.
34 35 36 |
# File 'lib/xiaomi/push/services/messages.rb', line 34 def initialize(context) @context = context end |
Instance Attribute Details
#context ⇒ Client
Returns the current value of context.
15 16 17 |
# File 'lib/xiaomi/push/services/messages.rb', line 15 def context @context end |
Instance Method Details
#send(type, messages = []) ⇒ Hash
推送消息
49 50 51 52 53 |
# File 'lib/xiaomi/push/services/messages.rb', line 49 def send(type, = []) url = @context.build_uri("multi_messages/#{request_uri(type)}") params = request_params(type, ) @context.post(url, params) end |