Class: Wechat::CorpApi
Constant Summary
Constants inherited
from ApiBase
ApiBase::API_BASE, ApiBase::DATACUBE_BASE, ApiBase::MP_BASE, ApiBase::OAUTH2_BASE, ApiBase::QYAPI_BASE, ApiBase::TCB_BASE, ApiBase::WXA_BASE
Instance Attribute Summary collapse
Attributes inherited from ApiBase
#access_token, #client, #jsapi_ticket, #qcloud
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
-
#checkin(useridlist, starttime = Time.now.beginning_of_day, endtime = Time.now.end_of_day, opencheckindatatype = 3) ⇒ Object
-
#convert_to_openid(userid) ⇒ Object
-
#convert_to_userid(openid) ⇒ Object
-
#custom_message_send(message) ⇒ Object
-
#department(departmentid = 1) ⇒ Object
-
#department_create(name, parentid) ⇒ Object
-
#department_delete(departmentid) ⇒ Object
-
#department_update(departmentid, name = nil, parentid = nil, order = nil) ⇒ Object
-
#get_externalcontact(external_userid, cursor = nil) ⇒ Object
-
#get_material(media_id) ⇒ Object
-
#getuserinfo(code) ⇒ Object
-
#initialize(appid, secret, token_file, agentid, network_setting, jsapi_ticket_file) ⇒ 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
-
#menu ⇒ Object
-
#menu_create(menu) ⇒ Object
-
#menu_delete ⇒ Object
-
#message_send(userid, message) ⇒ Object
-
#msgaudit_check_room_agree(roomid) ⇒ Object
-
#msgaudit_check_single_agree(info) ⇒ Object
-
#msgaudit_get_permit_user_list(type = nil) ⇒ Object
-
#msgaudit_groupchat(roomid) ⇒ Object
-
#news_message_send(userid, title, description, link_url, pic_url) ⇒ 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_batchdelete(useridlist) ⇒ Object
-
#user_create(user) ⇒ Object
-
#user_delete(userid) ⇒ Object
-
#user_list(department_id, fetch_child = 0, status = 0) ⇒ Object
-
#user_simplelist(department_id, fetch_child = 0, status = 0) ⇒ Object
Methods inherited from ApiBase
#callbackip, #clear_quota, #media, #media_create, #media_hq, #media_uploadimg, #media_uploadnews, #qrcode
Constructor Details
#initialize(appid, secret, token_file, agentid, network_setting, jsapi_ticket_file) ⇒ CorpApi
Returns a new instance of CorpApi.
7
8
9
10
11
12
13
14
|
# File 'lib/wechat/corp_api.rb', line 7
def initialize(appid, secret, token_file, agentid, network_setting, jsapi_ticket_file)
super()
@client = HttpClient.new(QYAPI_BASE, network_setting)
@access_token = Token::CorpAccessToken.new(@client, appid, secret, token_file)
@agentid = agentid
@jsapi_ticket = Ticket::CorpJsapiTicket.new(@client, @access_token, jsapi_ticket_file)
@qcloud = nil
end
|
Instance Attribute Details
#agentid ⇒ Object
Returns the value of attribute agentid.
5
6
7
|
# File 'lib/wechat/corp_api.rb', line 5
def agentid
@agentid
end
|
Instance Method Details
#agent(agentid) ⇒ Object
25
26
27
|
# File 'lib/wechat/corp_api.rb', line 25
def agent(agentid)
get 'agent/get', params: { agentid: agentid }
end
|
#agent_list ⇒ Object
21
22
23
|
# File 'lib/wechat/corp_api.rb', line 21
def agent_list
get 'agent/list'
end
|
#batch_job_result(jobid) ⇒ Object
74
75
76
|
# File 'lib/wechat/corp_api.rb', line 74
def batch_job_result(jobid)
get 'batch/getresult', params: { jobid: jobid }
end
|
#batch_replaceparty(media_id) ⇒ Object
78
79
80
|
# File 'lib/wechat/corp_api.rb', line 78
def batch_replaceparty(media_id)
post 'batch/replaceparty', JSON.generate(media_id: media_id)
end
|
#batch_replaceuser(media_id) ⇒ Object
86
87
88
|
# File 'lib/wechat/corp_api.rb', line 86
def batch_replaceuser(media_id)
post 'batch/replaceuser', JSON.generate(media_id: media_id)
end
|
#batch_syncuser(media_id) ⇒ Object
82
83
84
|
# File 'lib/wechat/corp_api.rb', line 82
def batch_syncuser(media_id)
post 'batch/syncuser', JSON.generate(media_id: media_id)
end
|
#checkin(useridlist, starttime = Time.now.beginning_of_day, endtime = Time.now.end_of_day, opencheckindatatype = 3) ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'lib/wechat/corp_api.rb', line 29
def checkin(useridlist, starttime = Time.now.beginning_of_day, endtime = Time.now.end_of_day, opencheckindatatype = 3)
post 'checkin/getcheckindata', JSON.generate(
opencheckindatatype: opencheckindatatype,
starttime: starttime.to_i,
endtime: endtime.to_i,
useridlist: useridlist
)
end
|
#convert_to_openid(userid) ⇒ Object
46
47
48
|
# File 'lib/wechat/corp_api.rb', line 46
def convert_to_openid(userid)
post 'user/convert_to_openid', JSON.generate(userid: userid, agentid: agentid)
end
|
#convert_to_userid(openid) ⇒ Object
50
51
52
|
# File 'lib/wechat/corp_api.rb', line 50
def convert_to_userid(openid)
post 'user/convert_to_userid', JSON.generate(openid: openid)
end
|
#custom_message_send(message) ⇒ Object
193
194
195
|
# File 'lib/wechat/corp_api.rb', line 193
def custom_message_send(message)
post 'message/send', message.is_a?(Wechat::Message) ? message.agent_id(agentid).to_json : JSON.generate(message.merge(agent_id: agentid)), content_type: :json
end
|
#department(departmentid = 1) ⇒ Object
102
103
104
|
# File 'lib/wechat/corp_api.rb', line 102
def department(departmentid = 1)
get 'department/list', params: { id: departmentid }
end
|
#department_create(name, parentid) ⇒ Object
90
91
92
|
# File 'lib/wechat/corp_api.rb', line 90
def department_create(name, parentid)
post 'department/create', JSON.generate(name: name, parentid: parentid)
end
|
#department_delete(departmentid) ⇒ Object
94
95
96
|
# File 'lib/wechat/corp_api.rb', line 94
def department_delete(departmentid)
get 'department/delete', params: { id: departmentid }
end
|
#department_update(departmentid, name = nil, parentid = nil, order = nil) ⇒ Object
98
99
100
|
# File 'lib/wechat/corp_api.rb', line 98
def department_update(departmentid, name = nil, parentid = nil, order = nil)
post 'department/update', JSON.generate({ id: departmentid, name: name, parentid: parentid, order: order }.compact)
end
|
16
17
18
19
|
# File 'lib/wechat/corp_api.rb', line 16
def get_externalcontact(external_userid, cursor = nil)
get 'externalcontact/get', params: { external_userid: external_userid, cursor: cursor }
end
|
#get_material(media_id) ⇒ Object
169
170
171
|
# File 'lib/wechat/corp_api.rb', line 169
def get_material(media_id)
post 'material/get_material', JSON.generate(media_id: media_id), params: { agentid: agentid }, as: :file
end
|
#getuserinfo(code) ⇒ Object
42
43
44
|
# File 'lib/wechat/corp_api.rb', line 42
def getuserinfo(code)
get 'user/getuserinfo', params: { code: code }
end
|
#invite_user(userid) ⇒ Object
54
55
56
|
# File 'lib/wechat/corp_api.rb', line 54
def invite_user(userid)
post 'invite/send', JSON.generate(userid: userid)
end
|
#material(media_id) ⇒ Object
163
164
165
166
167
|
# File 'lib/wechat/corp_api.rb', line 163
def material(media_id)
ActiveSupport::Deprecation.warn('material is deprecated. use get_material instead.')
post 'material/get_material', JSON.generate(media_id: media_id), params: { agentid: agentid }, as: :file
end
|
#material_add(type, file) ⇒ Object
173
174
175
|
# File 'lib/wechat/corp_api.rb', line 173
def material_add(type, file)
post_file 'material/add_material', file, params: { type: type, agentid: agentid }
end
|
#material_count ⇒ Object
155
156
157
|
# File 'lib/wechat/corp_api.rb', line 155
def material_count
get 'material/get_count', params: { agentid: agentid }
end
|
#material_delete(media_id) ⇒ Object
177
178
179
|
# File 'lib/wechat/corp_api.rb', line 177
def material_delete(media_id)
get 'material/del', params: { media_id: media_id, agentid: agentid }
end
|
#material_list(type, offset, count) ⇒ Object
159
160
161
|
# File 'lib/wechat/corp_api.rb', line 159
def material_list(type, offset, count)
post 'material/batchget', JSON.generate(type: type, agentid: agentid, offset: offset, count: count)
end
|
142
143
144
|
# File 'lib/wechat/corp_api.rb', line 142
def
get 'menu/get', params: { agentid: agentid }
end
|
150
151
152
153
|
# File 'lib/wechat/corp_api.rb', line 150
def ()
post 'menu/create', JSON.generate(), params: { agentid: agentid }
end
|
146
147
148
|
# File 'lib/wechat/corp_api.rb', line 146
def
get 'menu/delete', params: { agentid: agentid }
end
|
#message_send(userid, message) ⇒ Object
181
182
183
|
# File 'lib/wechat/corp_api.rb', line 181
def message_send(userid, message)
post 'message/send', Message.to(userid).text(message).agent_id(agentid).to_json, content_type: :json
end
|
#msgaudit_check_room_agree(roomid) ⇒ Object
205
206
207
|
# File 'lib/wechat/corp_api.rb', line 205
def msgaudit_check_room_agree(roomid)
post 'msgaudit/check_room_agree', JSON.generate(roomid: roomid)
end
|
#msgaudit_check_single_agree(info) ⇒ Object
201
202
203
|
# File 'lib/wechat/corp_api.rb', line 201
def msgaudit_check_single_agree(info)
post 'msgaudit/get_permit_user_list', JSON.generate(info: info)
end
|
#msgaudit_get_permit_user_list(type = nil) ⇒ Object
197
198
199
|
# File 'lib/wechat/corp_api.rb', line 197
def msgaudit_get_permit_user_list(type = nil)
post 'msgaudit/get_permit_user_list', JSON.generate(type: type)
end
|
#msgaudit_groupchat(roomid) ⇒ Object
209
210
211
|
# File 'lib/wechat/corp_api.rb', line 209
def msgaudit_groupchat(roomid)
post 'msgaudit/groupchat/get', JSON.generate(roomid: roomid)
end
|
#news_message_send(userid, title, description, link_url, pic_url) ⇒ Object
185
186
187
188
189
190
191
|
# File 'lib/wechat/corp_api.rb', line 185
def news_message_send(userid, title, description, link_url, pic_url)
post 'message/send', Message.to(userid).news([{ title: title,
description: description,
url: link_url,
pic_url: pic_url }])
.agent_id(agentid).to_json, content_type: :json
end
|
#tag(tagid) ⇒ Object
130
131
132
|
# File 'lib/wechat/corp_api.rb', line 130
def tag(tagid)
get 'tag/get', params: { tagid: tagid }
end
|
#tag_add_user(tagid, userids = nil, departmentids = nil) ⇒ Object
134
135
136
|
# File 'lib/wechat/corp_api.rb', line 134
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
114
115
116
|
# File 'lib/wechat/corp_api.rb', line 114
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
138
139
140
|
# File 'lib/wechat/corp_api.rb', line 138
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
122
123
124
|
# File 'lib/wechat/corp_api.rb', line 122
def tag_delete(tagid)
get 'tag/delete', params: { tagid: tagid }
end
|
#tag_update(tagid, tagname) ⇒ Object
118
119
120
|
# File 'lib/wechat/corp_api.rb', line 118
def tag_update(tagid, tagname)
post 'tag/update', JSON.generate(tagid: tagid, tagname: tagname)
end
|
126
127
128
|
# File 'lib/wechat/corp_api.rb', line 126
def tags
get 'tag/list'
end
|
#user(userid) ⇒ Object
38
39
40
|
# File 'lib/wechat/corp_api.rb', line 38
def user(userid)
get 'user/get', params: { userid: userid }
end
|
#user_auth_success(userid) ⇒ Object
58
59
60
|
# File 'lib/wechat/corp_api.rb', line 58
def user_auth_success(userid)
get 'user/authsucc', params: { userid: userid }
end
|
#user_batchdelete(useridlist) ⇒ Object
70
71
72
|
# File 'lib/wechat/corp_api.rb', line 70
def user_batchdelete(useridlist)
post 'user/batchdelete', JSON.generate(useridlist: useridlist)
end
|
#user_create(user) ⇒ Object
62
63
64
|
# File 'lib/wechat/corp_api.rb', line 62
def user_create(user)
post 'user/create', JSON.generate(user)
end
|
#user_delete(userid) ⇒ Object
66
67
68
|
# File 'lib/wechat/corp_api.rb', line 66
def user_delete(userid)
get 'user/delete', params: { userid: userid }
end
|
#user_list(department_id, fetch_child = 0, status = 0) ⇒ Object
110
111
112
|
# File 'lib/wechat/corp_api.rb', line 110
def user_list(department_id, fetch_child = 0, status = 0)
get 'user/list', params: { department_id: department_id, fetch_child: fetch_child, status: status }
end
|
#user_simplelist(department_id, fetch_child = 0, status = 0) ⇒ Object
106
107
108
|
# File 'lib/wechat/corp_api.rb', line 106
def user_simplelist(department_id, fetch_child = 0, status = 0)
get 'user/simplelist', params: { department_id: department_id, fetch_child: fetch_child, status: status }
end
|