Class: Wechat::CorpApi
Constant Summary collapse
- API_BASE =
'https://qyapi.weixin.qq.com/cgi-bin/'
Constants inherited from ApiBase
Instance Attribute Summary collapse
-
#agentid ⇒ Object
readonly
Returns the value of attribute agentid.
Attributes inherited from ApiBase
Instance Method Summary collapse
- #agent(agentid) ⇒ Object
- #agent_list ⇒ Object
- #batch_job_result(jobid) ⇒ Object
- #batch_replaceparty(media_id) ⇒ Object
- #batch_replaceuser(media_id) ⇒ Object
- #batch_syncuser(media_id) ⇒ Object
- #department(departmentid = 1) ⇒ Object
- #department_create(name, parentid) ⇒ Object
- #department_delete(departmentid) ⇒ Object
-
#initialize(appid, secret, token_file, agentid, skip_verify_ssl) ⇒ CorpApi
constructor
A new instance of CorpApi.
- #invite_user(userid) ⇒ Object
- #material(media_id) ⇒ Object
- #material_add(type, file) ⇒ Object
- #material_count ⇒ Object
- #material_delete(media_id) ⇒ Object
- #material_list(type, offset, count) ⇒ Object
- #media(media_id) ⇒ Object
- #media_create(type, file) ⇒ Object
- #menu ⇒ Object
- #menu_create(menu) ⇒ Object
- #menu_delete ⇒ Object
- #message_send(openid, message) ⇒ Object
- #tag(tagid) ⇒ Object
- #tag_add_user(tagid, userids = nil, departmentids = nil) ⇒ Object
- #tag_create(tagname, tagid = nil) ⇒ Object
- #tag_del_user(tagid, userids = nil, departmentids = nil) ⇒ Object
- #tag_delete(tagid) ⇒ Object
- #tag_update(tagid, tagname) ⇒ Object
- #tags ⇒ Object
- #user(userid) ⇒ Object
- #user_auth_success(userid) ⇒ Object
- #user_delete(userid) ⇒ Object
- #user_list(departmentid, fetch_child = 0, status = 0) ⇒ Object
- #user_simplelist(departmentid, fetch_child = 0, status = 0) ⇒ Object
Methods inherited from ApiBase
Constructor Details
#initialize(appid, secret, token_file, agentid, skip_verify_ssl) ⇒ CorpApi
Returns a new instance of CorpApi.
20 21 22 23 24 |
# File 'lib/wechat/corp_api.rb', line 20 def initialize(appid, secret, token_file, agentid, skip_verify_ssl) @client = Client.new(API_BASE, skip_verify_ssl) @access_token = CorpAccessToken.new(@client, appid, secret, token_file) @agentid = agentid end |
Instance Attribute Details
#agentid ⇒ Object (readonly)
Returns the value of attribute agentid.
16 17 18 |
# File 'lib/wechat/corp_api.rb', line 16 def agentid @agentid end |
Instance Method Details
#agent(agentid) ⇒ Object
30 31 32 |
# File 'lib/wechat/corp_api.rb', line 30 def agent(agentid) get 'agent/get', params: { agentid: agentid } end |
#agent_list ⇒ Object
26 27 28 |
# File 'lib/wechat/corp_api.rb', line 26 def agent_list get 'agent/list' end |
#batch_job_result(jobid) ⇒ Object
50 51 52 |
# File 'lib/wechat/corp_api.rb', line 50 def batch_job_result(jobid) get 'batch/getresult', params: { jobid: jobid } end |
#batch_replaceparty(media_id) ⇒ Object
54 55 56 |
# File 'lib/wechat/corp_api.rb', line 54 def batch_replaceparty(media_id) post 'batch/replaceparty', JSON.generate(media_id: media_id) end |
#batch_replaceuser(media_id) ⇒ Object
62 63 64 |
# File 'lib/wechat/corp_api.rb', line 62 def batch_replaceuser(media_id) post 'batch/replaceuser', JSON.generate(media_id: media_id) end |
#batch_syncuser(media_id) ⇒ Object
58 59 60 |
# File 'lib/wechat/corp_api.rb', line 58 def batch_syncuser(media_id) post 'batch/syncuser', JSON.generate(media_id: media_id) end |
#department(departmentid = 1) ⇒ Object
74 75 76 |
# File 'lib/wechat/corp_api.rb', line 74 def department(departmentid = 1) get 'department/list', params: { id: departmentid } end |
#department_create(name, parentid) ⇒ Object
66 67 68 |
# File 'lib/wechat/corp_api.rb', line 66 def department_create(name, parentid) post 'department/create', JSON.generate(name: name, parentid: parentid) end |
#department_delete(departmentid) ⇒ Object
70 71 72 |
# File 'lib/wechat/corp_api.rb', line 70 def department_delete(departmentid) get 'department/delete', params: { id: departmentid } end |
#invite_user(userid) ⇒ Object
38 39 40 |
# File 'lib/wechat/corp_api.rb', line 38 def invite_user(userid) post 'invite/send', JSON.generate(userid: userid) end |
#material(media_id) ⇒ Object
143 144 145 |
# File 'lib/wechat/corp_api.rb', line 143 def material(media_id) get 'material/get', params: { media_id: media_id, agentid: agentid }, as: :file end |
#material_add(type, file) ⇒ Object
147 148 149 |
# File 'lib/wechat/corp_api.rb', line 147 def material_add(type, file) post 'material/add_material', { upload: { media: file } }, params: { type: type, agentid: agentid } end |
#material_count ⇒ Object
131 132 133 |
# File 'lib/wechat/corp_api.rb', line 131 def material_count get 'material/get_count', params: { agentid: agentid } end |
#material_delete(media_id) ⇒ Object
151 152 153 |
# File 'lib/wechat/corp_api.rb', line 151 def material_delete(media_id) get 'material/del', params: { media_id: media_id, agentid: agentid } end |
#material_list(type, offset, count) ⇒ Object
135 136 137 |
# File 'lib/wechat/corp_api.rb', line 135 def material_list(type, offset, count) post 'material/batchget', JSON.generate(type: type, agentid: agentid, offset: offset, count: count) end |
#media(media_id) ⇒ Object
127 128 129 |
# File 'lib/wechat/corp_api.rb', line 127 def media(media_id) get 'media/get', params: { media_id: media_id }, as: :file end |
#media_create(type, file) ⇒ Object
139 140 141 |
# File 'lib/wechat/corp_api.rb', line 139 def media_create(type, file) post 'media/upload', { upload: { media: file } }, params: { type: type } end |
#menu ⇒ Object
114 115 116 |
# File 'lib/wechat/corp_api.rb', line 114 def get 'menu/get', params: { agentid: agentid } end |
#menu_create(menu) ⇒ Object
122 123 124 125 |
# File 'lib/wechat/corp_api.rb', line 122 def () # 微信不接受7bit escaped json(eg \uxxxx), 中文必须UTF-8编码, 这可能是个安全漏洞 post 'menu/create', JSON.generate(), params: { agentid: agentid } end |
#menu_delete ⇒ Object
118 119 120 |
# File 'lib/wechat/corp_api.rb', line 118 def get 'menu/delete', params: { agentid: agentid } end |
#message_send(openid, message) ⇒ Object
155 156 157 |
# File 'lib/wechat/corp_api.rb', line 155 def (openid, ) post 'message/send', Message.to(openid).text().agent_id(agentid).to_json, content_type: :json end |
#tag(tagid) ⇒ Object
102 103 104 |
# File 'lib/wechat/corp_api.rb', line 102 def tag(tagid) get 'tag/get', params: { tagid: tagid } end |
#tag_add_user(tagid, userids = nil, departmentids = nil) ⇒ Object
106 107 108 |
# File 'lib/wechat/corp_api.rb', line 106 def tag_add_user(tagid, userids = nil, departmentids = nil) post 'tag/addtagusers', JSON.generate(tagid: tagid, userlist: userids, partylist: departmentids) end |
#tag_create(tagname, tagid = nil) ⇒ Object
86 87 88 |
# File 'lib/wechat/corp_api.rb', line 86 def tag_create(tagname, tagid = nil) post 'tag/create', JSON.generate(tagname: tagname, tagid: tagid) end |
#tag_del_user(tagid, userids = nil, departmentids = nil) ⇒ Object
110 111 112 |
# File 'lib/wechat/corp_api.rb', line 110 def tag_del_user(tagid, userids = nil, departmentids = nil) post 'tag/deltagusers', JSON.generate(tagid: tagid, userlist: userids, partylist: departmentids) end |
#tag_delete(tagid) ⇒ Object
94 95 96 |
# File 'lib/wechat/corp_api.rb', line 94 def tag_delete(tagid) get 'tag/delete', params: { tagid: tagid } end |
#tag_update(tagid, tagname) ⇒ Object
90 91 92 |
# File 'lib/wechat/corp_api.rb', line 90 def tag_update(tagid, tagname) post 'tag/update', JSON.generate(tagid: tagid, tagname: tagname) end |
#tags ⇒ Object
98 99 100 |
# File 'lib/wechat/corp_api.rb', line 98 def get 'tag/list' end |
#user(userid) ⇒ Object
34 35 36 |
# File 'lib/wechat/corp_api.rb', line 34 def user(userid) get 'user/get', params: { userid: userid } end |
#user_auth_success(userid) ⇒ Object
42 43 44 |
# File 'lib/wechat/corp_api.rb', line 42 def user_auth_success(userid) get 'user/authsucc', params: { userid: userid } end |
#user_delete(userid) ⇒ Object
46 47 48 |
# File 'lib/wechat/corp_api.rb', line 46 def user_delete(userid) get 'user/delete', params: { userid: userid } end |
#user_list(departmentid, fetch_child = 0, status = 0) ⇒ Object
82 83 84 |
# File 'lib/wechat/corp_api.rb', line 82 def user_list(departmentid, fetch_child = 0, status = 0) get 'user/list', params: { departmentid: departmentid, fetch_child: fetch_child, status: status } end |
#user_simplelist(departmentid, fetch_child = 0, status = 0) ⇒ Object
78 79 80 |
# File 'lib/wechat/corp_api.rb', line 78 def user_simplelist(departmentid, fetch_child = 0, status = 0) get 'user/simplelist', params: { departmentid: departmentid, fetch_child: fetch_child, status: status } end |