Sha256: 5dbc993e0bac6ffcde9aa3e8e6766aa9a50c182adef456c3d4064dcdf2d2cb04

Contents?: true

Size: 594 Bytes

Versions: 13

Compression:

Stored size: 594 Bytes

Contents

module ChalkRuby
  class Token
    attr_accessor :token, :expires_at, :environment, :engines

    # @param [Hash[String, untyped]] exchange_credentials_response
    def initialize(exchange_credentials_response)
      @token       = exchange_credentials_response[:access_token]
      @expires_at  = DateTime.parse(exchange_credentials_response[:expires_at])
      @environment = exchange_credentials_response[:primary_environment]
      @engines     = exchange_credentials_response[:engines]
    end

    def expired?
      DateTime.now.advance({ seconds: 60 }) > @expires_at
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
chalk_ruby-0.2.8 lib/chalk_ruby/token.rb
chalk_ruby-0.2.7 lib/chalk_ruby/token.rb
chalk_ruby-0.2.6 lib/chalk_ruby/token.rb
chalk_ruby-0.2.5 lib/chalk_ruby/token.rb
chalk_ruby-0.2.4 lib/chalk_ruby/token.rb
chalk_ruby-0.2.3 lib/chalk_ruby/token.rb
chalk_ruby-0.2.2 lib/chalk_ruby/token.rb
chalk_ruby-0.2.1 lib/chalk_ruby/token.rb
chalk_ruby-0.2.0 lib/chalk_ruby/token.rb
chalk_ruby-0.1.4 lib/chalk_ruby/token.rb
chalk_ruby-0.1.3 lib/chalk_ruby/token.rb
chalk_ruby-0.1.2 lib/chalk_ruby/token.rb
chalk_ruby-0.1.1 lib/chalk_ruby/token.rb