Sha256: b8c6f5fc4765a23b82c89c1be8c7ec0f4331d370bb86bac82e9c3a1a079e932f

Contents?: true

Size: 627 Bytes

Versions: 3

Compression:

Stored size: 627 Bytes

Contents

module NestConnect
  class API
    class Stream < API
      def initialize(output: STDOUT, access_token: nil)
        @output = output
        @access_token = access_token
      end

      def run
        connection.get do |request|
          request.headers['Accept'] = 'text/event-stream'
          request.headers['Authorization'] = "Bearer #{access_token}"
          request.headers['Cache-Control'] = 'no-cache'

          request.options.on_data = Proc.new do |chunk, overall_received_bytes|
            output.write chunk
          end
        end
      end

      private

        attr_reader :output
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nest_connect-0.1.7 lib/nest_connect/api/stream.rb
nest_connect-0.1.6 lib/nest_connect/api/stream.rb
nest_connect-0.1.5 lib/nest_connect/api/stream.rb