wechat-shake_around 0.4 → 0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a736132f426e81fc4bd86bf97afbdfddf7f8a49c
4
- data.tar.gz: c27ef6734e3af540ebeeff4621bac76b360b9a0a
3
+ metadata.gz: 784c7c95779fa71b20d5b1a045ac253b21c81d31
4
+ data.tar.gz: 2666c404cb67a5b820221827793b9d83fa63edfd
5
5
  SHA512:
6
- metadata.gz: a16423788bbde419dbc00d1747ebeb33c383a4c79d30d1701053616a72367a2d6a55663760443be0128e8fd76ddf9dde72d79e559e51c8135785bfcd7865f03d
7
- data.tar.gz: 7033e16157b450669337cfde00893d57a13c086256b2d5adf7b25907aacb6094381fedb12a4c6e88c5144982ae0a895c1883e6906d3e4f106798bd748814324a
6
+ metadata.gz: 11d46eb0445ed118dd4fbecd366665ea308fdd24d14910066b1c9125daaa3e91a56afe2c8382b1dc6b4c1cc1ca51718370654563d15f581e2b1aa8bb496363fa
7
+ data.tar.gz: d3690fab70c308a891aee22f32a0a9663a19fd3198d02799b5577e023a0d88f8521c7e2ab4dfc31bc1adfc07fdb51ea73474588d4ef8791930d8f9018b6fb505
data/CHANGELOG.md CHANGED
@@ -17,3 +17,7 @@
17
17
  ## v0.4
18
18
  1. Page Report wrapper class
19
19
  2. Page Daily Report wrapper class
20
+
21
+ ## v0.5
22
+ 1. Group wrapper class
23
+ 2. Device Group Relation wrapper class
@@ -0,0 +1,50 @@
1
+ require 'jsonclient'
2
+
3
+ class Wechat::ShakeAround::DeviceGroupRelation
4
+
5
+ extend ::Wechat::ShakeAround::Common
6
+
7
+ # 从分组中移除设备
8
+ # http://mp.weixin.qq.com/wiki/10/9f6b498b6aa0eb5ef6b9ab5a70cc8fba.html#.E4.BB.8E.E5.88.86.E7.BB.84.E4.B8.AD.E7.A7.BB.E9.99.A4.E8.AE.BE.E5.A4.87
9
+ #
10
+ # Return hash format if success:
11
+ # {
12
+ # data: {},
13
+ # errcode: 0,
14
+ # errmsg: 'success.'
15
+ # }
16
+ #
17
+ # device_id is an integer or a hash like { uuid: <UUID>, major: <MAJOR>, minor: <MINOR> }.
18
+ def self.destroy(access_token, device_id, group_id)
19
+ device_identifier = normalize_device_id device_id
20
+ message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/device/group/deletedevice?access_token=#{access_token}",
21
+ {
22
+ group_id: group_id.to_i,
23
+ device_identifiers: [ device_identifier ]
24
+ }
25
+ message.body
26
+ end
27
+
28
+ # 添加设备到分组
29
+ # http://mp.weixin.qq.com/wiki/10/9f6b498b6aa0eb5ef6b9ab5a70cc8fba.html#.E6.B7.BB.E5.8A.A0.E8.AE.BE.E5.A4.87.E5.88.B0.E5.88.86.E7.BB.84
30
+ #
31
+ # Return hash format if success:
32
+ # {
33
+ # data: {},
34
+ # errcode: 0,
35
+ # errmsg: 'success.'
36
+ # }
37
+ #
38
+ # device_id is an integer or a hash like { uuid: <UUID>, major: <MAJOR>, minor: <MINOR> }.
39
+ # 每个分组能够持有的设备上限为10000,并且每次添加操作的添加上限为1000。
40
+ def self.create(access_token, device_id, group_id)
41
+ device_identifier = normalize_device_id device_id
42
+ message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/device/group/adddevice?access_token=#{access_token}",
43
+ {
44
+ group_id: group_id.to_i,
45
+ device_identifiers: [ device_identifier ]
46
+ }
47
+ message.body
48
+ end
49
+
50
+ end
@@ -0,0 +1,136 @@
1
+ require 'jsonclient'
2
+
3
+ class Wechat::ShakeAround::Group
4
+
5
+ extend ::Wechat::ShakeAround::Common
6
+
7
+ # 查询分组列表
8
+ # http://mp.weixin.qq.com/wiki/10/9f6b498b6aa0eb5ef6b9ab5a70cc8fba.html#.E6.9F.A5.E8.AF.A2.E5.88.86.E7.BB.84.E5.88.97.E8.A1.A8
9
+ #
10
+ # Return hash format if success:
11
+ # {
12
+ # data:
13
+ # {
14
+ # groups:
15
+ # [
16
+ # {
17
+ # group_id: <GROUP_ID>,
18
+ # group_name: <GROUP_NAME>
19
+ # },
20
+ # ...
21
+ # ],
22
+ # total_count: <TOTAL_COUNT> // 此账号下现有的总分组数
23
+ # },
24
+ # errcode: 0,
25
+ # errmsg: "success."
26
+ # }
27
+ #
28
+ # offset: 分组列表的起始索引值
29
+ # limit: 待查询的分组数量,不能超过1000个
30
+ def self.index(access_token, offset = 0, limit = 1000)
31
+ message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/device/group/getlist?access_token=#{access_token}",
32
+ {
33
+ begin: offset.to_i,
34
+ count: limit.to_i
35
+ }
36
+ message.body
37
+ end
38
+
39
+ # 查询分组详情
40
+ # http://mp.weixin.qq.com/wiki/10/9f6b498b6aa0eb5ef6b9ab5a70cc8fba.html#.E6.9F.A5.E8.AF.A2.E5.88.86.E7.BB.84.E8.AF.A6.E6.83.85
41
+ #
42
+ # Return hash format if success:
43
+ # {
44
+ # data:
45
+ # {
46
+ # group_id: <GROUP_ID>,
47
+ # group_name: <GROUP_NAME>,
48
+ # total_count: <TOTAL_COUNT>, // 此分组现有的总设备数
49
+ # devices:
50
+ # [
51
+ # {
52
+ # device_id: <DEIVCE_ID>,
53
+ # uuid: <UUID>,
54
+ # major: <MAJOR>,
55
+ # minor: <MINOR>,
56
+ # comment: <COMMENT>,
57
+ # poi_id: <POI_ID>
58
+ # },
59
+ # ...
60
+ # ]
61
+ # },
62
+ # errcode: 0,
63
+ # errmsg: "success."
64
+ # }
65
+ #
66
+ # group_id: 分组唯一标识,全局唯一
67
+ # offset: 分组里设备的起始索引值
68
+ # limit: 待查询的分组里设备的数量,不能超过1000个
69
+ def self.load(access_token, group_id, offset = 0, limit = 1000)
70
+ message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/device/group/getdetail?access_token=#{access_token}",
71
+ {
72
+ group_id: group_id.to_i,
73
+ begin: offset.to_i,
74
+ count: limit.to_i
75
+ }
76
+ message.body
77
+ end
78
+
79
+ # 删除分组
80
+ # http://mp.weixin.qq.com/wiki/10/9f6b498b6aa0eb5ef6b9ab5a70cc8fba.html#.E5.88.A0.E9.99.A4.E5.88.86.E7.BB.84
81
+ #
82
+ # Return hash format if success:
83
+ # {
84
+ # data: {},
85
+ # errcode: 0,
86
+ # errmsg: "success."
87
+ # }
88
+ #
89
+ # group_id: 分组唯一标识,全局唯一
90
+ def self.destroy(access_token, group_id)
91
+ message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/device/group/delete?access_token=#{access_token}", { group_id: group_id.to_i }
92
+ message.body
93
+ end
94
+
95
+ # 编辑分组信息
96
+ # http://mp.weixin.qq.com/wiki/10/9f6b498b6aa0eb5ef6b9ab5a70cc8fba.html#.E7.BC.96.E8.BE.91.E5.88.86.E7.BB.84.E4.BF.A1.E6.81.AF
97
+ #
98
+ # Return hash format if success:
99
+ # {
100
+ # data: {},
101
+ # errcode: 0,
102
+ # errmsg: "success."
103
+ # }
104
+ #
105
+ # group_id: 分组唯一标识,全局唯一
106
+ # name: 分组名称,不超过100汉字或200个英文字母
107
+ def self.update(access_token, group_id, name)
108
+ message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/device/group/update?access_token=#{access_token}",
109
+ {
110
+ group_id: group_id.to_i,
111
+ group_name: name
112
+ }
113
+ message.body
114
+ end
115
+
116
+ # 新增分组
117
+ # http://mp.weixin.qq.com/wiki/10/9f6b498b6aa0eb5ef6b9ab5a70cc8fba.html#.E6.96.B0.E5.A2.9E.E5.88.86.E7.BB.84
118
+ #
119
+ # Return hash format if success:
120
+ # {
121
+ # data:
122
+ # {
123
+ # group_id: <GROUP_ID>,
124
+ # group_name: <GROUP_NAME>
125
+ # },
126
+ # errcode: 0,
127
+ # errmsg: "success."
128
+ # }
129
+ #
130
+ # name: 分组名称,不超过100汉字或200个英文字母
131
+ def self.create(access_token, name)
132
+ message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/device/group/add?access_token=#{access_token}", { group_name: name }
133
+ message.body
134
+ end
135
+
136
+ end
@@ -1,5 +1,5 @@
1
1
  module Wechat
2
2
  module ShakeAround
3
- VERSION = '0.4'.freeze
3
+ VERSION = '0.5'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wechat-shake_around
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: '0.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-18 00:00:00.000000000 Z
11
+ date: 2016-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -90,6 +90,8 @@ files:
90
90
  - lib/wechat/shake_around/beacon.rb
91
91
  - lib/wechat/shake_around/beacon_page_relation.rb
92
92
  - lib/wechat/shake_around/common.rb
93
+ - lib/wechat/shake_around/device_group_relation.rb
94
+ - lib/wechat/shake_around/group.rb
93
95
  - lib/wechat/shake_around/icon.rb
94
96
  - lib/wechat/shake_around/license.rb
95
97
  - lib/wechat/shake_around/material.rb