Example #1
0
 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);
     }
 }
Example #2
0
 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);
     }
 }
Example #3
0
File: Pull.php Project: hjem/hjem
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     ProviderManager::pull();
 }
Example #4
0
 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]);
 }
Example #5
0
 public function __construct()
 {
     ProviderManager::init();
 }