Class: Wechat::ShakeAround::Group
- Inherits:
-
Object
- Object
- Wechat::ShakeAround::Group
- Extended by:
- Core::Common, Common
- Defined in:
- lib/wechat/shake_around/group.rb
Overview
Group 是 管理 iBeacon 设备分组的封装类。
Constant Summary
Constants included from Common
Class Method Summary collapse
- .create(access_token, name) ⇒ Object
- .destroy(access_token, group_id) ⇒ Object
- .index(access_token, offset: 0, limit: 1000) ⇒ Object
- .load(access_token, group_id, offset: 0, limit: 1000) ⇒ Object
- .update(access_token, group_id, name) ⇒ Object
Methods included from Common
normalize_date, normalize_device_id, normalize_page_ids
Class Method Details
.create(access_token, name) ⇒ Object
新增分组 mp.weixin.qq.com/wiki/10/9f6b498b6aa0eb5ef6b9ab5a70cc8fba.html#.E6.96.B0.E5.A2.9E.E5.88.86.E7.BB.84
Return hash format if success: {
data:
{
group_id: <GROUP_ID>,
group_name: <GROUP_NAME>
},
errcode: 0,
errmsg: "success."
}
name: 分组名称,不超过100汉字或200个英文字母
153 154 155 156 157 158 159 160 161 162 |
# File 'lib/wechat/shake_around/group.rb', line 153 def self.create(access_token, name) assert_present! :access_token, access_token assert_present! :name, name post_json "https://api.weixin.qq.com/shakearound/device/group/add?access_token=#{access_token}", body: { group_name: name } end |
.destroy(access_token, group_id) ⇒ Object
删除分组 mp.weixin.qq.com/wiki/10/9f6b498b6aa0eb5ef6b9ab5a70cc8fba.html#.E5.88.A0.E9.99.A4.E5.88.86.E7.BB.84
Return hash format if success:
data: {,
errcode: 0,
errmsg: "success."
}
group_id: 分组唯一标识,全局唯一
100 101 102 103 104 105 106 107 108 109 |
# File 'lib/wechat/shake_around/group.rb', line 100 def self.destroy(access_token, group_id) assert_present! :access_token, access_token assert_present! :group_id, group_id post_json "https://api.weixin.qq.com/shakearound/device/group/delete?access_token=#{access_token}", body: { group_id: group_id.to_i } end |
.index(access_token, offset: 0, limit: 1000) ⇒ Object
Return hash format if success: {
data:
{
groups:
[
{
group_id: <GROUP_ID>,
group_name: <GROUP_NAME>
},
...
],
total_count: <TOTAL_COUNT> // 此账号下现有的总分组数
},
errcode: 0,
errmsg: "success."
}
offset: 分组列表的起始索引值 limit: 待查询的分组数量,不能超过1000个
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/wechat/shake_around/group.rb', line 33 def self.index(access_token, offset: 0, limit: 1000) assert_present! :access_token, access_token post_json "https://api.weixin.qq.com/shakearound/device/group/getlist?access_token=#{access_token}", body: { begin: offset.to_i, count: limit.to_i } end |
.load(access_token, group_id, offset: 0, limit: 1000) ⇒ Object
Return hash format if success: {
data:
{
group_id: <GROUP_ID>,
group_name: <GROUP_NAME>,
total_count: <TOTAL_COUNT>, // 此分组现有的总设备数
devices:
[
{
device_id: <DEIVCE_ID>,
uuid: <UUID>,
major: <MAJOR>,
minor: <MINOR>,
comment: <COMMENT>,
poi_id: <POI_ID>
},
...
]
},
errcode: 0,
errmsg: "success."
}
group_id: 分组唯一标识,全局唯一 offset: 分组里设备的起始索引值 limit: 待查询的分组里设备的数量,不能超过1000个
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/wechat/shake_around/group.rb', line 75 def self.load(access_token, group_id, offset: 0, limit: 1000) assert_present! :access_token, access_token assert_present! :group_id, group_id post_json "https://api.weixin.qq.com/shakearound/device/group/getdetail?access_token=#{access_token}", body: { group_id: group_id.to_i, begin: offset.to_i, count: limit.to_i } end |
.update(access_token, group_id, name) ⇒ Object
Return hash format if success:
data: {,
errcode: 0,
errmsg: "success."
}
group_id: 分组唯一标识,全局唯一 name: 分组名称,不超过100汉字或200个英文字母
124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/wechat/shake_around/group.rb', line 124 def self.update(access_token, group_id, name) assert_present! :access_token, access_token assert_present! :group_id, group_id assert_present! :name, name post_json "https://api.weixin.qq.com/shakearound/device/group/update?access_token=#{access_token}", body: { group_id: group_id.to_i, group_name: name } end |