Sha256: ac8a1799f32d88459072ffe87f730055c818e7db8928a3212376da9986d11b17
Contents?: true
Size: 965 Bytes
Versions: 1
Compression:
Stored size: 965 Bytes
Contents
module SimpleWechat class Client class AccessToken ATTRIBUTES = %W(access_token expires_in errcode errmsg).freeze attr_reader *ATTRIBUTES def initialize(options = {}) ATTRIBUTES.each do |name| instance_variable_set("@#{name}", options[name]) end end end attr_reader :appid, :secret def initialize(appid, secret) @appid, @secret = appid, secret end def get_access_token response = connection.get("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=#{appid}&secret=#{secret}") AccessToken.new MultiJson.load(response.body) end def get_auth_client AuthClient.new(appid, secret) end def connection @connection ||= begin conn = Faraday.new do |faraday| faraday.adapter Faraday.default_adapter end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simple_wechat-0.0.1 | lib/simple_wechat/client.rb |