Class: Wechat::ShakeAround::BeaconPageRelation

Inherits:
Object
  • Object
show all
Extended by:
Common
Defined in:
lib/wechat/shake_around/beacon_page_relation.rb

Constant Summary

Constants included from Common

Common::ERROR_CODES

Class Method Summary collapse

Methods included from Common

normalize_date, normalize_device_id, normalize_page_ids

Class Method Details

.create(access_token, device_id, page_id) ⇒ Object

配置设备与页面的关联关系mp.weixin.qq.com/wiki/12/c8120214ec0ba08af5dfcc0da1a11400.html

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> }. page_id is an integer or an integer array. bind 关联操作标志位,0为解除关联关系,1为建立关联关系append 新增操作标志位,0为覆盖,1为新增



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/wechat/shake_around/beacon_page_relation.rb', line 21

def self.create(access_token, device_id, page_id)

  device_identifier = normalize_device_id device_id
  page_ids          = normalize_page_ids  page_id

  message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/device/bindpage?access_token=#{access_token}",
    {
      device_identifier: device_identifier,
      page_ids:          page_ids, 
      bind:              1,
      append:            1
    }
  message.body
end

.destroy(access_token, device_id, page_id) ⇒ Object

配置设备与页面的关联关系mp.weixin.qq.com/wiki/12/c8120214ec0ba08af5dfcc0da1a11400.html

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> }. page_id is an integer or an integer array. bind 关联操作标志位,0为解除关联关系,1为建立关联关系append 新增操作标志位,0为覆盖,1为新增



50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/wechat/shake_around/beacon_page_relation.rb', line 50

def self.destroy(access_token, device_id, page_id)

  device_identifier = normalize_device_id device_id
  page_ids          = normalize_page_ids  page_id

  message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/device/bindpage?access_token=#{access_token}",
    {
      device_identifier: device_identifier,
      page_ids:          page_ids, 
      bind:              0,
      append:            0
    }
  message.body
end