Sha256: 58c2e966d9691ed4da09bf17f74200b6336b659e33e84150361221c5ddfa93d8

Contents?: true

Size: 766 Bytes

Versions: 20

Compression:

Stored size: 766 Bytes

Contents

module GreenButtonData
  class Authorization < Entry
    include Enumerations
    include Utilities

    attr_reader :id

    attr_accessor :authorized_period,
                  :published_period,
                  :expires_at,
                  :status,
                  :resource_uri,
                  :authorization_uri

    def active?
      @status > 0
    end

    def expires_at
      if @expires_at.is_a? Numeric
        epoch_to_time @expires_at
      elsif @expires_at.is_a? String
        parse_datetime(@expires_at).to_time
      elsif @expires_at.respond_to? :to_time
        @expires_at.to_time
      else
        raise "Invalid expires_at type"
      end
    end

    def status
      get_enum_symbol AUTHORIZATION_STATUS, @status
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
green-button-data-2.0.1 lib/green-button-data/authorization.rb
green-button-data-2.0.0 lib/green-button-data/authorization.rb
green-button-data-1.0.3 lib/green-button-data/authorization.rb
green-button-data-1.0.1 lib/green-button-data/authorization.rb
green-button-data-1.0.0 lib/green-button-data/authorization.rb
green-button-data-0.7.5 lib/green-button-data/authorization.rb
green-button-data-0.7.4 lib/green-button-data/authorization.rb
green-button-data-0.7.3 lib/green-button-data/authorization.rb
green-button-data-0.7.2 lib/green-button-data/authorization.rb
green-button-data-0.7.1 lib/green-button-data/authorization.rb
green-button-data-0.7.0 lib/green-button-data/authorization.rb
green-button-data-0.6.0 lib/green-button-data/authorization.rb
green-button-data-0.5.0 lib/green-button-data/authorization.rb
green-button-data-0.4.2 lib/green-button-data/authorization.rb
green-button-data-0.4.1 lib/green-button-data/authorization.rb
green-button-data-0.3.2 lib/green-button-data/authorization.rb
green-button-data-0.4.0 lib/green-button-data/authorization.rb
green-button-data-0.4.0.alpha.pre.1 lib/green-button-data/authorization.rb
green-button-data-0.3.1 lib/green-button-data/authorization.rb
green-button-data-0.3.0 lib/green-button-data/authorization.rb