Module: WxExt::Api::TemplateMsg

Extended by:
TemplateMsg
Included in:
TemplateMsg
Defined in:
lib/wx_ext/api/template_msg.rb

Overview

User api of weixin.

Author:

  • FuShengYang

Instance Method Summary collapse

Instance Method Details

#get_template_id(access_token, template_id_short) ⇒ Hash

Get the template ID via post.

Parameters:

  • access_token (Enumerable<String>)
  • template_id_short (Enumerable<String>)

Returns:

  • (Hash)

    Json based hash.



31
32
33
34
35
# File 'lib/wx_ext/api/template_msg.rb', line 31

def get_template_id(access_token, template_id_short)
  url = 'https://api.weixin.qq.com/cgi-bin/template/api_add_template'\
        "?access_token=#{access_token}"
  Helper.http_post(url, { template_id_short: template_id_short })
end

#send_template_msg(access_token, template_msg_hash) ⇒ Hash

Send the template msg via post.

Parameters:

  • access_token (Enumerable<String>)
  • template_msg_hash (Hash)

Returns:

  • (Hash)

    Json based hash.



42
43
44
45
46
# File 'lib/wx_ext/api/template_msg.rb', line 42

def send_template_msg(access_token, template_msg_hash)
  url = 'https://api.weixin.qq.com/cgi-bin/message/template/send'\
        "?access_token=#{access_token}"
  Helper.http_post(url, template_msg_hash.to_json)
end

#set_industry(access_token, industry_id1, industry_id2) ⇒ Hash

Set the industry via post.

Parameters:

  • access_token (Enumerable<String>)
  • industry_id1 (Enumerable<String>)
  • industry_id2 (Enumerable<String>)

Returns:

  • (Hash)

    Json based hash.



20
21
22
23
24
# File 'lib/wx_ext/api/template_msg.rb', line 20

def set_industry(access_token, industry_id1, industry_id2)
  url = 'https://api.weixin.qq.com/cgi-bin/template/api_set_industry'\
        "?access_token=#{access_token}"
  Helper.http_post(url, { industry_id1: industry_id1, industry_id2: industry_id2 }.to_json)
end