Module: ActionController::WechatResponder

Included in:
API, Base
Defined in:
lib/action_controller/wechat_responder.rb

Instance Method Summary collapse

Instance Method Details

#load_controller_wechat(opts = {}) ⇒ Object



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

#wechat_api(opts = {}) ⇒ Object



3
4
5
6
# File 'lib/action_controller/wechat_responder.rb', line 3

def wechat_api(opts = {})
  include Wechat::ControllerApi
  self.wechat = load_controller_wechat(opts)
end

#wechat_responder(opts = {}) ⇒ Object



8
9
10
11
# File 'lib/action_controller/wechat_responder.rb', line 8

def wechat_responder(opts = {})
  include Wechat::Responder
  self.wechat = load_controller_wechat(opts)
end