Module: Lelylan::Client::Physical

Included in:
Lelylan::Client
Defined in:
lib/lelylan/client/physical.rb

Instance Method Summary collapse

Instance Method Details

#physical_properties(uri, secret, params) ⇒ Object

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.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/lelylan/client/physical.rb', line 21

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