Sha256: 07ba1ac1a73a345ac2b8423cdc46d1d19697bf5015f1c1b490f38547f16040be

Contents?: true

Size: 620 Bytes

Versions: 1

Compression:

Stored size: 620 Bytes

Contents

module Wework
  module Token
    class Store

      attr_accessor :agent

      def initialize(agent)
        @agent = agent
      end

      def access_token
        refresh_token if expired?
      end

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

      def refresh_token
        agent.request.get 'gettoken', params: {corpid: agent.corp_id, corpsecret: agent.agent_secret}
      end

      private

      def key
        @key ||= Digest::MD5.hexdigest("#{ACCESS_TOKEN_PREFIX}_#{agent.agent_id}_#{agent.agent_secret}")
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wework-0.1.2 lib/wework/token/store.rb