class JPush::Device
Public Instance Methods
delete_alias(registration_id)
click to toggle source
# File lib/jpush/device.rb, line 53 def delete_alias(registration_id) update(registration_id, alis: '') end
show(registration_id)
click to toggle source
GET /v3/devices/{registration_id} 获取当前设备的所有属性
# File lib/jpush/device.rb, line 9 def show(registration_id) url = base_url + registration_id Http::Client.get(@jpush, url) end
status(registration_ids)
click to toggle source
获取用户在线状态 POST /v3/devices/status/
# File lib/jpush/device.rb, line 63 def status(registration_ids) registration_ids = [registration_ids].flatten url = base_url + 'status' body = { registration_ids: registration_ids } Http::Client.post(@jpush, url, body: body) end
update(registration_id, tags_add: nil, tags_remove: nil, clear_tags: false, alis: nil, mobile: nil)
click to toggle source
POST /v3/devices/{registration_id} 更新当前设备的指定属性,当前支持tags, alias,手机号码mobile
# File lib/jpush/device.rb, line 16 def update(registration_id, tags_add: nil, tags_remove: nil, clear_tags: false, alis: nil, mobile: nil) tags = if clear_tags '' else hash = {} hash[:add] = [tags_add].flatten unless tags_add.nil? hash[:remove] = [tags_remove].flatten unless tags_remove.nil? hash.empty? ? nil : hash end body = { tags: tags, alias: alis, mobile: mobile }.select { |_, value| !value.nil? } url = base_url + registration_id Http::Client.post(@jpush, url, body: body) end
update_alias(registration_id, alis)
click to toggle source
# File lib/jpush/device.rb, line 49 def update_alias(registration_id, alis) update(registration_id, alis: alis) end
update_mobile(registration_id, mobile)
click to toggle source
# File lib/jpush/device.rb, line 57 def update_mobile(registration_id, mobile) update(registration_id, mobile: mobile) end
Private Instance Methods
base_url()
click to toggle source
# File lib/jpush/device.rb, line 72 def base_url 'https://device.jpush.cn/v3/devices/' end