class Qywechat::Notifier::QyAPI::API::Token

Attributes

client[R]

Public Class Methods

new() click to toggle source
# File lib/qywechat/notifier/qy_api/api/token.rb, line 6
def initialize
  @client = Client.new
end

Public Instance Methods

get_access_token() click to toggle source
# File lib/qywechat/notifier/qy_api/api/token.rb, line 10
def get_access_token
  Rails.cache.fetch('exception_notifier::qy_wechat_notifier', expires_in: 6800.seconds) do
    refresh_access_token
  end
end

Private Instance Methods

refresh_access_token() click to toggle source
# File lib/qywechat/notifier/qy_api/api/token.rb, line 18
def refresh_access_token
  res = client.get('/cgi-bin/gettoken', params: { corpid: Qywechat::Notifier::QyAPI.corpid, corpsecret: Qywechat::Notifier::QyAPI.corpsecret })
  res["access_token"]
end