Module: Jingubang::Weixin::Qiye::Account::SendMessage

Included in:
Jingubang::Weixin::Qiye::Account
Defined in:
lib/jingubang/weixin/qiye/account/send_message.rb

Instance Method Summary collapse

Instance Method Details

#send_news_message(departmentids: [], userids: [], title: nil, description: nil, url: nil, button_text: '详情', image_url: nil) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/jingubang/weixin/qiye/account/send_message.rb', line 35

def send_news_message departmentids: [], userids: [], title: nil, description: nil, url: nil, button_text: '详情', image_url: nil
  path = "/cgi-bin/message/send?access_token=#{refreshed_access_token}"
  body = {
    touser: ids_param(userids),
    toparty: ids_param(departmentids),
    msgtype: 'news',
    agentid: agentid,
    news: {
      articles: [{
        title: title,
        description: description,
        url: url,
        picurl: image_url,
        btntxt: button_text
      }]
    }
  }
  response = fire_request path, body
end

#send_text_card_message(departmentids: [], userids: [], title: nil, description: nil, url: nil, button_text: '详情') ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/jingubang/weixin/qiye/account/send_message.rb', line 18

def send_text_card_message departmentids: [], userids: [], title: nil, description: nil, url: nil, button_text: '详情'
  path = "/cgi-bin/message/send?access_token=#{refreshed_access_token}"
  body = {
    touser: ids_param(userids),
    toparty: ids_param(departmentids),
    msgtype: 'textcard',
    agentid: agentid,
    textcard: {
      title: title,
      description: description,
      url: url,
      btntxt: button_text
    }
  }
  response = fire_request path, body
end

#send_text_message(departmentids: [], userids: [], content: nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/jingubang/weixin/qiye/account/send_message.rb', line 4

def send_text_message departmentids: [], userids: [], content: nil
  path = "/cgi-bin/message/send?access_token=#{refreshed_access_token}"
  body = {
    touser: ids_param(userids),
    toparty: ids_param(departmentids),
    msgtype: 'text',
    agentid: agentid,
    text: {
      content: content
    }
  }
  response = fire_request path, body
end