class WeixinAuthorize::JsTicket::Store

def self.init_with(client)

def self.init_with(client)
  if WeixinAuthorize.weixin_redis.nil?
    ObjectStore.new(client)
  else
    RedisStore.new(client)
  end
end

def initialize(client)

def initialize(client)
  @client = client
end

def jsticket

def jsticket
  refresh_jsticket if jsticket_expired?
end

def jsticket_expired?

def jsticket_expired?
  raise NotImplementedError, "Subclasses must implement a jsticket_expired? method"
end

def refresh_jsticket

def refresh_jsticket
  set_jsticket
end

def set_jsticket

def set_jsticket
  result = client.http_get("/ticket/getticket", {type: 1}).result
  client.jsticket = result["ticket"]
  client.jsticket_expired_at = result["expires_in"] + Time.now.to_i
end