View Source WeChat.Work.Agent (wechat v0.15.1)

应用

Summary

Types

每个应用都有唯一的 agentid - 官方文档

secret 是企业应用里面用于保障数据安全的“钥匙” - 官方文档

t()

应用配置

Types

@type agent_flag() :: agent_id() | agent_name()
@type agent_id() :: integer() | atom()

每个应用都有唯一的 agentid - 官方文档

在管理后台->“应用与小程序”->“应用”,点进某个应用,即可看到 agentid

@type agent_name() :: atom() | String.t()
@type options() :: Keyword.t()
@type refresh_key() :: :js_api_ticket | :agent_js_api_ticket
@type refresh_list() :: [refresh_key()]
@type secret() :: String.t()

secret 是企业应用里面用于保障数据安全的“钥匙” - 官方文档

每一个应用都有一个独立的访问密钥,为了保证数据的安全,secret务必不能泄漏。 目前 secret 有:

  • 自建应用 secret 在管理后台->“应用与小程序”->“应用”->“自建”,点进某个应用,即可看到。
  • 基础应用 secret 某些基础应用(如“审批”“打卡”应用),支持通过API进行操作。在管理后台->“应用与小程序”->“应用->”“基础”,点进某个应用,点开“API”小按钮,即可看到。
  • 通讯录管理 secret 在“管理工具”-“通讯录同步”里面查看(需开启“API接口同步”);
  • 客户联系管理 secret 在“客户联系”栏,点开“API”小按钮,即可看到。
@type t() :: %WeChat.Work.Agent{
  aes_key: WeChat.ServerMessage.Encryptor.aes_key(),
  cache_id: WeChat.Storage.Cache.cache_id(),
  encoding_aes_key: WeChat.ServerMessage.Encryptor.encoding_aes_key(),
  id: agent_id(),
  name: agent_name(),
  refresh_list: [],
  secret: secret(),
  token: WeChat.token()
}

应用配置

Functions

@spec agent2id(WeChat.Work.client(), WeChat.Work.agent()) :: agent_id() | nil
Link to this function

agent(id, options \\ [])

View Source
@spec agent(agent_id(), options()) :: t()

构建应用(agent)

Link to this function

append_agent(client, agent)

View Source
Link to this function

contacts_agent(options \\ [])

View Source
@spec contacts_agent(options()) :: t()

构建[通讯录]应用(agent)

Link to this function

customer_agent(options \\ [])

View Source
@spec customer_agent(options()) :: t()

构建[客户联系]应用(agent)

Link to this function

fetch_agent!(client, agent)

View Source
@spec fetch_agent!(WeChat.Work.client(), WeChat.Work.agent()) :: t()
Link to this function

fetch_agent_cache_id!(client, agent)

View Source
@spec fetch_agent_cache_id!(WeChat.Work.client(), WeChat.Work.agent()) ::
  WeChat.Storage.Cache.cache_id()
@spec find_agent(WeChat.Work.client(), WeChat.Work.agent()) :: t() | nil
Link to this function

find_by_agent_string(client, agent_str)

View Source
@spec find_by_agent_string(WeChat.Work.client(), agent :: String.t()) :: t() | nil
@spec kf_agent(options()) :: t()

构建[微信客服]应用(agent)

Link to this function

maybe_init_work_agents(client)

View Source
@spec name2id(WeChat.Work.client(), agent_name()) :: agent_id() | nil