Class: Wework::Api::Agent
- Inherits:
-
Base
- Object
- Base
- Wework::Api::Agent
show all
- Defined in:
- lib/wework/api/agent.rb
Instance Attribute Summary
Attributes inherited from Base
#agent_secret, #corp_id, #options
Instance Method Summary
collapse
-
#agent_id ⇒ Object
-
#file_message_send(user_ids, department_ids, media_id) ⇒ Object
-
#get_info ⇒ Object
user agent: UA is mozilla/5.0 (iphone; cpu iphone os 10_2 like mac os x) applewebkit/602.3.12 (khtml, like gecko) mobile/14c92 wxwork/1.3.2 micromessenger/6.2.
-
#image_message_send(user_ids, department_ids, media_id) ⇒ Object
-
#media_get(media_id) ⇒ Object
-
#media_upload(type, file) ⇒ Object
-
#menu_create(menu) ⇒ Object
-
#menu_delete ⇒ Object
-
#message_send(user_ids, department_ids, payload = {}) ⇒ Object
-
#news_message_send(user_ids, department_ids, news = []) ⇒ Object
-
#set_info(data = {}) ⇒ Object
-
#text_message_send(user_ids, department_ids, content) ⇒ Object
-
#textcard_message_send(user_ids, department_ids, title, description, url, btntxt = '详情') ⇒ Object
-
#video_message_send(user_ids, department_ids, media_id, title = '', description = '') ⇒ Object
-
#voice_message_send(user_ids, department_ids, media_id) ⇒ Object
Methods inherited from Base
#get, #initialize, #post, #post_file, #request, #token_store, #with_access_token
Instance Method Details
#agent_id ⇒ Object
65
66
67
|
# File 'lib/wework/api/agent.rb', line 65
def agent_id
@agent_id.to_i
end
|
#file_message_send(user_ids, department_ids, media_id) ⇒ Object
49
50
51
|
# File 'lib/wework/api/agent.rb', line 49
def file_message_send user_ids, department_ids, media_id
message_send user_ids, department_ids, {file: {media_id: media_id}, msgtype: 'file'}
end
|
#get_info ⇒ Object
user agent: UA is mozilla/5.0 (iphone; cpu iphone os 10_2 like mac os x) applewebkit/602.3.12 (khtml, like gecko) mobile/14c92 wxwork/1.3.2 micromessenger/6.2
6
7
8
|
# File 'lib/wework/api/agent.rb', line 6
def get_info
get 'agent/get', params: {agentid: agent_id}
end
|
#image_message_send(user_ids, department_ids, media_id) ⇒ Object
41
42
43
|
# File 'lib/wework/api/agent.rb', line 41
def image_message_send user_ids, department_ids, media_id
message_send user_ids, department_ids, {image: {media_id: media_id}, msgtype: 'image'}
end
|
26
27
28
|
# File 'lib/wework/api/agent.rb', line 26
def media_get(media_id)
get 'media/get', params: { media_id: media_id }, as: :file
end
|
22
23
24
|
# File 'lib/wework/api/agent.rb', line 22
def media_upload type, file
post_file 'media/upload', file, params: { type: type }
end
|
14
15
16
|
# File 'lib/wework/api/agent.rb', line 14
def
post 'menu/create', , params: {agentid: agent_id}
end
|
18
19
20
|
# File 'lib/wework/api/agent.rb', line 18
def
get 'menu/delete', params: {agentid: agent_id}
end
|
#message_send(user_ids, department_ids, payload = {}) ⇒ Object
30
31
32
33
34
35
|
# File 'lib/wework/api/agent.rb', line 30
def message_send user_ids, department_ids, payload={}
payload[:agentid] = agent_id
payload[:touser] = Array.wrap(user_ids).join('|') if user_ids.present?
payload[:toparty] = Array.wrap(department_ids).join('|') if department_ids.present?
post 'message/send', payload
end
|
#news_message_send(user_ids, department_ids, news = []) ⇒ Object
61
62
63
|
# File 'lib/wework/api/agent.rb', line 61
def news_message_send user_ids, department_ids, news=[]
message_send user_ids, department_ids, {news: {articles: news}, msgtype: 'news'}
end
|
#set_info(data = {}) ⇒ Object
10
11
12
|
# File 'lib/wework/api/agent.rb', line 10
def set_info data={}
post 'agent/set', data.merge(agentid: agent_id)
end
|
#text_message_send(user_ids, department_ids, content) ⇒ Object
37
38
39
|
# File 'lib/wework/api/agent.rb', line 37
def text_message_send user_ids, department_ids, content
message_send user_ids, department_ids, {text: {content: content}, msgtype: 'text'}
end
|
#textcard_message_send(user_ids, department_ids, title, description, url, btntxt = '详情') ⇒ Object
57
58
59
|
# File 'lib/wework/api/agent.rb', line 57
def textcard_message_send user_ids, department_ids, title, description, url, btntxt='详情'
message_send user_ids, department_ids, {textcard: {title: title, description: description, url: url, btntxt: btntxt}, msgtype: 'textcard'}
end
|
#video_message_send(user_ids, department_ids, media_id, title = '', description = '') ⇒ Object
53
54
55
|
# File 'lib/wework/api/agent.rb', line 53
def video_message_send user_ids, department_ids, media_id, title='', description=''
message_send user_ids, department_ids, {video: {media_id: media_id, title: 'title', description: description}, msgtype: 'video'}
end
|
#voice_message_send(user_ids, department_ids, media_id) ⇒ Object
45
46
47
|
# File 'lib/wework/api/agent.rb', line 45
def voice_message_send user_ids, department_ids, media_id
message_send user_ids, department_ids, {voice: {media_id: media_id}, msgtype: 'voice'}
end
|