Class: Wechat::ShakeAround::Beacon
- Inherits:
-
Object
- Object
- Wechat::ShakeAround::Beacon
- Extended by:
- Core::Common, Common
- Defined in:
- lib/wechat/shake_around/beacon.rb
Overview
Beacon 是管理 iBeacon 设备的封装类。
Constant Summary
Constants included from Common
Class Method Summary collapse
- .index(access_token, offset, limit, apply_id: nil) ⇒ Object
- .load(access_token, device_id) ⇒ Object
- .update(access_token, device_id, comment) ⇒ Object
Methods included from Common
normalize_date, normalize_device_id, normalize_page_ids
Class Method Details
.index(access_token, offset, limit, apply_id: nil) ⇒ Object
Return hash format if success: {
data:
{
devices:
[
{
comment: '',
device_id: <DEVICE_ID>,
major: <MAJOR>,
minor: <MINOR>,
status: <STATUS>, // 激活状态,0:未激活,1:已激活
last_active_time: <LAST_ACTIVE_TIME>, // 设备最近一次被摇到的日期(最早只能获取前一天的数据);新申请的设备该字段值为0
poi_id: <POI_ID>, // 设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。门店相关信息具体可查看门店相关的接口文档
uuid: <UUID>
}
],
total_count: <TOTAL_COUNT> // 商户名下的设备总量
},
errcode: 0,
errmsg: 'success.'
}
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/wechat/shake_around/beacon.rb', line 35 def self.index(access_token, offset, limit, apply_id: nil) assert_present! :access_token, access_token assert_present! :offset, offset assert_present! :limit, limit = { begin: offset, count: limit } if apply_id.present? [:apply_id] = apply_id [:type] = 3 else [:type] = 2 end post_json "https://api.weixin.qq.com/shakearound/device/search?access_token=#{access_token}", body: end |
.load(access_token, device_id) ⇒ Object
Return hash format if success: {
data:
{
devices:
[
{
comment: '',
device_id: <DEVICE_ID>,
major: <MAJOR>,
minor: <MINOR>,
status: <STATUS>, // 激活状态,0:未激活,1:已激活
last_active_time: <LAST_ACTIVE_TIME>, // 设备最近一次被摇到的日期(最早只能获取前一天的数据);新申请的设备该字段值为0
poi_id: <POI_ID>, // 设备关联的门店ID,关联门店后,在门店1KM的范围内有优先摇出信息的机会。门店相关信息具体可查看门店相关的接口文档
uuid: <UUID>
}
],
total_count: <TOTAL_COUNT> // 商户名下的设备总量
},
errcode: 0,
errmsg: 'success.'
}
device_id is an integer or a hash like { uuid: <UUID>, major: <MAJOR>, minor: <MINOR> }.
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/wechat/shake_around/beacon.rb', line 79 def self.load(access_token, device_id) assert_present! :access_token, access_token assert_present! :device_id, device_id device_identifier = self.normalize_device_id device_id post_json "https://api.weixin.qq.com/shakearound/device/search?access_token=#{access_token}", body: { type: 1, device_identifiers: [ device_identifier ] } end |
.update(access_token, device_id, comment) ⇒ Object
Return hash format if success:
data: {,
errcode: 0,
errmsg: 'success.'
}
device_id is an integer or a hash like { uuid: <UUID>, major: <MAJOR>, minor: <MINOR> }.
104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/wechat/shake_around/beacon.rb', line 104 def self.update(access_token, device_id, comment) assert_present! :access_token, access_token assert_present! :device_id, device_id assert_present! :comment, comment device_identifier = self.normalize_device_id device_id post_json "https://api.weixin.qq.com/shakearound/device/update?access_token=#{access_token}", body: { device_identifier: device_identifier, comment: comment } end |