From 8f2856780c9b998986afbd24d57ab491cd55077f Mon Sep 17 00:00:00 2001 From: lanrion Date: Thu, 14 May 2015 14:43:31 +0800 Subject: [PATCH] 管理企业号应用, 设置文件为UTF-8编码 --- README.md | 21 +++++++++++++++++++++ lib/qy_wechat_api/api/agent.rb | 27 +++++++++++++++++++++++++++ lib/qy_wechat_api/api/async_task.rb | 3 ++- lib/qy_wechat_api/api/auth_login.rb | 2 +- lib/qy_wechat_api/client.rb | 4 ++++ 5 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 lib/qy_wechat_api/api/agent.rb diff --git a/README.md b/README.md index 26ab182..78187f2 100644 --- a/README.md +++ b/README.md @@ -214,6 +214,27 @@ suite_api.auth_url(code, uri, state="suite") group_client.async_task.get_result(job_id) ``` +## 管理企业号应用 + +```ruby + # 获取应用概况列表 + group_client.agent.list + + # 设置企业号应用 + # agentid 企业应用的id + # report_location_flag 企业应用是否打开地理位置上报 0:不上报;1:进入会话上报;2:持续上报 + # logo_mediaid 企业应用头像的mediaid,通过多媒体接口上传图片获得mediaid,上传后会自动裁剪成方形和圆形两个头像 + # name 企业应用名称 + # description 企业应用详情 + # redirect_domain 企业应用可信域名 + # isreportuser 是否接收用户变更通知。0:不接收;1:接收 + # isreportenter 是否上报用户进入应用事件。0:不接收;1:接收 + group_client.agent.set() + + ## 获取企业号应用 + group_client.agent.get(agent_id) +``` + ### 应用套件的回调通知处理 Wiki: http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E6%96%B9%E5%9B%9E%E8%B0%83%E5%8D%8F%E8%AE%AE diff --git a/lib/qy_wechat_api/api/agent.rb b/lib/qy_wechat_api/api/agent.rb new file mode 100644 index 0000000..fa86f03 --- /dev/null +++ b/lib/qy_wechat_api/api/agent.rb @@ -0,0 +1,27 @@ +# encoding: utf-8 +# 管理企业号应用 +module QyWechatApi + module Api + class Agent < Base + + def set(info) + http_post("set", info) + end + + def get(agent_id) + http_get("get", agentid: agent_id) + end + + def list + http_get("list") + end + + end + + private + + def base_url + "/agent" + end + end +end diff --git a/lib/qy_wechat_api/api/async_task.rb b/lib/qy_wechat_api/api/async_task.rb index b31fb65..decf0c7 100644 --- a/lib/qy_wechat_api/api/async_task.rb +++ b/lib/qy_wechat_api/api/async_task.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 module QyWechatApi module Api class AsyncTask < Base @@ -26,7 +27,7 @@ module QyWechatApi # 获取异步任务结果 def get_result(job_id) - payload = {job_id: job_id} + payload = {jobid: job_id} http_post("getresult", payload) end diff --git a/lib/qy_wechat_api/api/auth_login.rb b/lib/qy_wechat_api/api/auth_login.rb index 84477ef..b7cc15b 100644 --- a/lib/qy_wechat_api/api/auth_login.rb +++ b/lib/qy_wechat_api/api/auth_login.rb @@ -1,5 +1,5 @@ -# 登录授权流程说明 # encoding: utf-8 +# 登录授权流程说明 module QyWechatApi module Api class AuthLogin < Base diff --git a/lib/qy_wechat_api/client.rb b/lib/qy_wechat_api/client.rb index 0ef78e5..8c7166d 100644 --- a/lib/qy_wechat_api/client.rb +++ b/lib/qy_wechat_api/client.rb @@ -71,6 +71,10 @@ module QyWechatApi Api::AsyncTask.new(get_access_token, corp_id) end + def agent + Api::Agent.new(get_access_token) + end + private def security_redis_key(key) -- libgit2 0.21.0