Class: Wechat::MpApi

Inherits:
ApiBase show all
Includes:
Concern::Common
Defined in:
lib/wechat/mp_api.rb

Constant Summary

Constants included from Concern::Common

Concern::Common::API_BASE, Concern::Common::OAUTH2_BASE, Concern::Common::WXA_BASE

Constants inherited from ApiBase

ApiBase::MP_BASE

Instance Attribute Summary

Attributes inherited from ApiBase

#access_token, #client, #jsapi_ticket

Instance Method Summary collapse

Methods included from Concern::Common

#custom_message_send, #customservice_getonlinekflist, #group_create, #group_delete, #group_update, #groups, #initialize, #material, #material_add, #material_count, #material_delete, #material_list, #menu, #menu_addconditional, #menu_create, #menu_delconditional, #menu_delete, #menu_trymatch, #message_mass_delete, #message_mass_get, #message_mass_preview, #message_mass_sendall, #qrcode_create_limit_scene, #qrcode_create_scene, #shorturl, #tag, #tag_add_user, #tag_create, #tag_del_user, #tag_delete, #tag_update, #tags, #user, #user_batchget, #user_change_group, #user_group, #user_update_remark, #users, #web_access_token, #web_auth_access_token, #web_refresh_access_token, #web_userinfo, #wxa_create_qrcode, #wxa_get_wxacode

Methods inherited from ApiBase

#callbackip, #media, #media_create, #media_hq, #media_uploadimg, #media_uploadnews, #qrcode

Instance Method Details

#add_message_template(id, keyword_id_list) ⇒ Object



23
24
25
# File 'lib/wechat/mp_api.rb', line 23

def add_message_template(id, keyword_id_list)
  post 'wxopen/template/add', JSON.generate(id: id, keyword_id_list: keyword_id_list)
end

#del_message_template(template_id) ⇒ Object



31
32
33
# File 'lib/wechat/mp_api.rb', line 31

def del_message_template(template_id)
  post 'wxopen/template/del', JSON.generate(template_id: template_id)
end

#jscode2session(code) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/wechat/mp_api.rb', line 35

def jscode2session(code)
  params = {
    appid: access_token.appid,
    secret: access_token.secret,
    js_code: code,
    grant_type: 'authorization_code'
  }

  client.get 'jscode2session', params: params, base: OAUTH2_BASE
end

#list_message_template(offset: 0, count: 20) ⇒ Object



27
28
29
# File 'lib/wechat/mp_api.rb', line 27

def list_message_template(offset: 0, count: 20)
  post 'wxopen/template/list', JSON.generate(offset: offset, count: count)
end

#list_template_library(offset: 0, count: 20) ⇒ Object



15
16
17
# File 'lib/wechat/mp_api.rb', line 15

def list_template_library(offset: 0, count: 20)
  post 'wxopen/template/library/list', JSON.generate(offset: offset, count: count)
end

#list_template_library_keywords(id) ⇒ Object



19
20
21
# File 'lib/wechat/mp_api.rb', line 19

def list_template_library_keywords(id)
  post 'wxopen/template/library/get', JSON.generate(id: id)
end

#template_message_send(message) ⇒ Object



11
12
13
# File 'lib/wechat/mp_api.rb', line 11

def template_message_send(message)
  post 'message/wxopen/template/send', message.to_json, content_type: :json
end