Sha256: aea6dcb658d62a6da589a891d71729ea9ae5f18840af842eeb90f538333b8125

Contents?: true

Size: 539 Bytes

Versions: 11

Compression:

Stored size: 539 Bytes

Contents

module Wework
  module JsTicket
    class Store

      attr_accessor :app

      def initialize(app)
        @app = app
      end

      def jsapi_ticket
        refresh_token if expired?
      end

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

      def refresh_token
        app.get 'get_jsapi_ticket'
      end

      private

      def key
        @key ||= Digest::MD5.hexdigest("#{JSAPI_TOKEN_PREFIX}_#{app.app_id}_#{app.app_secret}")
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
wework-0.2.5 lib/wework/js_ticket/store.rb
wework-0.2.4 lib/wework/js_ticket/store.rb
wework-0.2.3 lib/wework/js_ticket/store.rb
wework-0.2.2 lib/wework/js_ticket/store.rb
wework-0.2.0 lib/wework/js_ticket/store.rb
wework-0.1.9 lib/wework/js_ticket/store.rb
wework-0.1.8 lib/wework/js_ticket/store.rb
wework-0.1.7 lib/wework/js_ticket/store.rb
wework-0.1.6 lib/wework/js_ticket/store.rb
wework-0.1.4 lib/wework/js_ticket/store.rb
wework-0.1.3 lib/wework/js_ticket/store.rb