Class: Wechat::ShakeAround::BeaconPageRelation

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

Overview

Beacon Page Relation 是管理 iBeacon 设备和页面之间关系的封装类。

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为新增



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/wechat/shake_around/beacon_page_relation.rb', line 57

def self.create(access_token, device_id, page_id)

  assert_present! :access_token, access_token
  assert_present! :device_id,    device_id
  assert_present! :page_id,      page_id

  device_identifier = normalize_device_id device_id
  page_ids          = normalize_page_ids  page_id

  post_json "https://api.weixin.qq.com/shakearound/device/bindpage?access_token=#{access_token}", body:
    {
      device_identifier: device_identifier,
      page_ids:          page_ids,
      bind:              1,
      append:            1
    }
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为新增



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/wechat/shake_around/beacon_page_relation.rb', line 24

def self.destroy(access_token, device_id, page_id)

  assert_present! :access_token, access_token
  assert_present! :device_id,    device_id
  assert_present! :page_id,      page_id

  device_identifier = normalize_device_id device_id
  page_ids          = normalize_page_ids  page_id

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