Class: App::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/wechat.rb

Class Method Summary collapse

Class Method Details

.with(options) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/wechat.rb', line 12

def self.with(options)
  appid =  Wechat.config.appid
  secret = Wechat.config.secret
  token_file = options[:toke_file] || Wechat.config.access_token

  if (appid.nil? || secret.nil? || token_file.nil?)
  puts <<-HELP
You need create ~/.wechat.yml with wechat appid and secret. For example:

  appid: <wechat appid>
  secret: <wechat secret>
  access_toke: "/var/tmp/wechat_access_token"

HELP
  exit 1
  end
  Wechat::Api.new(appid, secret, token_file)
end