wechat-shake_around 0.2 → 0.3
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 -0
- data/lib/wechat/shake_around/beacon_page_relation.rb +69 -0
- data/lib/wechat/shake_around/page.rb +143 -0
- data/lib/wechat/shake_around/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 875e9436ab8c3ee96401b149eee9e6fdf21835c8
|
4
|
+
data.tar.gz: 13f800097d3b6ff7cc22d1f01f3c3f2a4ea7fd0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c54a9effe59ce22a81b2eb3a252fb8f46b20539e05ac31d4329d7386a44d8689387804d0cc4ab9f94dccf578ed360ac2de059ed64c611fc36647b236a2f70242
|
7
|
+
data.tar.gz: fe808be353d7489e634ccc8ba702c51c61e666c1b4198464561167a9ea04b8376952791501cf45d77c37d9e2e870a55eecfd7c08094b5e4bc3597c8f163cc698
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'jsonclient'
|
2
|
+
|
3
|
+
class Wechat::ShakeAround::BeaconPageRelation
|
4
|
+
|
5
|
+
extend ::Wechat::ShakeAround::Common
|
6
|
+
|
7
|
+
# 配置设备与页面的关联关系
|
8
|
+
# http://mp.weixin.qq.com/wiki/12/c8120214ec0ba08af5dfcc0da1a11400.html
|
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
|
+
# page_id is an integer or an integer array.
|
19
|
+
# bind 关联操作标志位,0为解除关联关系,1为建立关联关系
|
20
|
+
# append 新增操作标志位,0为覆盖,1为新增
|
21
|
+
def self.create(access_token, device_id, page_id)
|
22
|
+
|
23
|
+
device_identifier = normalize_device_id device_id
|
24
|
+
page_ids = normalize_page_ids page_id
|
25
|
+
|
26
|
+
message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/device/bindpage?access_token=#{access_token}",
|
27
|
+
{
|
28
|
+
device_identifier: device_identifier,
|
29
|
+
page_ids: page_ids,
|
30
|
+
bind: 1,
|
31
|
+
append: 1
|
32
|
+
}
|
33
|
+
message.body
|
34
|
+
end
|
35
|
+
|
36
|
+
# 配置设备与页面的关联关系
|
37
|
+
# http://mp.weixin.qq.com/wiki/12/c8120214ec0ba08af5dfcc0da1a11400.html
|
38
|
+
#
|
39
|
+
# Return hash format if success:
|
40
|
+
# {
|
41
|
+
# data: {},
|
42
|
+
# errcode: 0,
|
43
|
+
# errmsg: 'success.'
|
44
|
+
# }
|
45
|
+
#
|
46
|
+
# device_id is an integer or a hash like { uuid: <UUID>, major: <MAJOR>, minor: <MINOR> }.
|
47
|
+
# page_id is an integer or an integer array.
|
48
|
+
# bind 关联操作标志位,0为解除关联关系,1为建立关联关系
|
49
|
+
# append 新增操作标志位,0为覆盖,1为新增
|
50
|
+
def self.destroy(access_token, device_id, page_id)
|
51
|
+
|
52
|
+
device_identifier = normalize_device_id device_id
|
53
|
+
page_ids = normalize_page_ids page_id
|
54
|
+
|
55
|
+
message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/device/bindpage?access_token=#{access_token}",
|
56
|
+
{
|
57
|
+
device_identifier: device_identifier,
|
58
|
+
page_ids: page_ids,
|
59
|
+
bind: 0,
|
60
|
+
append: 0
|
61
|
+
}
|
62
|
+
message.body
|
63
|
+
end
|
64
|
+
=begin
|
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
|
69
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
require 'jsonclient'
|
2
|
+
|
3
|
+
class Wechat::ShakeAround::Page
|
4
|
+
|
5
|
+
extend ::Wechat::ShakeAround::Common
|
6
|
+
|
7
|
+
# 查询页面列表
|
8
|
+
# 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
|
9
|
+
#
|
10
|
+
# Return hash format if success:
|
11
|
+
# {
|
12
|
+
# data:
|
13
|
+
# {
|
14
|
+
# pages:
|
15
|
+
# [
|
16
|
+
# {
|
17
|
+
# comment: <COMMENT>, // 页面的备注信息
|
18
|
+
# description: <DESCRIPTION>, // 在摇一摇页面展示的副标题
|
19
|
+
# icon_url: <ICON_LINK>, // 在摇一摇页面展示的图片
|
20
|
+
# page_id: <PAGE_ID>, // 摇周边页面唯一ID
|
21
|
+
# page_url: <PAGE_LINK>, // 跳转链接
|
22
|
+
# title: <TITLE> // 在摇一摇页面展示的主标题
|
23
|
+
# },
|
24
|
+
# ...
|
25
|
+
# ],
|
26
|
+
# total_count: <TOTAL_COUNT> // 商户名下的页面总数
|
27
|
+
# },
|
28
|
+
# errcode: 0,
|
29
|
+
# errmsg: 'success.'
|
30
|
+
# }
|
31
|
+
def self.index(access_token, offset, limit)
|
32
|
+
message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/page/search?access_token=#{access_token}",
|
33
|
+
{
|
34
|
+
type: 2,
|
35
|
+
begin: offset.to_i,
|
36
|
+
count: limit.to_i
|
37
|
+
}
|
38
|
+
message.body
|
39
|
+
end
|
40
|
+
|
41
|
+
# 查询页面列表
|
42
|
+
# 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
|
43
|
+
#
|
44
|
+
# Return hash format if success:
|
45
|
+
# {
|
46
|
+
# data:
|
47
|
+
# {
|
48
|
+
# pages:
|
49
|
+
# [
|
50
|
+
# {
|
51
|
+
# comment: <COMMENT>, // 页面的备注信息
|
52
|
+
# description: <DESCRIPTION>, // 在摇一摇页面展示的副标题
|
53
|
+
# icon_url: <ICON_LINK>, // 在摇一摇页面展示的图片
|
54
|
+
# page_id: <PAGE_ID>, // 摇周边页面唯一ID
|
55
|
+
# page_url: <PAGE_LINK>, // 跳转链接
|
56
|
+
# title: <TITLE> // 在摇一摇页面展示的主标题
|
57
|
+
# },
|
58
|
+
# ...
|
59
|
+
# ],
|
60
|
+
# total_count: <TOTAL_COUNT> // 商户名下的页面总数
|
61
|
+
# },
|
62
|
+
# errcode: 0,
|
63
|
+
# errmsg: 'success.'
|
64
|
+
# }
|
65
|
+
#
|
66
|
+
# page_id 可以是数字、整数或者它们的数组。
|
67
|
+
def self.load(access_token, page_id)
|
68
|
+
message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/page/search?access_token=#{access_token}",
|
69
|
+
{
|
70
|
+
type: 1,
|
71
|
+
page_ids: normalize_page_ids(page_id)
|
72
|
+
}
|
73
|
+
message.body
|
74
|
+
end
|
75
|
+
|
76
|
+
# 删除页面
|
77
|
+
# http://mp.weixin.qq.com/wiki/5/6626199ea8757c752046d8e46cf13251.html#.E5.88.A0.E9.99.A4.E9.A1.B5.E9.9D.A2
|
78
|
+
#
|
79
|
+
# Return hash format if success:
|
80
|
+
# {
|
81
|
+
# data: {},
|
82
|
+
# errcode: 0,
|
83
|
+
# errmsg: 'success.'
|
84
|
+
# }
|
85
|
+
def self.destroy(access_token, page_id)
|
86
|
+
message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/page/delete?access_token=#{access_token}", { page_id: page_id.to_i }
|
87
|
+
message.body
|
88
|
+
end
|
89
|
+
|
90
|
+
# 编辑页面信息
|
91
|
+
# 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
|
92
|
+
#
|
93
|
+
# Return hash format if success:
|
94
|
+
# {
|
95
|
+
# data: {},
|
96
|
+
# errcode: 0,
|
97
|
+
# errmsg: 'success.'
|
98
|
+
# }
|
99
|
+
#
|
100
|
+
# title 在摇一摇页面展示的主标题,不超过6个汉字或12个英文字母。
|
101
|
+
# description 在摇一摇页面展示的副标题,不超过7个汉字或14个英文字母。
|
102
|
+
# comment 页面的备注信息,不超过15个汉字或30个英文字母。
|
103
|
+
# icon_link 在摇一摇页面展示的图片。图片需先上传至微信侧服务器,用“素材管理-上传图片素材”接口上传图片,返回的图片URL再配置在此处。
|
104
|
+
def self.update(access_token, page_id, title, description, comment, page_link, icon_link)
|
105
|
+
message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/page/update?access_token=#{access_token}",
|
106
|
+
{
|
107
|
+
page_id: page_id.to_i,
|
108
|
+
title: title,
|
109
|
+
description: description,
|
110
|
+
page_url: page_link,
|
111
|
+
comment: comment,
|
112
|
+
icon_url: icon_link
|
113
|
+
}
|
114
|
+
message.body
|
115
|
+
end
|
116
|
+
|
117
|
+
# 新增页面
|
118
|
+
# http://mp.weixin.qq.com/wiki/5/6626199ea8757c752046d8e46cf13251.html#.E6.96.B0.E5.A2.9E.E9.A1.B5.E9.9D.A2
|
119
|
+
#
|
120
|
+
# Return hash format if success:
|
121
|
+
# {
|
122
|
+
# data: { page_id: <PAGE_ID> },
|
123
|
+
# errcode: 0,
|
124
|
+
# errmsg: 'success.'
|
125
|
+
# }
|
126
|
+
#
|
127
|
+
# title 在摇一摇页面展示的主标题,不超过6个汉字或12个英文字母。
|
128
|
+
# description 在摇一摇页面展示的副标题,不超过7个汉字或14个英文字母。
|
129
|
+
# comment 页面的备注信息,不超过15个汉字或30个英文字母。
|
130
|
+
# icon_link 在摇一摇页面展示的图片。图片需先上传至微信侧服务器,用“素材管理-上传图片素材”接口上传图片,返回的图片URL再配置在此处。
|
131
|
+
def self.create(access_token, title, description, comment, page_link, icon_link)
|
132
|
+
message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/page/add?access_token=#{access_token}",
|
133
|
+
{
|
134
|
+
title: title,
|
135
|
+
description: description,
|
136
|
+
page_url: page_link,
|
137
|
+
comment: comment,
|
138
|
+
icon_url: icon_link
|
139
|
+
}
|
140
|
+
message.body
|
141
|
+
end
|
142
|
+
|
143
|
+
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
|
+
version: '0.3'
|
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-
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -88,10 +88,12 @@ files:
|
|
88
88
|
- bin/setup
|
89
89
|
- lib/wechat/shake_around.rb
|
90
90
|
- lib/wechat/shake_around/beacon.rb
|
91
|
+
- lib/wechat/shake_around/beacon_page_relation.rb
|
91
92
|
- lib/wechat/shake_around/common.rb
|
92
93
|
- lib/wechat/shake_around/icon.rb
|
93
94
|
- lib/wechat/shake_around/license.rb
|
94
95
|
- lib/wechat/shake_around/material.rb
|
96
|
+
- lib/wechat/shake_around/page.rb
|
95
97
|
- lib/wechat/shake_around/shaking.rb
|
96
98
|
- lib/wechat/shake_around/version.rb
|
97
99
|
- wechat-shake_around.gemspec
|