public function query($type, $name = null) { $type = strtoupper($type); try { $this->validateType($type); return response()->json(ProviderManager::getDataForQuery($type, $name)); } catch (NoMatchException $e) { return response()->json(['error' => $e->getMessage()], 422); } }
public function set($type, $value, Request $request) { $type = strtoupper($type); try { $this->validateType($type); $value = ProviderManager::setActuator($type, $value, $request->json()->all()); $response = ['success' => true]; if ($value) { $response['value'] = $value; } return response()->json($response); } catch (NoMatchException $e) { return response()->json(['error' => $e->getMessage()], 422); } }
/** * Execute the console command. * * @return mixed */ public function handle() { ProviderManager::pull(); }
public function testSetLightsOn() { $mockProvider = \Mockery::mock(App\Support\Providers\PhilipsHueProvider::class)->shouldReceive('providesActuators')->andReturn(['Lights' => ActuatorTypes::LIGHTS])->shouldReceive('setLights')->with('on', [])->mock(); ProviderManager::$providers = [$mockProvider]; $this->post('/v1/set/lights/on')->seeJson(['success' => true]); }
public function __construct() { ProviderManager::init(); }