Commit 7c35cae8f56436c3583afd6604fcb9dc4de83536

Authored by Tao Huang
1 parent b7e5294e
Exists in master

Add message API

Showing 1 changed file with 26 additions and 3 deletions   Show diff stats
lib/dingtalk/api/message.rb
1 1 module Dingtalk
2 2 module Api
3 3 class Message < Base
4   - def send_with(params)
5   - http_post("send?access_token=#{access_token}", params)
  4 + def send(userid_list, msg)
  5 + http_post("asyncsend_v2?access_token=#{access_token}", {
  6 + agent_id: @corp.agent_id,
  7 + userid_list: userid_list,
  8 + msg: msg
  9 + })
  10 + end
  11 +
  12 + def send_to_departments(dept_id_list, msg)
  13 + http_post("asyncsend_v2?access_token=#{access_token}", {
  14 + agent_id: @corp.agent_id,
  15 + dept_id_list: dept_id_list,
  16 + msg: msg
  17 + })
  18 + end
  19 +
  20 + def send_to_all_users(msg)
  21 + if @corp.isv_mode?
  22 + raise 'ISV not supporting sending messages to all users'
  23 + end
  24 + http_post("asyncsend_v2?access_token=#{access_token}", {
  25 + agent_id: @corp.agent_id,
  26 + to_all_user: true,
  27 + msg: msg
  28 + })
6 29 end
7 30  
8 31 private
9 32 def base_url
10   - 'message'
  33 + 'topapi/message/corpconversation'
11 34 end
12 35 end
13 36 end
... ...