wechat-shake_around 0.1
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 +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +1 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/ROADMAP.md +33 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/wechat/shake_around.rb +11 -0
- data/lib/wechat/shake_around/beacon.rb +102 -0
- data/lib/wechat/shake_around/common.rb +95 -0
- data/lib/wechat/shake_around/shaking.rb +37 -0
- data/lib/wechat/shake_around/version.rb +5 -0
- data/wechat-shake_around.gemspec +37 -0
- metadata +119 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: a84929a8b08a3c34a472632fe601fee42950a5ce
|
|
4
|
+
data.tar.gz: d31799a835be63812613c2282f26d3e262e58a2a
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3b0758a81a2cccf2cda1141a83e8be92b8c9028e4346f9cc780bb152123b955965573f158ef11611212aa2d44a6e1827b4daadc80f9b2ba97a6a42b99a5fd4ef
|
|
7
|
+
data.tar.gz: 15bc9254a1c540895a0e8ff48af85c6bf7ad3d587c12a47f36141c4e8b5a878673a4ea9c71c0845e0e9cff0958b75d8c456085c994e5bc645518655f292ae264
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Wechat Shake Around Change Log 微信摇周边库变更日志
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributor Code of Conduct
|
|
2
|
+
|
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
|
7
|
+
|
|
8
|
+
We are committed to making participation in this project a harassment-free
|
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
|
12
|
+
|
|
13
|
+
Examples of unacceptable behavior by participants include:
|
|
14
|
+
|
|
15
|
+
* The use of sexualized language or imagery
|
|
16
|
+
* Personal attacks
|
|
17
|
+
* Trolling or insulting/derogatory comments
|
|
18
|
+
* Public or private harassment
|
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
|
20
|
+
addresses, without explicit permission
|
|
21
|
+
* Other unethical or unprofessional conduct
|
|
22
|
+
|
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
27
|
+
threatening, offensive, or harmful.
|
|
28
|
+
|
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
|
32
|
+
Conduct may be permanently removed from the project team.
|
|
33
|
+
|
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
|
35
|
+
when an individual is representing the project or its community.
|
|
36
|
+
|
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
38
|
+
reported by contacting a project maintainer at topbit.du@gmail.com. All
|
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
|
42
|
+
incident.
|
|
43
|
+
|
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
45
|
+
version 1.3.0, available at
|
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
|
47
|
+
|
|
48
|
+
[homepage]: http://contributor-covenant.org
|
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Topbit Du
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Wechat Shake Around 微信摇周边库
|
|
2
|
+
|
|
3
|
+
[](http://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://badge.fury.io/rb/wechat-shake_around)
|
|
5
|
+
|
|
6
|
+
The Wechat Shake Around Library is a code base to call the Wechat Shake Around APIs.
|
|
7
|
+
微信摇周边库用于调用微信摇周边API。
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add this line to your application's Gemfile:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem 'wechat-shake_around'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
And then execute:
|
|
18
|
+
|
|
19
|
+
$ bundle
|
|
20
|
+
|
|
21
|
+
Or install it yourself as:
|
|
22
|
+
|
|
23
|
+
$ gem install wechat-shake_around
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
TODO: Write usage instructions here
|
|
28
|
+
|
|
29
|
+
## Development
|
|
30
|
+
|
|
31
|
+
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.
|
|
32
|
+
|
|
33
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
34
|
+
|
|
35
|
+
## Contributing
|
|
36
|
+
|
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/topbitdu/wechat-shake_around. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
43
|
+
|
data/ROADMAP.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Wechat Shake Around Road Map 微信摇周边库路线图
|
|
2
|
+
|
|
3
|
+
## v0.1
|
|
4
|
+
- Common module
|
|
5
|
+
- Beacon wrapper class
|
|
6
|
+
- Shaking wrapper class
|
|
7
|
+
|
|
8
|
+
## v0.2
|
|
9
|
+
- Material module
|
|
10
|
+
- Icon wrapper class
|
|
11
|
+
- License wrapper class
|
|
12
|
+
|
|
13
|
+
## v0.3
|
|
14
|
+
- Page wrapper class
|
|
15
|
+
- Beacon Page Relation wrapper class
|
|
16
|
+
|
|
17
|
+
## v0.4
|
|
18
|
+
- Page Report wrapper class
|
|
19
|
+
- Page Daily Report wrapper class
|
|
20
|
+
|
|
21
|
+
## v0.5
|
|
22
|
+
- Group wrapper class
|
|
23
|
+
- Device Group Relation wrapper class
|
|
24
|
+
|
|
25
|
+
## v0.6
|
|
26
|
+
- Device Report wrapper class
|
|
27
|
+
- Device Daily Report wrapper class
|
|
28
|
+
|
|
29
|
+
## v0.7
|
|
30
|
+
- Apply wrapper class
|
|
31
|
+
|
|
32
|
+
## v0.8
|
|
33
|
+
- Beacon PoI Relation wrapper class
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "wechat/shake_around"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
require 'jsonclient'
|
|
2
|
+
|
|
3
|
+
class Wechat::ShakeAround::Beacon
|
|
4
|
+
|
|
5
|
+
extend ::Wechat::ShakeAround::Common
|
|
6
|
+
|
|
7
|
+
# 查询设备列表
|
|
8
|
+
# 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
|
|
9
|
+
#
|
|
10
|
+
# Return hash format if success:
|
|
11
|
+
# {
|
|
12
|
+
# data:
|
|
13
|
+
# {
|
|
14
|
+
# devices:
|
|
15
|
+
# [
|
|
16
|
+
# {
|
|
17
|
+
# comment: '',
|
|
18
|
+
# device_id: <DEVICE_ID>,
|
|
19
|
+
# major: <MAJOR>,
|
|
20
|
+
# minor: <MINOR>,
|
|
21
|
+
# status: <STATUS>, // 激活状态,0:未激活,1:已激活
|
|
22
|
+
# last_active_time: <LAST_ACTIVE_TIME>, // 设备最近一次被摇到的日期(最早只能获取前一天的数据);新申请的设备该字段值为0
|
|
23
|
+
# poi_id: <POI_ID>, // 设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。门店相关信息具体可查看门店相关的接口文档
|
|
24
|
+
# uuid: <UUID>
|
|
25
|
+
# }
|
|
26
|
+
# ],
|
|
27
|
+
# total_count: <TOTAL_COUNT> // 商户名下的设备总量
|
|
28
|
+
# },
|
|
29
|
+
# errcode: 0,
|
|
30
|
+
# errmsg: 'success.'
|
|
31
|
+
# }
|
|
32
|
+
def self.index(access_token, offset, limit, apply_id = nil)
|
|
33
|
+
options = { begin: offset, count: limit }
|
|
34
|
+
if apply_id.present?
|
|
35
|
+
options[:apply_id] = apply_id
|
|
36
|
+
options[:type] = 3
|
|
37
|
+
else
|
|
38
|
+
options[:type] = 2
|
|
39
|
+
end
|
|
40
|
+
message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/device/search?access_token=#{access_token}", options
|
|
41
|
+
message.body
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# 查询设备列表
|
|
45
|
+
# 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
|
|
46
|
+
#
|
|
47
|
+
# Return hash format if success:
|
|
48
|
+
# {
|
|
49
|
+
# data:
|
|
50
|
+
# {
|
|
51
|
+
# devices:
|
|
52
|
+
# [
|
|
53
|
+
# {
|
|
54
|
+
# comment: '',
|
|
55
|
+
# device_id: <DEVICE_ID>,
|
|
56
|
+
# major: <MAJOR>,
|
|
57
|
+
# minor: <MINOR>,
|
|
58
|
+
# status: <STATUS>, // 激活状态,0:未激活,1:已激活
|
|
59
|
+
# last_active_time: <LAST_ACTIVE_TIME>, // 设备最近一次被摇到的日期(最早只能获取前一天的数据);新申请的设备该字段值为0
|
|
60
|
+
# poi_id: <POI_ID>, // 设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。门店相关信息具体可查看门店相关的接口文档
|
|
61
|
+
# uuid: <UUID>
|
|
62
|
+
# }
|
|
63
|
+
# ],
|
|
64
|
+
# total_count: <TOTAL_COUNT> // 商户名下的设备总量
|
|
65
|
+
# },
|
|
66
|
+
# errcode: 0,
|
|
67
|
+
# errmsg: 'success.'
|
|
68
|
+
# }
|
|
69
|
+
#
|
|
70
|
+
# device_id is an integer or a hash like { uuid: <UUID>, major: <MAJOR>, minor: <MINOR> }.
|
|
71
|
+
def self.load(access_token, device_id)
|
|
72
|
+
device_identifier = self.normalize_device_id device_id
|
|
73
|
+
message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/device/search?access_token=#{access_token}",
|
|
74
|
+
{
|
|
75
|
+
type: 1,
|
|
76
|
+
device_identifiers: [ device_identifier ]
|
|
77
|
+
}
|
|
78
|
+
message.body
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# 编辑设备信息
|
|
82
|
+
# 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
|
|
83
|
+
#
|
|
84
|
+
# Return hash format if success:
|
|
85
|
+
# {
|
|
86
|
+
# data: {},
|
|
87
|
+
# errcode: 0,
|
|
88
|
+
# errmsg: 'success.'
|
|
89
|
+
# }
|
|
90
|
+
#
|
|
91
|
+
# device_id is an integer or a hash like { uuid: <UUID>, major: <MAJOR>, minor: <MINOR> }.
|
|
92
|
+
def self.update(access_token, device_id, comment)
|
|
93
|
+
device_identifier = self.normalize_device_id device_id
|
|
94
|
+
message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/device/update?access_token=#{access_token}",
|
|
95
|
+
{
|
|
96
|
+
device_identifier: device_identifier,
|
|
97
|
+
comment: comment
|
|
98
|
+
}
|
|
99
|
+
message.body
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
module Wechat::ShakeAround::Common
|
|
2
|
+
|
|
3
|
+
# http://mp.weixin.qq.com/wiki/5/fe90761a540f6fe056c774ab3df8afe9.html
|
|
4
|
+
ERROR_CODES =
|
|
5
|
+
{
|
|
6
|
+
-1 => '系统繁忙,此时请开发者稍候再试',
|
|
7
|
+
0 => '请求成功',
|
|
8
|
+
9001001 => 'POST数据参数不合法',
|
|
9
|
+
9001002 => '远端服务不可用',
|
|
10
|
+
9001003 => 'Ticket不合法',
|
|
11
|
+
9001004 => '获取摇周边用户信息失败',
|
|
12
|
+
9001005 => '获取商户信息失败',
|
|
13
|
+
9001006 => '获取OpenID失败',
|
|
14
|
+
9001007 => '上传文件缺失',
|
|
15
|
+
9001008 => '上传素材的文件类型不合法',
|
|
16
|
+
9001009 => '上传素材的文件尺寸不合法',
|
|
17
|
+
9001010 => '上传失败',
|
|
18
|
+
9001020 => '帐号不合法',
|
|
19
|
+
9001022 => '设备申请数不合法,必须为大于0的数字',
|
|
20
|
+
9001023 => '已存在审核中的设备ID申请',
|
|
21
|
+
9001024 => '一次查询设备ID数量不能超过50',
|
|
22
|
+
9001025 => '设备ID不合法',
|
|
23
|
+
9001026 => '页面ID不合法',
|
|
24
|
+
9001027 => '页面参数不合法',
|
|
25
|
+
9001028 => '一次删除页面ID数量不能超过10',
|
|
26
|
+
9001029 => '页面已应用在设备中,请先解除应用关系再删除',
|
|
27
|
+
9001030 => '一次查询页面ID数量不能超过50',
|
|
28
|
+
9001031 => '时间区间不合法',
|
|
29
|
+
9001032 => '保存设备与页面的绑定关系参数错误',
|
|
30
|
+
9001033 => '门店ID不合法',
|
|
31
|
+
9001034 => '设备备注信息过长',
|
|
32
|
+
9001035 => '设备申请参数不合法',
|
|
33
|
+
9001036 => '查询起始值begin不合法',
|
|
34
|
+
9001037 => '单个设备绑定页面不能超过30个',
|
|
35
|
+
9001038 => '设备总数超过了限额',
|
|
36
|
+
9001039 => '不合法的联系人名字',
|
|
37
|
+
9001040 => '不合法的联系人电话',
|
|
38
|
+
9001041 => '不合法的联系人邮箱',
|
|
39
|
+
9001042 => '不合法的行业id',
|
|
40
|
+
9001043 => '不合法的资质证明文件url,文件需通过“素材管理”接口上传',
|
|
41
|
+
9001044 => '缺少资质证明文件',
|
|
42
|
+
9001045 => '申请理由不能超过500字',
|
|
43
|
+
9001046 => '公众账号未认证',
|
|
44
|
+
9001047 => '不合法的设备申请批次id',
|
|
45
|
+
9001048 => '审核状态为审核中或审核已通过,不能再提交申请请求',
|
|
46
|
+
9001049 => '获取分组元数据失败',
|
|
47
|
+
9001050 => '账号下分组数达到上限,最多为100个',
|
|
48
|
+
9001051 => '分组包含的设备数达到上限,最多为10000个',
|
|
49
|
+
9001052 => '每次添加到分组的设备数达到上限,每次最多操作1000个设备',
|
|
50
|
+
9001053 => '每次从分组删除的设备数达到上限,每次最多操作1000个设备',
|
|
51
|
+
9001054 => '待删除的分组仍存在设备',
|
|
52
|
+
9001055 => '分组名称过长,上限为100个字符',
|
|
53
|
+
9001056 => '分组待添加或删除的设备列表中包含有不属于该分组的设备id',
|
|
54
|
+
9001057 => '分组相关信息操作失败',
|
|
55
|
+
9001058 => '分组id不存在',
|
|
56
|
+
9001059 => '模板页面logo_url为空',
|
|
57
|
+
9001060 => '创建红包活动失败',
|
|
58
|
+
9001061 => '获得红包活动ID失败',
|
|
59
|
+
9001062 => '创建模板页面失败',
|
|
60
|
+
9001063 => '红包提供商户公众号ID和红包发放商户公众号ID不一致',
|
|
61
|
+
9001064 => '红包权限审核失败',
|
|
62
|
+
9001065 => '红包权限正在审核',
|
|
63
|
+
9001066 => '红包权限被取消',
|
|
64
|
+
9001067 => '没有红包权限',
|
|
65
|
+
9001068 => '红包活动时间不在红包权限有效时间内',
|
|
66
|
+
9001069 => '设置红包活动开关失败',
|
|
67
|
+
9001070 => '获得红包活动信息失败',
|
|
68
|
+
9001071 => '查询红包ticket失败',
|
|
69
|
+
9001072 => '红包ticket数量超过限制',
|
|
70
|
+
9001073 => 'sponsor_appid与预下单时的wxappid不一致',
|
|
71
|
+
9001074 => '获得红包发送ID失败',
|
|
72
|
+
9001075 => '录入活动的红包总数超过创建活动时预设的total',
|
|
73
|
+
9001076 => '添加红包发送ID失败',
|
|
74
|
+
9001077 => '解码红包发送ID失败',
|
|
75
|
+
9001078 => '获取公众号uin失败',
|
|
76
|
+
9001079 => '接口调用appid与调用创建活动接口的appid不一致',
|
|
77
|
+
9001090 => '录入的所有ticket都是无效ticket,可能原因为ticket重复使用,过期或金额不在1-1000元之间',
|
|
78
|
+
9001091 => '活动已过期'
|
|
79
|
+
}.freeze
|
|
80
|
+
|
|
81
|
+
def normalize_date(date)
|
|
82
|
+
date = Date.parse date if date.is_a? String
|
|
83
|
+
date.to_time.to_i
|
|
84
|
+
# date.to_datetime
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def normalize_device_id(device_id)
|
|
88
|
+
device_id.is_a?(Hash) ? device_id : { device_id: device_id.to_i }
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def normalize_page_ids(page_ids)
|
|
92
|
+
page_ids.is_a?(Array) ? page_ids.map { |i| i.to_i } : [ page_ids.to_i ]
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'jsonclient'
|
|
2
|
+
|
|
3
|
+
class Wechat::ShakeAround::Shaking
|
|
4
|
+
|
|
5
|
+
extend ::Wechat::ShakeAround::Common
|
|
6
|
+
|
|
7
|
+
# 获取摇周边的设备及用户信息
|
|
8
|
+
# http://mp.weixin.qq.com/wiki/3/34904a5db3d0ec7bb5306335b8da1faf.html
|
|
9
|
+
#
|
|
10
|
+
# Return hash format if success:
|
|
11
|
+
# {
|
|
12
|
+
# data:
|
|
13
|
+
# {
|
|
14
|
+
# page_id: <PAGE_ID>,
|
|
15
|
+
# openid: <OPEN_ID>,
|
|
16
|
+
# poi_id: <POI_ID>,
|
|
17
|
+
# beacon_info:
|
|
18
|
+
# {
|
|
19
|
+
# distance: <DISTANCE>,
|
|
20
|
+
# uuid: <UUID>,
|
|
21
|
+
# major: <MAJOR>,
|
|
22
|
+
# minor: <MINOR>
|
|
23
|
+
# }
|
|
24
|
+
# },
|
|
25
|
+
# errcode: 0,
|
|
26
|
+
# errmsg: 'success.'
|
|
27
|
+
# }
|
|
28
|
+
def self.load(access_token, ticket)
|
|
29
|
+
message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/user/getshakeinfo?access_token=#{access_token}",
|
|
30
|
+
{
|
|
31
|
+
ticket: ticket,
|
|
32
|
+
need_poi: 1
|
|
33
|
+
}
|
|
34
|
+
message.body
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'wechat/shake_around/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
|
|
8
|
+
spec.name = 'wechat-shake_around'
|
|
9
|
+
spec.version = Wechat::ShakeAround::VERSION
|
|
10
|
+
spec.authors = [ 'Topbit Du' ]
|
|
11
|
+
spec.email = [ 'topbit.du@gmail.com' ]
|
|
12
|
+
|
|
13
|
+
spec.summary = %q{Wechat Shake Around Library}
|
|
14
|
+
spec.description = %q{The Wechat Shake Around Library is a code base to handle the shaking around API calls.}
|
|
15
|
+
spec.homepage = 'https://github.com/topbitdu/wechat-shake_around'
|
|
16
|
+
spec.license = 'MIT'
|
|
17
|
+
|
|
18
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
|
19
|
+
# delete this section to allow pushing this gem to any host.
|
|
20
|
+
#if spec.respond_to?(:metadata)
|
|
21
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
|
22
|
+
#else
|
|
23
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
24
|
+
#end
|
|
25
|
+
|
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
27
|
+
spec.bindir = 'exe'
|
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
29
|
+
spec.require_paths = [ 'lib' ]
|
|
30
|
+
|
|
31
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
|
32
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
33
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
34
|
+
|
|
35
|
+
spec.add_dependency 'httpclient', '~> 2.7'
|
|
36
|
+
|
|
37
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: wechat-shake_around
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: '0.1'
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Topbit Du
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-02-15 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.11'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.11'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: httpclient
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '2.7'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '2.7'
|
|
69
|
+
description: The Wechat Shake Around Library is a code base to handle the shaking
|
|
70
|
+
around API calls.
|
|
71
|
+
email:
|
|
72
|
+
- topbit.du@gmail.com
|
|
73
|
+
executables: []
|
|
74
|
+
extensions: []
|
|
75
|
+
extra_rdoc_files: []
|
|
76
|
+
files:
|
|
77
|
+
- ".gitignore"
|
|
78
|
+
- ".rspec"
|
|
79
|
+
- ".travis.yml"
|
|
80
|
+
- CHANGELOG.md
|
|
81
|
+
- CODE_OF_CONDUCT.md
|
|
82
|
+
- Gemfile
|
|
83
|
+
- LICENSE.txt
|
|
84
|
+
- README.md
|
|
85
|
+
- ROADMAP.md
|
|
86
|
+
- Rakefile
|
|
87
|
+
- bin/console
|
|
88
|
+
- bin/setup
|
|
89
|
+
- lib/wechat/shake_around.rb
|
|
90
|
+
- lib/wechat/shake_around/beacon.rb
|
|
91
|
+
- lib/wechat/shake_around/common.rb
|
|
92
|
+
- lib/wechat/shake_around/shaking.rb
|
|
93
|
+
- lib/wechat/shake_around/version.rb
|
|
94
|
+
- wechat-shake_around.gemspec
|
|
95
|
+
homepage: https://github.com/topbitdu/wechat-shake_around
|
|
96
|
+
licenses:
|
|
97
|
+
- MIT
|
|
98
|
+
metadata: {}
|
|
99
|
+
post_install_message:
|
|
100
|
+
rdoc_options: []
|
|
101
|
+
require_paths:
|
|
102
|
+
- lib
|
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
|
+
requirements:
|
|
105
|
+
- - ">="
|
|
106
|
+
- !ruby/object:Gem::Version
|
|
107
|
+
version: '0'
|
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
|
+
requirements:
|
|
110
|
+
- - ">="
|
|
111
|
+
- !ruby/object:Gem::Version
|
|
112
|
+
version: '0'
|
|
113
|
+
requirements: []
|
|
114
|
+
rubyforge_project:
|
|
115
|
+
rubygems_version: 2.4.5.1
|
|
116
|
+
signing_key:
|
|
117
|
+
specification_version: 4
|
|
118
|
+
summary: Wechat Shake Around Library
|
|
119
|
+
test_files: []
|