PHP code example of djthossi / ergosoft-sdk

1. Go to this page and download the library: Download djthossi/ergosoft-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

djthossi / ergosoft-sdk example snippets


use DjThossi\ErgosoftSdk\ErgosoftFactory;
use DjThossi\ErgosoftSdk\SimpleErgosoftConfiguration;
use DjThossi\ErgosoftSdk\Domain\BaseUrl;

// Initialize the Ergosoft API client with YOUR URL and optional timeout (defaults to 10s)
$configuration = new SimpleErgosoftConfiguration(new BaseUrl('https://YOUR_API_URL'));
$factory = new ErgosoftFactory($configuration);
$jobApi = $factory->createGetJobsApi();

try {
    $jobs = $jobApi->getJobs();
    foreach ($jobs as $job) {
        echo "Job ID: " . $job->getJobId()->value . "\n";
        echo "Status: " . $job->getJobStatus() . "\n";
        echo "Name: " . $job->getJobName()->value . "\n";
        echo "Created at: " . $job->getTimeCreated()->format('Y-m-d H:i:s') . "\n";
        if ($job->getTimePrinted()) {
            echo "Printed at: " . $job->getTimePrinted()->format('Y-m-d H:i:s') . "\n";
        }
        echo "---\n";
    }
} catch (\Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}


declare(strict_types=1);
namespace App\Controller;

use DjThossi\ErgosoftSdk\Api\GetJobsApi;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class DefaultController extends AbstractController
{
    #[Route('/', name: 'homepage', methods: ['GET'])]
    public function index(GetJobsApi $getJobsApi): Response {
        var_dump($getJobsApi->getJobs());

        //...
    }
}