Skip to content

Instantly share code, notes, and snippets.

@jceloi
Created February 2, 2016 16:49
Show Gist options
  • Save jceloi/0f0b5611c1e3b3124e43 to your computer and use it in GitHub Desktop.
Save jceloi/0f0b5611c1e3b3124e43 to your computer and use it in GitHub Desktop.
get '/coffre/state/:id' do
response.headers['Access-Control-Allow-Origin'] = '*'
content_type :json
puts params['coffre']
puts params['id']
device = $coffre.select {|val| params['id'] == val['ID']}.first
new_status = !device['DEVICE_STATUS']
device['DEVICE_STATUS'] = new_status
device['SAFE_ID'] = params['coffre']
device['LAST_UPDATE'] = DateTime.now
{deviceId: device['ID'], inTheSafe: new_status, safeId: params['coffre']}.to_json
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment