Module: WeixinAuthorize

Defined in:
lib/weixin_authorize.rb,
lib/weixin_authorize/client.rb,
lib/weixin_authorize/config.rb,
lib/weixin_authorize/version.rb,
lib/weixin_authorize/api/menu.rb,
lib/weixin_authorize/api/user.rb,
lib/weixin_authorize/api/media.rb,
lib/weixin_authorize/api/custom.rb,
lib/weixin_authorize/api/groups.rb,
lib/weixin_authorize/api/qrcode.rb,
lib/weixin_authorize/adapter/storage.rb,
lib/weixin_authorize/adapter/redis_storage.rb,
lib/weixin_authorize/adapter/client_storage.rb

Defined Under Namespace

Modules: Api Classes: Client, ClientStorage, Config, RedisStorage, Storage

Constant Summary collapse

VERSION =
"1.5.6"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Returns the value of attribute config.



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

def config
  @config
end

Class Method Details

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

Yields:



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

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

.endpoint_url(endpoint, url) ⇒ Object



28
29
30
# File 'lib/weixin_authorize.rb', line 28

def endpoint_url(endpoint, url)
  send("#{endpoint}_endpoint") + url
end

.file_endpointObject



36
37
38
# File 'lib/weixin_authorize.rb', line 36

def file_endpoint
  "http://file.api.weixin.qq.com/cgi-bin"
end

.http_get_without_token(url, headers = {}, endpoint = "plain") ⇒ Object



12
13
14
15
# File 'lib/weixin_authorize.rb', line 12

def http_get_without_token(url, headers={}, endpoint="plain")
  get_api_url = endpoint_url(endpoint, url)
  load_json(RestClient.get(get_api_url, :params => headers))
end

.http_post_without_token(url, payload = {}, headers = {}, endpoint = "plain") ⇒ Object



17
18
19
20
21
# File 'lib/weixin_authorize.rb', line 17

def http_post_without_token(url, payload={}, headers={}, endpoint="plain")
  post_api_url = endpoint_url(endpoint, url)
  payload = MultiJson.dump(payload) if endpoint == "plain" # to json
  load_json(RestClient.post(post_api_url, payload, headers))
end

.load_json(string) ⇒ Object

return hash



24
25
26
# File 'lib/weixin_authorize.rb', line 24

def load_json(string)
  JSON.parse(string)
end

.mp_endpointObject



40
41
42
# File 'lib/weixin_authorize.rb', line 40

def mp_endpoint
  "https://mp.weixin.qq.com/cgi-bin"
end

.plain_endpointObject



32
33
34
# File 'lib/weixin_authorize.rb', line 32

def plain_endpoint
  "https://api.weixin.qq.com/cgi-bin"
end