Sha256: 92c4ff497ecfb9c4d855f2dc620fd274404fe39241585a68c8be05af86a8d5a5

Contents?: true

Size: 998 Bytes

Versions: 2

Compression:

Stored size: 998 Bytes

Contents

module NestConnect
  class API
    module Devices
      class BaseDevice < API
       def initialize(resource_id: nil, access_token: nil)
          @resource_id = resource_id
          @access_token = access_token
        end

        def put(body)
          connection.put do |request|
            request.url(resource)
            request.headers.merge!(headers)
            request.body = body
          end
        end

        def get
          connection.get do |request|
            request.url(resource)
            request.headers.merge!(headers)
          end
        end

        def all
          connection.get do |request|
            request.url(resources)
            request.headers.merge!(headers)
          end
        end

        private

          attr_reader :resource_id

          def headers
            {
              'Content-Type' => 'application/json',
              'Authorization' => "Bearer #{access_token}"
            }
          end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nest_connect-0.1.7 lib/nest_connect/api/devices/base_device.rb
nest_connect-0.1.6 lib/nest_connect/api/devices/base_device.rb