Sha256: 06df61878ed99423e204c364aef880f090472357f408e815277ea3913a5615a1

Contents?: true

Size: 571 Bytes

Versions: 4

Compression:

Stored size: 571 Bytes

Contents

module NestConnect
  class API
    class Stream < API
      def initialize(output: STDOUT)
        @output = output
      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

4 entries across 4 versions & 1 rubygems

Version Path
nest_connect-0.1.4 lib/nest_connect/api/stream.rb
nest_connect-0.1.3 lib/nest_connect/api/stream.rb
nest_connect-0.1.2 lib/nest_connect/api/stream.rb
nest_connect-0.1.1 lib/nest_connect/api/stream.rb