You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1012 B
40 lines
1012 B
<?php
|
|
|
|
namespace App\Admin\Services;
|
|
|
|
use GuzzleHttp\Client;
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
class EquipInfoService
|
|
{
|
|
public static function getDatapoints($param)
|
|
{
|
|
$query = [];
|
|
if (!empty($param['at']['start'])){
|
|
$query['start'] = str_replace(' ', 'T', $param['at']['start']);
|
|
|
|
}
|
|
if (!empty($param['at']['end'])){
|
|
$query['end'] = str_replace(' ', 'T', $param['at']['end']);
|
|
|
|
}
|
|
|
|
$query = http_build_query($query);
|
|
|
|
$client = new Client([
|
|
'base_uri' => config('onenet.api_host'),
|
|
'headers' => [
|
|
'api-key' => "l5KGPjSqQVuwSSjlUAuBohPNVrM=",
|
|
]
|
|
|
|
]);
|
|
|
|
$response = $client->request('GET', 'devices/984998613/datapoints?' . $query);
|
|
|
|
$res = json_decode($response->getBody()->getContents(), true);
|
|
|
|
$res = !empty($res['data']['datastreams'][0]['datapoints']) ? $res['data']['datastreams'][0]['datapoints'] : [];
|
|
|
|
return $res;
|
|
}
|
|
}
|
|
|