Module: ThirdPartyWxa

Defined in:
lib/third_party_wxa.rb,
lib/third_party_wxa.rb,
lib/third_party_wxa/config.rb,
lib/third_party_wxa/plugin.rb,
lib/third_party_wxa/version.rb,
lib/third_party_wxa/api/code.rb,
lib/third_party_wxa/api/login.rb,
lib/third_party_wxa/api/member.rb,
lib/third_party_wxa/api/qrcode.rb,
lib/third_party_wxa/api/server.rb,
lib/third_party_wxa/token/store.rb,
lib/third_party_wxa/api/template.rb,
lib/third_party_wxa/api/authorize.rb,
lib/third_party_wxa/token/local_store.rb,
lib/third_party_wxa/token/redis_store.rb

Defined Under Namespace

Modules: Api, Token Classes: Config, Error, Plugin

Constant Summary collapse

BASE =
'https://api.weixin.qq.com/'.freeze
VERSION =
"0.2.9"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Returns the value of attribute config.



5
6
7
# File 'lib/third_party_wxa/config.rb', line 5

def config
  @config
end

Class Method Details

.appidObject



15
16
17
# File 'lib/third_party_wxa/config.rb', line 15

def appid
	config.appid
end

.appsecretObject



19
20
21
# File 'lib/third_party_wxa/config.rb', line 19

def appsecret
	config.appsecret
end

.cal_expire_at(expires_in, pre = nil) ⇒ Object



41
42
43
44
# File 'lib/third_party_wxa.rb', line 41

def cal_expire_at expires_in, pre=nil
	return (Time.now.to_i + expires_in.to_i - pre_expire) if pre.blank?
	Time.now.to_i + expires_in.to_i - pre
end

.configure {|self.config ||= Config.new| ... } ⇒ Object

Yields:



7
8
9
# File 'lib/third_party_wxa/config.rb', line 7

def configure
	yield self.config ||= Config.new
end

.http_get_without_component_access_token(scope, url, url_params = {}) ⇒ Object



20
21
22
23
24
25
# File 'lib/third_party_wxa.rb', line 20

def http_get_without_component_access_token scope, url, url_params={}
	url = "#{BASE}#{scope}/#{url}"
	p "get -----  #{url}"
	p url_params
	JSON.parse RestClient.get URI.encode(url), {params: url_params}
end

.http_post_without_component_access_token(scope, url, post_params = {}, url_params = {}) ⇒ Object

url cant end with ‘/’, url should be encoded



28
29
30
31
32
33
34
35
# File 'lib/third_party_wxa.rb', line 28

def http_post_without_component_access_token scope, url, post_params={}, url_params={}
	url = "#{BASE}#{scope}/#{url}"
	param = url_params.to_param
	url += "?#{param}" if !param.blank?
	p "post -----  #{url}"
	p post_params
	JSON.parse RestClient.post URI.encode(url), post_params.to_json
end

.pre_expireObject



37
38
39
# File 'lib/third_party_wxa.rb', line 37

def pre_expire
	5.minutes.to_i
end

.redis_keyObject



23
24
25
# File 'lib/third_party_wxa/config.rb', line 23

def redis_key
	config.redis_key
end

.wx_redisObject



11
12
13
# File 'lib/third_party_wxa/config.rb', line 11

def wx_redis
	config.redis
end