From e0d18321abfd78952f4d77ab450d967cca69815b Mon Sep 17 00:00:00 2001 From: Vincent BRIDIER Date: Fri, 3 Oct 2025 19:30:36 +0200 Subject: [PATCH] wip --- composer.json | 2 ++ index.php | 15 +++++++++-- src/Datas/EmployeesDatas.php | 35 ++++++++++++++++++++++---- src/Datas/IncoDatas.php | 48 ++++++++++++++++++++++++++++++++++++ src/Models/Employee.php | 19 ++++++++++++++ src/Models/Inco.php | 21 ++++++++++++++++ src/Traits/ArcadiaTrait.php | 6 +++-- src/Transport.php | 23 +++++++++++------ 8 files changed, 152 insertions(+), 17 deletions(-) create mode 100644 src/Datas/IncoDatas.php create mode 100644 src/Models/Inco.php diff --git a/composer.json b/composer.json index 0e0d6a5..bb97083 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,8 @@ } ], "require": { + "php": "^8.0", + "ext-mbstring": "*", "guzzlehttp/guzzle": "^7.10" } } diff --git a/index.php b/index.php index ea73e02..a4dd043 100644 --- a/index.php +++ b/index.php @@ -1,10 +1,21 @@ diff --git a/src/Datas/EmployeesDatas.php b/src/Datas/EmployeesDatas.php index bdf1d4d..b252bcb 100644 --- a/src/Datas/EmployeesDatas.php +++ b/src/Datas/EmployeesDatas.php @@ -21,10 +21,12 @@ class EmployeesDatas 'planned_end_date' => 'DATE_EFFET_FIC', 'establishment' => 'ETAB_FIC', 'site' => 'SITE_FIC', - 'service' => 'SERVICE_FIC' + 'service' => 'SERVICE_FIC', + 'created_at' => 'DAT_CRE', + 'updated_at' => 'DAT_MAJ', ]; - public static function getById(string $id) + public static function getById(string $id) : Employee|null { $params = [ 'TABLE' => self::$table, @@ -40,8 +42,31 @@ class EmployeesDatas return null; } - $employee = new Employee(); - $employee->fill(self::mapObject($response[0]->values)); - return $employee; + $model = new Employee(); + $model->fill(self::mapObject($response[0]->values)); + return $model; + } + + public static function getListModifiedSince(string $date) + { + $params = [ + 'TABLE' => self::$table, + 'S_COLS' => self::getArcadiaDefinition(), + 'C_COLS' => self::getArcadiaDefinition(['updated_at']), + 'C_OPES' => ['>='], + 'C_VALS' => [$date], + ]; + + $response = Transport::call($params); + + var_dump($response);exit; + + if (empty($response[0]->values)) { + return null; + } + + $model = new Employee(); + $model->fill(self::mapObject($response[0]->values)); + return $model; } } \ No newline at end of file diff --git a/src/Datas/IncoDatas.php b/src/Datas/IncoDatas.php new file mode 100644 index 0000000..60bbbe3 --- /dev/null +++ b/src/Datas/IncoDatas.php @@ -0,0 +1,48 @@ + 'NO_ART', + 'description' => 'DESCRIPTIF', + 'tips' => 'ASTUCES', + 'ingredients' => 'LST_ING', + 'portions' => 'NB_PORTION', + 'portion_type' => 'TYP_PORTION', // FIXME: Lié à une autre table ? + 'allergens' => 'LST_ALLERGENE', // FIXME: Lié à une autre table ? + 'brand' => 'MARQUE', // FIXME: Lié à une autre table ? + 'created_at' => 'DAT_CRE', + 'updated_at' => 'DAT_MAJ', + ]; + + public static function getById(string $id) + { + $params = [ + 'TABLE' => self::$table, + 'S_COLS' => self::getArcadiaDefinition(), + 'C_COLS' => self::getArcadiaDefinition(['id']), + 'C_OPES' => ['='], + 'C_VALS' => [$id], + ]; + + $response = Transport::call($params); + + if (empty($response[0]->values)) { + return null; + } + + $model = new Inco(); + $model->fill(self::mapObject($response[0]->values)); + return $model; + } +} \ No newline at end of file diff --git a/src/Models/Employee.php b/src/Models/Employee.php index c4e2284..ac6fb66 100644 --- a/src/Models/Employee.php +++ b/src/Models/Employee.php @@ -4,6 +4,23 @@ namespace Uwil\ArcadiaGenesisPhpClient\Models; use Uwil\ArcadiaGenesisPhpClient\Traits\ModelTrait; +/** + * Class Employee + * + * Represents an employee with personal and job-related details. + * + * @property string $matricule Unique identifier of the employee + * @property string $lastname Last name of the employee + * @property string $firstname First name of the employee + * @property string $start_date Employment start date (YYYY-MM-DD) + * @property string|null $end_date Employment end date if applicable (YYYY-MM-DD or null) + * @property string|null $planned_end_date Planned termination date if any + * @property string $establishment Establishment where the employee works + * @property string $site Physical site location of the employee + * @property string $service Service or department of the employee + * @property string|null $created_at Record creation timestamp + * @property string|null $updated_at Record last update timestamp + */ class Employee { use ModelTrait; @@ -17,4 +34,6 @@ class Employee public string $establishment; public string $site; public string $service; + public string|null $created_at; + public string|null $updated_at; } \ No newline at end of file diff --git a/src/Models/Inco.php b/src/Models/Inco.php new file mode 100644 index 0000000..c34e7c6 --- /dev/null +++ b/src/Models/Inco.php @@ -0,0 +1,21 @@ +format('Y-m-d'); } // If just string, return original value. diff --git a/src/Transport.php b/src/Transport.php index 7cb4297..b41f0eb 100644 --- a/src/Transport.php +++ b/src/Transport.php @@ -5,6 +5,7 @@ namespace Uwil\ArcadiaGenesisPhpClient; use GuzzleHttp\Psr7; use GuzzleHttp\Client; use GuzzleHttp\Exception\ClientException; +use GuzzleHttp\Exception\ServerException; use InvalidArgumentException; class Transport @@ -12,8 +13,7 @@ class Transport private static string $endpoint = "https://lab501-arc05402.lesidc.com"; // FIXME : Move this private static string $apiKey = "11319-1127611241-11748-11917-12156891612247-10244-11653-125778522-1195511335-11382-10886-108424242324222424242322242424232423"; // FIXME : Move this - private static string $apiSecret = "1046012368-8940-10144-1095-12022-10631103331003311372-107631276111238-12022-9129-1202-1223310126-10026957612620-10828100522324232224232414232423232423232324241424232324"; - private static string $apiSignature = "TaLY2pzBFdyUd2liBteJPh2E3t6BIbiQuVy6KAgsL5I="; // FIXME : Move this + private static string $apiSecret = "-1046012368-8940-10144-1095-12022-10631103331003311372-107631276111238-12022-9129-1202-1223310126-10026957612620-10828100522324232224232414232423232423232324241424232324"; public function __construct(string $endpoint) { @@ -22,6 +22,7 @@ class Transport public static function call(array $params) { + $client = new Client([ 'base_uri' => sprintf( "%s%s", @@ -37,19 +38,25 @@ class Transport 'headers' => [ 'Content-Type' => 'application/json', 'API-KEY' => self::$apiKey, - 'API-SIGNATURE' => self::$apiSignature // FIXME : Utiliser la methode getApiSignature() quand on aura le secret fourni comme dans la doc + 'API-SIGNATURE' => self::getApiSignature() ] ]); $body = $response->getBody()->getContents(); - - return $body ? json_decode($body) : null; + $utf8_string = \mb_convert_encoding($body, 'UTF-8', 'ISO-8859-1'); // FIXME: Non bah non... + var_dump($body);exit; + return $body ? json_decode($utf8_string) : null; } catch (ClientException $e) { - //echo Psr7\Message::toString($e->getRequest()); - $response = json_decode($e->getResponse()->getBody()->getContents()); - var_dump($response); + var_dump($e);exit; + echo Psr7\Message::toString($e->getRequest()); + echo Psr7\Message::toString($e->getResponse()); + //$response = json_decode($e->getResponse()->getBody()->getContents()); + //var_dump($response); exit; + } catch (ServerException $e) { // FIXME: L'API retourne 503 pour certains calls mais pas pour d'autres, le serveur n'est donc pas en maintenance. + var_dump($e);exit; + die('herde'); } }