Class: Xiaomi::Push::Services::User

Inherits:
Object
  • Object
show all
Defined in:
lib/xiaomi/push/services/user.rb

Overview

用户查询类 API

比如查找用户设置的 Alias 和 Topic 等

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ User

初始化

Parameters:



14
15
16
# File 'lib/xiaomi/push/services/user.rb', line 14

def initialize(context)
  @context = context
end

Instance Attribute Details

#contextClient

Returns the current value of context.

Returns:

  • (Client)

    the current value of context



8
9
10
# File 'lib/xiaomi/push/services/user.rb', line 8

def context
  @context
end

Instance Method Details

#aliases(reg_id, package_name = nil) ⇒ Hash

根据 reg id 查找绑定的别名(aliases)

一个 reg id 可以绑定多个 alias

Parameters:

  • reg_id (String)
  • package_name (String) (defaults to: nil)

Returns:

  • (Hash)

    小米返回数据结构



31
32
33
34
# File 'lib/xiaomi/push/services/user.rb', line 31

def aliases(reg_id, package_name = nil)
  url = @context.build_uri('alias/all')
  @context.get(url, reg_params(reg_id, package_name))
end

#topices(reg_id, package_name = nil) ⇒ Hash

根据 reg id 查找设置的标签(Topics)

一个 reg id 可以绑定多个 topic

Parameters:

  • reg_id (String)
  • package_name (String) (defaults to: nil)

Returns:

  • (Hash)

    小米返回数据结构



43
44
45
46
# File 'lib/xiaomi/push/services/user.rb', line 43

def topices(reg_id, package_name = nil)
  url = @context.build_uri('topic/all')
  @context.get(url, reg_params(reg_id, package_name))
end