скорректирована структура

This commit is contained in:
2025-07-31 17:15:37 +03:00
parent 017354b999
commit a1be6113db
6 changed files with 20 additions and 9 deletions

View File

@@ -1,12 +1,9 @@
<?php
require __DIR__ . '/vendor/autoload.php';
const STORAGE_DIR = __DIR__ . '/../data';
const STORAGE_RUN_DIR = __DIR__ . '/../run';
require_once __DIR__ . '/lib/YandexIoT.php';
require_once __DIR__ . '/lib/Prometheus.php';
require_once __DIR__ . '/lib/Narodmon.php';
/** Идентификатор устройства народного мониторинга */
const NARODMON_DEVICE_ID = 'AE-71-70-50-00-01';

View File

@@ -4,7 +4,7 @@
"license": "MIT",
"autoload": {
"psr-4": {
"Rsgrinko\\IotApi\\": "inc/lib/"
"Rsgrinko\\IotApi\\": "lib/"
}
},
"authors": [

View File

@@ -1,5 +1,7 @@
<?php
namespace Rsgrinko\IotApi;
class Narodmon
{
private const API_ENDPOINT = 'http://narodmon.ru/post';

View File

@@ -1,5 +1,5 @@
<?php
namespace Rsgrinko\IotApi;
class Prometheus
{
private array $data = [];

View File

@@ -1,5 +1,7 @@
<?php
namespace Rsgrinko\IotApi;
class YandexIoT
{
private string $clientId;
@@ -43,8 +45,12 @@ class YandexIoT
* @return array
* @throws JsonException
*/
public static function sendRequest(string $url, array $headers = [], ?array $data = null, ?string $method = null): array
{
public static function sendRequest(
string $url,
array $headers = [],
?array $data = null,
?string $method = null
): array {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

View File

@@ -1,5 +1,11 @@
<?php
use Rsgrinko\IotApi\Narodmon;
use Rsgrinko\IotApi\Prometheus;
use Rsgrinko\IotApi\YandexIoT;
require_once __DIR__ . '/inc/bootstrap.php';
header('Content-Type: text/plain');
$prometheusObject = new Prometheus();