Module: JPush::Device
Constant Summary
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 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
Methods included from Helper::ArgumentHelper
build_alias, build_extras, build_msg_ids, build_platform, 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
Instance Method Details
#add_tags(registration_id, tags) ⇒ Object
下面两个方法接受一个参数,其类型为数组或字符串
46 47 48 |
# File 'lib/jpush/device.rb', line 46 def (registration_id, ) update(registration_id, tags_add: ) end |
#clear_tags(registration_id) ⇒ Object
54 55 56 |
# File 'lib/jpush/device.rb', line 54 def (registration_id) update(registration_id, clear_tags: true) end |
#delete_alias(registration_id) ⇒ Object
62 63 64 |
# File 'lib/jpush/device.rb', line 62 def delete_alias(registration_id) update(registration_id, alis: '') end |
#remove_tags(registration_id, tags) ⇒ Object
50 51 52 |
# File 'lib/jpush/device.rb', line 50 def (registration_id, ) update(registration_id, tags_remove: ) end |
#show(registration_id) ⇒ Object
GET /v3/devices/registration_id 获取当前设备的所有属性
12 13 14 15 16 |
# File 'lib/jpush/device.rb', line 12 def show(registration_id) check_registration_id(registration_id) url = base_url + registration_id Http::Client.get(url) end |
#status(registration_ids) ⇒ Object
获取用户在线状态 POST /v3/devices/status/
72 73 74 75 76 77 |
# File 'lib/jpush/device.rb', line 72 def status(registration_ids) registration_ids = build_registration_ids(registration_ids) 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
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/jpush/device.rb', line 20 def update(registration_id, tags_add: nil, tags_remove: nil, clear_tags: false, alis: nil, mobile: nil) check_registration_id(registration_id) check_mobile(mobile) unless mobile.nil? check_alias(alis) unless alis.nil? = if '' else = () unless .nil? = () unless .nil? = { add: , remove: }.compact .empty? ? nil : end body = { tags: , alias: alis, mobile: mobile }.compact raise Utils::Exceptions::JPushError, 'Devices update body can not be empty' if body.empty? url = base_url + registration_id Http::Client.post(url, body: body) end |
#update_alias(registration_id, alis) ⇒ Object
58 59 60 |
# File 'lib/jpush/device.rb', line 58 def update_alias(registration_id, alis) update(registration_id, alis: alis) end |
#update_mobile(registration_id, mobile) ⇒ Object
66 67 68 |
# File 'lib/jpush/device.rb', line 66 def update_mobile(registration_id, mobile) update(registration_id, mobile: mobile) end |