Module: JPush::Device
Instance Method Summary collapse
-
#add_tags(registration_id, tags) ⇒ Object
下面两个方法接受一个参数,其类型为数组或字符串.
- #clear_tags(registration_id) ⇒ Object
- #delete_alias(registration_id) ⇒ Object
- #remove_tags(registration_id, tags) ⇒ Object
-
#show(registration_id) ⇒ Object
GET /v3/devices/registration_id 获取当前设备的所有属性.
-
#status(registration_ids) ⇒ Object
获取用户在线状态 POST /v3/devices/status/.
-
#update(registration_id, tags_add: nil, tags_remove: nil, clear_tags: false, alis: nil, mobile: nil) ⇒ Object
POST /v3/devices/registration_id 更新当前设备的指定属性,当前支持tags, alias,手机号码mobile.
- #update_alias(registration_id, alis) ⇒ Object
- #update_mobile(registration_id, mobile) ⇒ Object
Instance Method Details
#add_tags(registration_id, tags) ⇒ Object
下面两个方法接受一个参数,其类型为数组或字符串
37 38 39 |
# File 'lib/jpush/device.rb', line 37 def (registration_id, ) update(registration_id, tags_add: ) end |
#clear_tags(registration_id) ⇒ Object
45 46 47 |
# File 'lib/jpush/device.rb', line 45 def (registration_id) update(registration_id, clear_tags: true) end |
#delete_alias(registration_id) ⇒ Object
53 54 55 |
# File 'lib/jpush/device.rb', line 53 def delete_alias(registration_id) update(registration_id, alis: '') end |
#remove_tags(registration_id, tags) ⇒ Object
41 42 43 |
# File 'lib/jpush/device.rb', line 41 def (registration_id, ) update(registration_id, tags_remove: ) end |
#show(registration_id) ⇒ Object
GET /v3/devices/registration_id 获取当前设备的所有属性
9 10 11 12 |
# File 'lib/jpush/device.rb', line 9 def show(registration_id) url = base_url + registration_id Http::Client.get(url) end |
#status(registration_ids) ⇒ Object
获取用户在线状态 POST /v3/devices/status/
63 64 65 66 67 68 |
# 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(url, body: body) end |
#update(registration_id, tags_add: nil, tags_remove: nil, clear_tags: false, alis: nil, mobile: nil) ⇒ Object
POST /v3/devices/registration_id 更新当前设备的指定属性,当前支持tags, alias,手机号码mobile
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/jpush/device.rb', line 16 def update(registration_id, tags_add: nil, tags_remove: nil, clear_tags: false, alis: nil, mobile: nil) = if '' else hash = {} hash[:add] = [].flatten unless .nil? hash[:remove] = [].flatten unless .nil? hash.empty? ? nil : hash end body = { tags: , alias: alis, mobile: mobile }.select { |_, value| !value.nil? } url = base_url + registration_id Http::Client.post(url, body: body) end |
#update_alias(registration_id, alis) ⇒ Object
49 50 51 |
# File 'lib/jpush/device.rb', line 49 def update_alias(registration_id, alis) update(registration_id, alis: alis) end |
#update_mobile(registration_id, mobile) ⇒ Object
57 58 59 |
# File 'lib/jpush/device.rb', line 57 def update_mobile(registration_id, mobile) update(registration_id, mobile: mobile) end |