Class: Wechat::MpApi
Constant Summary
Constants inherited
from ApiBase
ApiBase::API_BASE, ApiBase::DATACUBE_BASE, ApiBase::MP_BASE, ApiBase::OAUTH2_BASE, ApiBase::QYAPI_BASE, ApiBase::TCB_BASE, ApiBase::WXA_BASE
Instance Attribute Summary
Attributes inherited from ApiBase
#access_token, #client, #jsapi_ticket, #qcloud
Instance Method Summary
collapse
#invoke_cloud_function, #qdb_add, #qdb_aggregate, #qdb_collection_add, #qdb_collection_delete, #qdb_collections, #qdb_count, #qdb_delete, #qdb_migrate_export, #qdb_migrate_import, #qdb_migrate_query, #qdb_query, #qdb_update, #qdb_update_index, #tcb_delete_files, #tcb_do_upload_file, #tcb_download_files, #tcb_preflight_upload_file, #tcb_upload_file
#addvoicetorecofortext, #custom_message_send, #customservice_getonlinekflist, #get_material, #getusercumulate, #getusersummary, #group_create, #group_delete, #group_update, #groups, #material, #material_add, #material_add_news, #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, #queryrecoresultfortext, #shorturl, #tag, #tag_add_user, #tag_create, #tag_del_user, #tag_delete, #tag_update, #tags, #translatecontent, #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_generate_shortlink, #wxa_generate_urllink, #wxa_get_user_phone_number, #wxa_get_wxacode, #wxa_get_wxacode_unlimit, #wxa_msg_sec_check
Methods inherited from ApiBase
#callbackip, #clear_quota, #media, #media_create, #media_hq, #media_uploadimg, #media_uploadnews, #qrcode
Constructor Details
#initialize(appid, secret, token_file, network_setting, jsapi_ticket_file, qcloud_setting) ⇒ MpApi
Returns a new instance of MpApi.
5
6
7
8
9
10
11
|
# File 'lib/wechat/mp_api.rb', line 5
def initialize(appid, secret, token_file, network_setting, jsapi_ticket_file, qcloud_setting)
super()
@client = HttpClient.new(Wechat::Api::API_BASE, network_setting)
@access_token = Token::PublicAccessToken.new(@client, appid, secret, token_file)
@jsapi_ticket = Ticket::PublicJsapiTicket.new(@client, @access_token, jsapi_ticket_file)
@qcloud = Qcloud::Token.new(@client, @access_token, qcloud_setting)
end
|
Instance Method Details
#add_message_template(id, keyword_id_list) ⇒ Object
28
29
30
|
# File 'lib/wechat/mp_api.rb', line 28
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
36
37
38
|
# File 'lib/wechat/mp_api.rb', line 36
def del_message_template(template_id)
post 'wxopen/template/del', JSON.generate(template_id: template_id)
end
|
#jscode2session(code) ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/wechat/mp_api.rb', line 44
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
32
33
34
|
# File 'lib/wechat/mp_api.rb', line 32
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
20
21
22
|
# File 'lib/wechat/mp_api.rb', line 20
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
24
25
26
|
# File 'lib/wechat/mp_api.rb', line 24
def list_template_library_keywords(id)
post 'wxopen/template/library/get', JSON.generate(id: id)
end
|
#subscribe_message_send(message) ⇒ Object
40
41
42
|
# File 'lib/wechat/mp_api.rb', line 40
def subscribe_message_send(message)
post 'message/subscribe/send', message.to_json
end
|
#template_message_send(message) ⇒ Object
16
17
18
|
# File 'lib/wechat/mp_api.rb', line 16
def template_message_send(message)
post 'message/wxopen/template/send', message.to_json, content_type: :json
end
|