wechat-shake_around 0.8 → 0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -1
- data/README.md +426 -3
- data/ROADMAP.md +4 -1
- data/lib/wechat/shake_around.rb +2 -0
- data/lib/wechat/shake_around/apply.rb +4 -4
- data/lib/wechat/shake_around/beacon.rb +1 -1
- data/lib/wechat/shake_around/beacon_page_relation.rb +9 -13
- data/lib/wechat/shake_around/device_daily_report.rb +1 -1
- data/lib/wechat/shake_around/registration.rb +57 -0
- data/lib/wechat/shake_around/shaking.rb +1 -1
- data/lib/wechat/shake_around/version.rb +1 -1
- data/wechat-shake_around.gemspec +8 -10
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ade87fe6c471bbbcec03f1ae4cb4543234dc88ff
|
4
|
+
data.tar.gz: 77271b546768163e25bdad157f387d334787f2d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1d06babbf659b2c1fbe8a102266ff33cec371d62fe44e3c575af3557b2dc73c829e521cdc20e965318c70470d94736b4d88b1f5c0491b9519f41c7b5a9d98d0
|
7
|
+
data.tar.gz: 39bd730d7716ce4955f762f758330eb24d238ea8e7e1103bbb33dbe38ad9849eabe59ae2fdd65782dd4c1a393b0b85dc5fd9ba3528ece42abc6e7eaa5fbecfb7
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -24,10 +24,44 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
-
|
27
|
+
|
28
|
+
|
29
|
+
### Registration 注册开通摇周边
|
30
|
+
[Create Registration 申请开通功能](http://mp.weixin.qq.com/wiki/13/025f1d471dc999928340161c631c6635.html#.E7.94.B3.E8.AF.B7.E5.BC.80.E9.80.9A.E5.8A.9F.E8.83.BD)
|
31
|
+
成功提交申请请求后,工作人员会在三个工作日内完成审核。
|
32
|
+
若审核不通过,可以重新提交申请请求。
|
33
|
+
若是审核中,请耐心等待工作人员审核,在审核中状态不能再提交申请请求。
|
34
|
+
industry_id参考[所需资质文件](http://3gimg.qq.com/shake_nearby/Qualificationdocuments.html)
|
28
35
|
```ruby
|
29
|
-
response =
|
30
|
-
if response.present? && 0==response['errcode']
|
36
|
+
response = Wechat::ShakeAround::Registration.create(access_token, name, phone_number, email, industry_id, qualification_links, apply_reason)
|
37
|
+
if response.present? && 0==response['errcode'].to_i
|
38
|
+
# Do something more...
|
39
|
+
else
|
40
|
+
# Show response['errmsg']
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
[Check Registration Audit Status 查询审核状态](http://mp.weixin.qq.com/wiki/13/025f1d471dc999928340161c631c6635.html#.E6.9F.A5.E8.AF.A2.E5.AE.A1.E6.A0.B8.E7.8A.B6.E6.80.81)
|
45
|
+
```ruby
|
46
|
+
response = Wechat::ShakeAround::Registration.load(access_token)
|
47
|
+
if response.present? && 0==response['errcode'].to_i
|
48
|
+
status = response['data']
|
49
|
+
apply_time = status['apply_time'] # 提交申请的时间戳
|
50
|
+
audit_comment = status['audit_comment'] # 审核备注,包括审核不通过的原因
|
51
|
+
audit_status = status['audit_status'] # 0:审核未通过、1:审核中、2:审核已通过
|
52
|
+
audit_time = status['audit_time'] # 确定审核结果的时间戳;若状态为审核中,则该时间值为0
|
53
|
+
else
|
54
|
+
# Show response['errmsg']
|
55
|
+
end
|
56
|
+
```
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
### Handle the Callback of Shaking 处理摇周边行为的回调
|
61
|
+
[Get Beacon & PoI & Page & Shaker 获取摇周边的设备及用户信息](http://mp.weixin.qq.com/wiki/3/34904a5db3d0ec7bb5306335b8da1faf.html)
|
62
|
+
```ruby
|
63
|
+
response = Wechat::ShakeAround::Shaking.load access_token, params[:ticket]
|
64
|
+
if response.present? && 0==response['errcode'].to_i
|
31
65
|
page_id = response['page_id']
|
32
66
|
open_id = response['openid']
|
33
67
|
poi_id = response['poi_id']
|
@@ -36,11 +70,400 @@ if response.present? && 0==response['errcode']
|
|
36
70
|
beacon_uuid = beacon['uuid']
|
37
71
|
beacon_major = beacon['major']
|
38
72
|
beacon_minor = beacon['minor']
|
73
|
+
else
|
74
|
+
# Show response['errmsg']
|
75
|
+
end
|
76
|
+
```
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
### Apply the Device IDs 申请Beacon设备ID
|
81
|
+
[Apply Beacon Device IDs 申请设备ID](http://mp.weixin.qq.com/wiki/15/b9e012f917e3484b7ed02771156411f3.html#.E7.94.B3.E8.AF.B7.E8.AE.BE.E5.A4.87ID)
|
82
|
+
```ruby
|
83
|
+
quantity = 500
|
84
|
+
reason = 'Test Purpose'
|
85
|
+
comment = 'Some Mall' # optional
|
86
|
+
poi_id = nil # optional Some PoI ID
|
87
|
+
response = Wechat::ShakeAround::Apply.create access_token, quantity, apply_reason, comment, poi_id
|
88
|
+
if response.present? && 0==response['errcode'].to_i
|
89
|
+
apply_id = response['data']['apply_id']
|
90
|
+
audit_status = response['data']['audit_status']
|
91
|
+
# 0:审核未通过、1:审核中、2:审核已通过
|
92
|
+
audit_comment = response['data']['audit_comment']
|
93
|
+
else
|
94
|
+
# Show response['errmsg']
|
95
|
+
end
|
96
|
+
```
|
97
|
+
|
98
|
+
[Query the Status of Application of Beacon Device IDs 查询设备ID申请审核状态](http://mp.weixin.qq.com/wiki/15/b9e012f917e3484b7ed02771156411f3.html#.E6.9F.A5.E8.AF.A2.E8.AE.BE.E5.A4.87ID.E7.94.B3.E8.AF.B7.E5.AE.A1.E6.A0.B8.E7.8A.B6.E6.80.81)
|
99
|
+
```ruby
|
100
|
+
response = Wechat::ShakeAround::Apply.load access_token, apply_id
|
101
|
+
if response.present? && 0==response['errcode'].to_i
|
102
|
+
apply_time = response['data']['apply_time']
|
103
|
+
# 提交申请的时间戳
|
104
|
+
audit_status = response['data']['audit_status']
|
105
|
+
# 0:审核未通过、1:审核中、2:审核已通过
|
106
|
+
audit_comment = response['data']['audit_comment']
|
107
|
+
audit_time = response['data']['audit_time']
|
108
|
+
# 确定审核结果的时间戳,若状态为审核中,则该时间值为0
|
109
|
+
else
|
110
|
+
# Show response['errmsg']
|
111
|
+
end
|
112
|
+
```
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
### Manage the Beacon Devices 管理Beacon设备信息
|
117
|
+
[Get Beacon information by Batch 查询设备列表](http://mp.weixin.qq.com/wiki/15/b9e012f917e3484b7ed02771156411f3.html#.E6.9F.A5.E8.AF.A2.E8.AE.BE.E5.A4.87.E5.88.97.E8.A1.A8)
|
118
|
+
```ruby
|
119
|
+
offset = 40
|
120
|
+
limit = 20
|
121
|
+
apply_id = nil
|
122
|
+
response = Wechat::ShakeAround::Beacon.index access_token, offset, limit, apply_id
|
123
|
+
if response.present? && 0==response['errcode'].to_i
|
124
|
+
total_count = response['data']['total_count']
|
125
|
+
response['data']['devices'].each do |device|
|
126
|
+
device_id = device['device_id']
|
127
|
+
uuid = device['uuid']
|
128
|
+
major = device['major']
|
129
|
+
minor = device['minor']
|
130
|
+
status = device['status']
|
131
|
+
# 0:未激活,1:已激活
|
132
|
+
last_active_time = device['last_active_time']
|
133
|
+
# 设备最近一次被摇到的日期(最早只能获取前一天的数据);新申请的设备该字段值为0
|
134
|
+
poi_id = device['poi_id']
|
135
|
+
# 设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会
|
136
|
+
end
|
137
|
+
else
|
138
|
+
# Show response['errmsg']
|
139
|
+
end
|
140
|
+
```
|
141
|
+
|
142
|
+
[Get Beacon information 查询设备](http://mp.weixin.qq.com/wiki/15/b9e012f917e3484b7ed02771156411f3.html#.E6.9F.A5.E8.AF.A2.E8.AE.BE.E5.A4.87.E5.88.97.E8.A1.A8)
|
143
|
+
device_id 是整数或者Hash结构:{ uuid: UUID, major: MAJOR, minor: MINOR }。
|
144
|
+
```ruby
|
145
|
+
response = Wechat::ShakeAround::Beacon.load access_token, device_id
|
146
|
+
if response.present? && 0==response['errcode'].to_i
|
147
|
+
total_count = response['data']['total_count']
|
148
|
+
response['data']['devices'].each do |device|
|
149
|
+
device_id = device['device_id']
|
150
|
+
uuid = device['uuid']
|
151
|
+
major = device['major']
|
152
|
+
minor = device['minor']
|
153
|
+
status = device['status']
|
154
|
+
# 0:未激活,1:已激活
|
155
|
+
last_active_time = device['last_active_time']
|
156
|
+
# 设备最近一次被摇到的日期(最早只能获取前一天的数据);新申请的设备该字段值为0
|
157
|
+
poi_id = device['poi_id']
|
158
|
+
# 设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会
|
159
|
+
end
|
160
|
+
else
|
161
|
+
# Show response['errmsg']
|
162
|
+
end
|
163
|
+
```
|
164
|
+
|
165
|
+
[Update Beacon information 编辑设备信息](http://mp.weixin.qq.com/wiki/15/b9e012f917e3484b7ed02771156411f3.html#.E7.BC.96.E8.BE.91.E8.AE.BE.E5.A4.87.E4.BF.A1.E6.81.AF)
|
166
|
+
device_id 是整数或者Hash结构:{ uuid: UUID, major: MAJOR, minor: MINOR }。
|
167
|
+
```ruby
|
168
|
+
response = Wechat::ShakeAround::Beacon.update access_token, device_id, comment
|
169
|
+
if response.present? && 0==response['errcode'].to_i
|
170
|
+
# Do something more...
|
171
|
+
else
|
172
|
+
# Show response['errmsg']
|
173
|
+
end
|
174
|
+
```
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
### Manage the Beacon Device Groups 管理Beacon设备分组
|
179
|
+
[Get Groups by Batch 查询分组列表](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)
|
180
|
+
```ruby
|
181
|
+
response = Wechat::ShakeAround::Group.index access_token, offset, limit
|
182
|
+
if response.present? && 0==response['errcode'].to_i
|
183
|
+
total_count = response['data']['total_count']
|
184
|
+
response['data']['groups'].each do |group|
|
185
|
+
group_id = group['group_id']
|
186
|
+
group_name = group['group_name']
|
187
|
+
end
|
188
|
+
else
|
189
|
+
# Show response['errmsg']
|
190
|
+
end
|
191
|
+
```
|
192
|
+
|
193
|
+
[Get Group per ID 查询分组详情](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)
|
194
|
+
```ruby
|
195
|
+
response = Wechat::ShakeAround::Group.load access_token, group_id, offset, limit
|
196
|
+
if response.present? && 0==response['errcode'].to_i
|
197
|
+
group_id = response['data']['group_id']
|
198
|
+
group_name = response['data']['group_name']
|
199
|
+
total_count = response['data']['total_count']
|
200
|
+
response['data']['devices'].each do |device|
|
201
|
+
device_id = device['device_id']
|
202
|
+
uuid = device['uuid']
|
203
|
+
major_id = device['major_id']
|
204
|
+
minor_id = device['minor_id']
|
205
|
+
comment = device['comment']
|
206
|
+
poi_id = device['poi_id']
|
207
|
+
end
|
208
|
+
else
|
209
|
+
# Show response['errmsg']
|
210
|
+
end
|
211
|
+
```
|
212
|
+
|
213
|
+
[Delete Group 删除分组](http://mp.weixin.qq.com/wiki/10/9f6b498b6aa0eb5ef6b9ab5a70cc8fba.html#.E5.88.A0.E9.99.A4.E5.88.86.E7.BB.84)
|
214
|
+
```ruby
|
215
|
+
response = Wechat::ShakeAround::Group.destroy access_token, group_id
|
216
|
+
if response.present? && 0==response['errcode'].to_i
|
217
|
+
# Do something more
|
218
|
+
else
|
219
|
+
# Show response['errmsg']
|
220
|
+
end
|
221
|
+
```
|
222
|
+
|
223
|
+
[Update Group 编辑分组信息](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)
|
224
|
+
```ruby
|
225
|
+
response = Wechat::ShakeAround::Group.update access_token, group_id, name
|
226
|
+
if response.present? && 0==response['errcode'].to_i
|
227
|
+
# Do something more
|
228
|
+
else
|
229
|
+
# Show response['errmsg']
|
230
|
+
end
|
231
|
+
```
|
232
|
+
|
233
|
+
[Create Group 新增分组](http://mp.weixin.qq.com/wiki/10/9f6b498b6aa0eb5ef6b9ab5a70cc8fba.html#.E6.96.B0.E5.A2.9E.E5.88.86.E7.BB.84)
|
234
|
+
```ruby
|
235
|
+
response = Wechat::ShakeAround::Group.create access_token, name
|
236
|
+
if response.present? && 0==response['errcode'].to_i
|
237
|
+
group_id = response['data']['group_id']
|
238
|
+
else
|
239
|
+
# Show response['errmsg']
|
240
|
+
end
|
241
|
+
```
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
### Manage Beacon Device Group Relations 管理Beacon设备分组关系
|
246
|
+
[Create Device Group Relation 新增设备分组关联](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)
|
247
|
+
```ruby
|
248
|
+
response = Wechat::ShakeAround::DeviceGroupRelation.create access_token, device_id, group_id
|
249
|
+
if response.present? && 0==response['errcode'].to_i
|
250
|
+
# Do something more
|
251
|
+
else
|
252
|
+
# Show response['errmsg']
|
253
|
+
end
|
254
|
+
```
|
255
|
+
|
256
|
+
[Destroy Device Group Relation 删除设备分组关联](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)
|
257
|
+
```ruby
|
258
|
+
response = Wechat::ShakeAround::DeviceGroupRelation.destroy access_token, device_id, group_id
|
259
|
+
if response.present? && 0==response['errcode'].to_i
|
260
|
+
# Do something more
|
261
|
+
else
|
262
|
+
# Show response['errmsg']
|
39
263
|
end
|
264
|
+
```
|
265
|
+
|
40
266
|
|
41
267
|
|
268
|
+
### Manage Pages 管理页面
|
269
|
+
[Get Pages by Batch 获取页面列表](http://mp.weixin.qq.com/wiki/5/6626199ea8757c752046d8e46cf13251.html#.E6.9F.A5.E8.AF.A2.E9.A1.B5.E9.9D.A2.E5.88.97.E8.A1.A8)
|
270
|
+
```ruby
|
271
|
+
response = Wechat::ShakeAround::Page.index access_token, offset, limit
|
272
|
+
if response.present? && 0==response['errcode'].to_i
|
273
|
+
total_count = response['data']['total_count']
|
274
|
+
response['data']['pages'].each do |page|
|
275
|
+
comment = page['comment'] # 页面的备注信息
|
276
|
+
description = page['description'] # 在摇一摇页面展示的副标题
|
277
|
+
icon_url = page['icon_url'] # 在摇一摇页面展示的图片
|
278
|
+
page_id = page['page_id'] # 摇周边页面唯一ID
|
279
|
+
page_url = page['page_url'] # 跳转链接
|
280
|
+
title = page['title'] # 在摇一摇页面展示的主标题
|
281
|
+
end
|
282
|
+
else
|
283
|
+
# Show response['errmsg']
|
284
|
+
end
|
285
|
+
```
|
286
|
+
|
287
|
+
[Get Page per ID 获取页面详情](http://mp.weixin.qq.com/wiki/5/6626199ea8757c752046d8e46cf13251.html#.E6.9F.A5.E8.AF.A2.E9.A1.B5.E9.9D.A2.E5.88.97.E8.A1.A8)
|
288
|
+
```ruby
|
289
|
+
response = Wechat::ShakeAround::Page.load access_token, page_id
|
290
|
+
if response.present? && 0==response['errcode'].to_i
|
291
|
+
total_count = response['data']['total_count']
|
292
|
+
page = response['data']['pages'][0]
|
293
|
+
comment = page['comment'] # 页面的备注信息
|
294
|
+
description = page['description'] # 在摇一摇页面展示的副标题
|
295
|
+
icon_url = page['icon_url'] # 在摇一摇页面展示的图片
|
296
|
+
page_id = page['page_id'] # 摇周边页面唯一ID
|
297
|
+
page_url = page['page_url'] # 跳转链接
|
298
|
+
title = page['title'] # 在摇一摇页面展示的主标题
|
299
|
+
else
|
300
|
+
# Show response['errmsg']
|
301
|
+
end
|
302
|
+
```
|
303
|
+
|
304
|
+
[Destroy Page per ID 删除页面](http://mp.weixin.qq.com/wiki/5/6626199ea8757c752046d8e46cf13251.html#.E5.88.A0.E9.99.A4.E9.A1.B5.E9.9D.A2)
|
305
|
+
```ruby
|
306
|
+
response = Wechat::ShakeAround::Page.destroy access_token, page_id
|
307
|
+
if response.present? && 0==response['errcode'].to_i
|
308
|
+
# Do something more
|
309
|
+
else
|
310
|
+
# Show response['errmsg']
|
311
|
+
end
|
312
|
+
```
|
313
|
+
|
314
|
+
[Update Page per ID 编辑页面信息](http://mp.weixin.qq.com/wiki/5/6626199ea8757c752046d8e46cf13251.html#.E7.BC.96.E8.BE.91.E9.A1.B5.E9.9D.A2.E4.BF.A1.E6.81.AF)
|
315
|
+
```ruby
|
316
|
+
response = Wechat::ShakeAround::Page.update access_token, page_id, title, description, comment, page_link, icon_link
|
317
|
+
if response.present? && 0==response['errcode'].to_i
|
318
|
+
# Do something more
|
319
|
+
else
|
320
|
+
# Show response['errmsg']
|
321
|
+
end
|
322
|
+
```
|
323
|
+
|
324
|
+
[Create Page 新增页面](http://mp.weixin.qq.com/wiki/5/6626199ea8757c752046d8e46cf13251.html#.E6.96.B0.E5.A2.9E.E9.A1.B5.E9.9D.A2)
|
325
|
+
```ruby
|
326
|
+
response = Wechat::ShakeAround::Page.create access_token, title, description, comment, page_link, icon_link
|
327
|
+
if response.present? && 0==response['errcode'].to_i
|
328
|
+
page_id = response['data']['page_id']
|
329
|
+
else
|
330
|
+
# Show response['errmsg']
|
331
|
+
end
|
332
|
+
```
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
### Manage Beacon Device Page Relations 管理Beacon设备页面关系
|
337
|
+
[Destroy Beacon Page Relation 删除Beacon页面关系](http://mp.weixin.qq.com/wiki/12/c8120214ec0ba08af5dfcc0da1a11400.html)
|
338
|
+
device_id 可以是整数或者Hash结构:{ uuid: UUID, major: MAJOR, minor: MINOR }。
|
339
|
+
```ruby
|
340
|
+
response = Wechat::ShakeAround::BeaconPageRelation.destroy access_token, device_id, page_id
|
341
|
+
if response.present? && 0==response['errcode'].to_i
|
342
|
+
# Do something more
|
343
|
+
else
|
344
|
+
# Show response['errmsg']
|
345
|
+
end
|
346
|
+
```
|
347
|
+
|
348
|
+
[Create Beacon Page Relation 创建Beacon页面关系](http://mp.weixin.qq.com/wiki/12/c8120214ec0ba08af5dfcc0da1a11400.html)
|
349
|
+
device_id 可以是整数或者Hash结构:{ uuid: UUID, major: MAJOR, minor: MINOR }。
|
350
|
+
```ruby
|
351
|
+
response = Wechat::ShakeAround::BeaconPageRelation.create access_token, device_id, page_id
|
352
|
+
if response.present? && 0==response['errcode'].to_i
|
353
|
+
# Do something more
|
354
|
+
else
|
355
|
+
# Show response['errmsg']
|
356
|
+
end
|
42
357
|
```
|
43
358
|
|
359
|
+
|
360
|
+
|
361
|
+
### Manage Beacon PoI Relation 管理Beacon场地关系
|
362
|
+
[Create Beacon PoI Relation 创建Beacon场地关系](http://mp.weixin.qq.com/wiki/15/b9e012f917e3484b7ed02771156411f3.html#.E9.85.8D.E7.BD.AE.E8.AE.BE.E5.A4.87.E4.B8.8E.E9.97.A8.E5.BA.97.E7.9A.84.E5.85.B3.E8.81.94.E5.85.B3.E7.B3.BB)
|
363
|
+
device_id 可以是整数或者Hash结构:{ uuid: UUID, major: MAJOR, minor: MINOR }。
|
364
|
+
```ruby
|
365
|
+
response = Wechat::ShakeAround::BeaconPoiRelation.create access_token, device_id, poi_id
|
366
|
+
if response.present? && 0==response['errcode'].to_i
|
367
|
+
# Do something more
|
368
|
+
else
|
369
|
+
# Show response['errmsg']
|
370
|
+
end
|
371
|
+
```
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
### Beacon Device Report Beacon设备报表
|
376
|
+
[Query Beacon Device Stats. Data by Batch 批量查询设备统计数据接口](http://mp.weixin.qq.com/wiki/0/8a24bcacad40fe7ee98d1573cb8a6764.html#.E6.89.B9.E9.87.8F.E6.9F.A5.E8.AF.A2.E8.AE.BE.E5.A4.87.E7.BB.9F.E8.AE.A1.E6.95.B0.E6.8D.AE.E6.8E.A5.E5.8F.A3)
|
377
|
+
date是以秒为单位的整数。page_index从1开始。
|
378
|
+
```ruby
|
379
|
+
response = Wechat::ShakeAround::DeviceReport.index access_token, date, page_index
|
380
|
+
if response.present? && 0==response['errcode'].to_i
|
381
|
+
date = response['date']
|
382
|
+
total_count = response['total_count']
|
383
|
+
page_index = response['page_index']
|
384
|
+
response['data']['devices'].each do |device|
|
385
|
+
device_id = device['device_id']
|
386
|
+
major = device['major']
|
387
|
+
minor = device['minor']
|
388
|
+
uuid = device['uuid']
|
389
|
+
shake_pv = device['shake_pv']
|
390
|
+
shake_uv = device['shake_uv']
|
391
|
+
click_pv = device['click_pv']
|
392
|
+
click_uv = device['click_uv']
|
393
|
+
end
|
394
|
+
else
|
395
|
+
# Show response['errmsg']
|
396
|
+
end
|
397
|
+
```
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
### Beacon Device Daily Report Beacon设备每日报表
|
402
|
+
[Query Beacon Device Stats. Data by Date 以设备为维度的数据统计接口](http://mp.weixin.qq.com/wiki/0/8a24bcacad40fe7ee98d1573cb8a6764.html#.E4.BB.A5.E8.AE.BE.E5.A4.87.E4.B8.BA.E7.BB.B4.E5.BA.A6.E7.9A.84.E6.95.B0.E6.8D.AE.E7.BB.9F.E8.AE.A1.E6.8E.A5.E5.8F.A3)
|
403
|
+
device_id 可以是整数或者Hash结构: { uuid: UUID, major: MAJOR, minor: MINOR }。
|
404
|
+
date_range 是字符串范围,形式如: 'yyyy-mm-dd'..'yyyy-mm-dd'。
|
405
|
+
```ruby
|
406
|
+
response = Wechat::ShakeAround::DeviceDailyReport.index access_token, device_id, date_range
|
407
|
+
if response.present? && 0==response['errcode'].to_i
|
408
|
+
response['data'].each do |item|
|
409
|
+
date = item['ftime']
|
410
|
+
# 当天0点对应的时间戳
|
411
|
+
shake_pv = item['shake_pv']
|
412
|
+
shake_uv = item['shake_uv']
|
413
|
+
click_pv = item['click_pv']
|
414
|
+
click_uv = item['click_uv']
|
415
|
+
end
|
416
|
+
else
|
417
|
+
# Show response['errmsg']
|
418
|
+
end
|
419
|
+
```
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
### Page Report 页面报表
|
424
|
+
[Query Page Stats. Data by Batch 批量查询页面统计数据接口](http://mp.weixin.qq.com/wiki/0/8a24bcacad40fe7ee98d1573cb8a6764.html#.E6.89.B9.E9.87.8F.E6.9F.A5.E8.AF.A2.E9.A1.B5.E9.9D.A2.E7.BB.9F.E8.AE.A1.E6.95.B0.E6.8D.AE.E6.8E.A5.E5.8F.A3)
|
425
|
+
date是以秒为单位的整数。page_index从1开始。
|
426
|
+
```ruby
|
427
|
+
response = Wechat::ShakeAround::PageReport.index access_token, date, page_index
|
428
|
+
if response.present? && 0==response['errcode'].to_i
|
429
|
+
date = response['date']
|
430
|
+
total_count = response['total_count']
|
431
|
+
page_index = response['page_index']
|
432
|
+
response['data']['pages'].each do |page|
|
433
|
+
page_id = page['page_id']
|
434
|
+
shake_pv = page['shake_pv']
|
435
|
+
shake_uv = page['shake_uv']
|
436
|
+
click_pv = page['click_pv']
|
437
|
+
click_uv = page['click_uv']
|
438
|
+
end
|
439
|
+
else
|
440
|
+
# Show response['errmsg']
|
441
|
+
end
|
442
|
+
```
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
### Page Daily Report 页面每日报表
|
447
|
+
[Query Page Stats. Data by Date 以页面为维度的数据统计接口](http://mp.weixin.qq.com/wiki/0/8a24bcacad40fe7ee98d1573cb8a6764.html#.E4.BB.A5.E9.A1.B5.E9.9D.A2.E4.B8.BA.E7.BB.B4.E5.BA.A6.E7.9A.84.E6.95.B0.E6.8D.AE.E7.BB.9F.E8.AE.A1.E6.8E.A5.E5.8F.A3)
|
448
|
+
page_id 是从1开始的整数。 date_range 是字符串范围,形式如: 'yyyy-mm-dd'..'yyyy-mm-dd'。
|
449
|
+
```ruby
|
450
|
+
response = Wechat::ShakeAround::PageDailyReport.index access_token, page_id, date_range
|
451
|
+
if response.present? && 0==response['errcode'].to_i
|
452
|
+
response['data'].each do |item|
|
453
|
+
date = item['ftime']
|
454
|
+
# 当天0点对应的时间戳
|
455
|
+
shake_pv = item['shake_pv']
|
456
|
+
shake_uv = item['shake_uv']
|
457
|
+
click_pv = item['click_pv']
|
458
|
+
click_uv = item['click_uv']
|
459
|
+
end
|
460
|
+
else
|
461
|
+
# Show response['errmsg']
|
462
|
+
end
|
463
|
+
```
|
464
|
+
|
465
|
+
|
466
|
+
|
44
467
|
## Development
|
45
468
|
|
46
469
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/ROADMAP.md
CHANGED
data/lib/wechat/shake_around.rb
CHANGED
@@ -40,10 +40,10 @@ class Wechat::ShakeAround::Apply
|
|
40
40
|
# }
|
41
41
|
#
|
42
42
|
# quantity: 申请的设备ID的数量,单次新增设备超过500个,需走人工审核流程。
|
43
|
-
#
|
44
|
-
# comment:
|
45
|
-
def self.create(access_token, quantity,
|
46
|
-
options = { quantity: quantity, apply_reason:
|
43
|
+
# reason: 申请理由,不超过100个汉字或200个英文字母。
|
44
|
+
# comment: 备注,不超过15个汉字或30个英文字母。
|
45
|
+
def self.create(access_token, quantity, reason, comment = nil, poi_id = nil)
|
46
|
+
options = { quantity: quantity, apply_reason: reason }
|
47
47
|
options[:comment] = comment if comment.present?
|
48
48
|
options[:poi_id] = poi_id if poi_id.present?
|
49
49
|
message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/device/applyid?access_token=#{access_token}", options
|
@@ -4,7 +4,7 @@ class Wechat::ShakeAround::BeaconPageRelation
|
|
4
4
|
|
5
5
|
extend ::Wechat::ShakeAround::Common
|
6
6
|
|
7
|
-
#
|
7
|
+
# 删除设备与页面的关联关系
|
8
8
|
# http://mp.weixin.qq.com/wiki/12/c8120214ec0ba08af5dfcc0da1a11400.html
|
9
9
|
#
|
10
10
|
# Return hash format if success:
|
@@ -18,7 +18,7 @@ class Wechat::ShakeAround::BeaconPageRelation
|
|
18
18
|
# page_id is an integer or an integer array.
|
19
19
|
# bind 关联操作标志位,0为解除关联关系,1为建立关联关系
|
20
20
|
# append 新增操作标志位,0为覆盖,1为新增
|
21
|
-
def self.
|
21
|
+
def self.destroy(access_token, device_id, page_id)
|
22
22
|
|
23
23
|
device_identifier = normalize_device_id device_id
|
24
24
|
page_ids = normalize_page_ids page_id
|
@@ -27,13 +27,13 @@ class Wechat::ShakeAround::BeaconPageRelation
|
|
27
27
|
{
|
28
28
|
device_identifier: device_identifier,
|
29
29
|
page_ids: page_ids,
|
30
|
-
bind:
|
31
|
-
append:
|
30
|
+
bind: 0,
|
31
|
+
append: 0
|
32
32
|
}
|
33
33
|
message.body
|
34
34
|
end
|
35
35
|
|
36
|
-
#
|
36
|
+
# 创建设备与页面的关联关系
|
37
37
|
# http://mp.weixin.qq.com/wiki/12/c8120214ec0ba08af5dfcc0da1a11400.html
|
38
38
|
#
|
39
39
|
# Return hash format if success:
|
@@ -47,7 +47,7 @@ class Wechat::ShakeAround::BeaconPageRelation
|
|
47
47
|
# page_id is an integer or an integer array.
|
48
48
|
# bind 关联操作标志位,0为解除关联关系,1为建立关联关系
|
49
49
|
# append 新增操作标志位,0为覆盖,1为新增
|
50
|
-
def self.
|
50
|
+
def self.create(access_token, device_id, page_id)
|
51
51
|
|
52
52
|
device_identifier = normalize_device_id device_id
|
53
53
|
page_ids = normalize_page_ids page_id
|
@@ -56,14 +56,10 @@ class Wechat::ShakeAround::BeaconPageRelation
|
|
56
56
|
{
|
57
57
|
device_identifier: device_identifier,
|
58
58
|
page_ids: page_ids,
|
59
|
-
bind:
|
60
|
-
append:
|
59
|
+
bind: 1,
|
60
|
+
append: 1
|
61
61
|
}
|
62
62
|
message.body
|
63
63
|
end
|
64
|
-
|
65
|
-
def self.normalize_page_id(page_id)
|
66
|
-
page_id.is_a?(Array) ? page_id.map { |i| i.to_i } : [ page_id.to_i ]
|
67
|
-
end
|
68
|
-
=end
|
64
|
+
|
69
65
|
end
|
@@ -5,7 +5,7 @@ class Wechat::ShakeAround::DeviceDailyReport
|
|
5
5
|
extend ::Wechat::ShakeAround::Common
|
6
6
|
|
7
7
|
# 以设备为维度的数据统计接口
|
8
|
-
# http://mp.weixin.qq.com/wiki/0/8a24bcacad40fe7ee98d1573cb8a6764.html
|
8
|
+
# http://mp.weixin.qq.com/wiki/0/8a24bcacad40fe7ee98d1573cb8a6764.html#.E4.BB.A5.E8.AE.BE.E5.A4.87.E4.B8.BA.E7.BB.B4.E5.BA.A6.E7.9A.84.E6.95.B0.E6.8D.AE.E7.BB.9F.E8.AE.A1.E6.8E.A5.E5.8F.A3
|
9
9
|
#
|
10
10
|
# Return hash format if success:
|
11
11
|
# {
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'jsonclient'
|
2
|
+
|
3
|
+
class Wechat::ShakeAround::Registration
|
4
|
+
|
5
|
+
extend ::Wechat::ShakeAround::Common
|
6
|
+
|
7
|
+
# 查询审核状态
|
8
|
+
# http://mp.weixin.qq.com/wiki/13/025f1d471dc999928340161c631c6635.html#.E6.9F.A5.E8.AF.A2.E5.AE.A1.E6.A0.B8.E7.8A.B6.E6.80.81
|
9
|
+
#
|
10
|
+
# Return hash format if success:
|
11
|
+
# {
|
12
|
+
# data: {
|
13
|
+
# apply_time: APPLY_TIME,
|
14
|
+
# audit_comment: AUDIT_COMMENT,
|
15
|
+
# audit_status: AUDIT_STATUS,
|
16
|
+
# audit_time: AUDIT_TIME
|
17
|
+
# },
|
18
|
+
# errcode: 0,
|
19
|
+
# errmsg: 'success.'
|
20
|
+
# }
|
21
|
+
#
|
22
|
+
# apply_time: 提交申请的时间戳
|
23
|
+
# apply_comment: 审核备注,包括审核不通过的原因
|
24
|
+
# audit_status: 0:审核未通过、1:审核中、2:审核已通过
|
25
|
+
# audit_time: 确定审核结果的时间戳;若状态为审核中,则该时间值为0
|
26
|
+
def self.load(access_token)
|
27
|
+
message = ::JSONClient.new.get "https://api.weixin.qq.com/shakearound/account/auditstatus?access_token=#{access_token}"
|
28
|
+
message.body
|
29
|
+
end
|
30
|
+
|
31
|
+
# 申请开通功能
|
32
|
+
# http://mp.weixin.qq.com/wiki/13/025f1d471dc999928340161c631c6635.html#.E7.94.B3.E8.AF.B7.E5.BC.80.E9.80.9A.E5.8A.9F.E8.83.BD
|
33
|
+
# 成功提交申请请求后,工作人员会在三个工作日内完成审核。
|
34
|
+
# 若审核不通过,可以重新提交申请请求。
|
35
|
+
# 若是审核中,请耐心等待工作人员审核,在审核中状态不能再提交申请请求。
|
36
|
+
# industry_id: http://3gimg.qq.com/shake_nearby/Qualificationdocuments.html
|
37
|
+
#
|
38
|
+
# Return hash format if success:
|
39
|
+
# {
|
40
|
+
# data: {},
|
41
|
+
# errcode: 0,
|
42
|
+
# errmsg: 'success.'
|
43
|
+
# }
|
44
|
+
def self.create(access_token, name, phone_number, email, industry_id, qualification_links, apply_reason)
|
45
|
+
message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/account/register?access_token=#{access_token}",
|
46
|
+
{
|
47
|
+
name: name,
|
48
|
+
phone_number: phone_number,
|
49
|
+
email: email,
|
50
|
+
industry_id: industry_id,
|
51
|
+
qualification_cert_urls: qualification_links,
|
52
|
+
apply_reason: apply_reason
|
53
|
+
}
|
54
|
+
message.body
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -28,7 +28,7 @@ class Wechat::ShakeAround::Shaking
|
|
28
28
|
def self.load(access_token, ticket)
|
29
29
|
message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/user/getshakeinfo?access_token=#{access_token}",
|
30
30
|
{
|
31
|
-
ticket:
|
31
|
+
ticket: ticket,
|
32
32
|
need_poi: 1
|
33
33
|
}
|
34
34
|
message.body
|
data/wechat-shake_around.gemspec
CHANGED
@@ -4,16 +4,14 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'wechat/shake_around/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
|
8
|
-
spec.
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
spec.
|
12
|
-
|
13
|
-
spec.
|
14
|
-
spec.
|
15
|
-
spec.homepage = 'https://github.com/topbitdu/wechat-shake_around'
|
16
|
-
spec.license = 'MIT'
|
7
|
+
spec.name = 'wechat-shake_around'
|
8
|
+
spec.version = Wechat::ShakeAround::VERSION
|
9
|
+
spec.authors = [ 'Topbit Du' ]
|
10
|
+
spec.email = [ 'topbit.du@gmail.com' ]
|
11
|
+
spec.summary = 'Wechat Shake Around Library 微信摇周边库'
|
12
|
+
spec.description = 'Wechat Shake Around Library is a wrapper for calling the Shake Around APIs. 微信摇周边库封装了微信摇周边API的调用。'
|
13
|
+
spec.homepage = 'https://github.com/topbitdu/wechat-shake_around'
|
14
|
+
spec.license = 'MIT'
|
17
15
|
|
18
16
|
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
19
17
|
# delete this section to allow pushing this gem to any host.
|
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
|
+
version: '0.9'
|
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-
|
11
|
+
date: 2016-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/wechat/shake_around/page.rb
|
103
103
|
- lib/wechat/shake_around/page_daily_report.rb
|
104
104
|
- lib/wechat/shake_around/page_report.rb
|
105
|
+
- lib/wechat/shake_around/registration.rb
|
105
106
|
- lib/wechat/shake_around/shaking.rb
|
106
107
|
- lib/wechat/shake_around/version.rb
|
107
108
|
- wechat-shake_around.gemspec
|