Sha256: 9f3780b25b16a761c6a97f67d3cc60aecdf6f521cd37c28d519a895a5ac80cfa

Contents?: true

Size: 975 Bytes

Versions: 2

Compression:

Stored size: 975 Bytes

Contents

require 'uri'
require 'openssl'
require 'securerandom'
require 'json'
require 'lelylan/authentication'

module Lelylan
  class Client
    module Physical

      #
      # Public: Send a request adding a nonce and a X-Physical-Signature
      # header.
      #
      # uri - A String that represents the uri of the physical device.
      # secret - The device secret.
      # params - An object containing the JSON params to send.
      #
      # Returns Hashie The JSON resource.
      #
      def physical_properties(uri, secret, params)
        headers = { 'X-Physical-Secret' => secret }

        request  = Faraday.new do |builder|
          builder.request :json
          builder.use Faraday::Response::RaiseHttpError
          builder.use FaradayMiddleware::Mashify
          builder.use FaradayMiddleware::ParseJson
          builder.adapter(adapter)
        end

        response = request.put(uri, params, headers)
        response.body
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lelylan-rb-0.1.0 lib/lelylan/client/physical.rb
lelylan-rb-0.0.5 lib/lelylan/client/physical.rb