15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/action_controller/wechat_responder.rb', line 15
def load_controller_wechat(opts = {})
self.token = opts[:token] || Wechat.config.token
self.appid = opts[:appid] || Wechat.config.appid
self.corpid = opts[:corpid] || Wechat.config.corpid
self.agentid = opts[:agentid] || Wechat.config.agentid
self.encrypt_mode = opts[:encrypt_mode] || Wechat.config.encrypt_mode || corpid.present?
self.timeout = opts[:timeout] || 20
self.skip_verify_ssl = opts[:skip_verify_ssl]
self.encoding_aes_key = opts[:encoding_aes_key] || Wechat.config.encoding_aes_key
self.trusted_domain_fullname = opts[:trusted_domain_fullname] || Wechat.config.trusted_domain_fullname
Wechat.config.oauth2_cookie_duration ||= 1.hour
self.oauth2_cookie_duration = opts[:oauth2_cookie_duration] || Wechat.config.oauth2_cookie_duration.to_i.seconds
return self.wechat = Wechat.api if opts.empty?
if corpid.present?
Wechat::CorpApi.new(corpid, opts[:corpsecret], opts[:access_token], \
agentid, timeout, skip_verify_ssl, opts[:jsapi_ticket])
else
Wechat::Api.new(appid, opts[:secret], opts[:access_token], \
timeout, skip_verify_ssl, opts[:jsapi_ticket])
end
end
|