Module: JPush::Tag
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_devices(tag_value, registration_ids) ⇒ Object
下面两个方法接受一个参数,其类型为数组或字符串.
-
#delete(tag_value, platform = nil) ⇒ Object
DELETE /v3/tags/tag_value 删除一个标签,以及标签与设备之间的关联关系.
-
#has_device?(tag_value, registration_id) ⇒ Boolean
GET /v3/tags/tag_value/registration_ids/registration_id 查询某个设备是否在 tag 下.
-
#list ⇒ Object
GET /v3/tags/ 获取当前应用的所有标签列表。.
- #remove_devices(tag_value, registration_ids) ⇒ Object
-
#update(tag_value, devices_add: nil, devices_remove: nil) ⇒ Object
POST /v3/tags/tag_value 为一个标签添加或者删除设备。.
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_devices(tag_value, registration_ids) ⇒ Object
下面两个方法接受一个参数,其类型为数组或字符串
126 127 128 |
# File 'lib/jpush/device.rb', line 126 def add_devices(tag_value, registration_ids) update(tag_value, devices_add: registration_ids) end |
#delete(tag_value, platform = nil) ⇒ Object
DELETE /v3/tags/tag_value 删除一个标签,以及标签与设备之间的关联关系
136 137 138 139 140 141 |
# File 'lib/jpush/device.rb', line 136 def delete(tag_value, platform = nil) check_tag(tag_value) params = platform.nil? ? nil : { platform: build_platform(platform) } url = base_url + tag_value Http::Client.delete(url, params: params) end |
#has_device?(tag_value, registration_id) ⇒ Boolean
GET /v3/tags/tag_value/registration_ids/registration_id 查询某个设备是否在 tag 下
102 103 104 105 106 107 |
# File 'lib/jpush/device.rb', line 102 def has_device?(tag_value, registration_id) check_registration_id(registration_id) check_tag(tag_value) url = base_url + "#{tag_value}/registration_ids/#{registration_id}" Http::Client.get(url) end |
#list ⇒ Object
GET /v3/tags/ 获取当前应用的所有标签列表。
95 96 97 98 |
# File 'lib/jpush/device.rb', line 95 def list url = base_url Http::Client.get(url) end |
#remove_devices(tag_value, registration_ids) ⇒ Object
130 131 132 |
# File 'lib/jpush/device.rb', line 130 def remove_devices(tag_value, registration_ids) update(tag_value, devices_remove: registration_ids) end |
#update(tag_value, devices_add: nil, devices_remove: nil) ⇒ Object
POST /v3/tags/tag_value 为一个标签添加或者删除设备。
111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/jpush/device.rb', line 111 def update(tag_value, devices_add: nil, devices_remove: nil) check_tag(tag_value) devices_add = build_registration_ids(devices_add) unless devices_add.nil? devices_remove = build_registration_ids(devices_remove) unless devices_remove.nil? registration_ids = { add: devices_add, remove: devices_remove }.compact raise Utils::Exceptions::JPushError, 'Tags update body can not be empty.' if registration_ids.empty? body = { registration_ids: registration_ids } url = base_url + tag_value Http::Client.post(url, body: body) end |