diff --git a/composer.json b/composer.json index f5258383ff79bfdc3f6160688161d935f32f3f17..b973f53c38a9fac90e634dd41eec30d1131ef553 100644 --- a/composer.json +++ b/composer.json @@ -17,8 +17,8 @@ "require": { "silex/silex" : "^2.3", "phpmailer/phpmailer": ">=6.0", - "jards/eventsapiclient": "=3.4", - "jards/gcsjardsapiclient": "=2.3" + "jards/gcsjardsapiclient": "=2.3", + "jards/eventsapiclient": "3.5" }, "require-dev": { "phpunit/phpunit": "^9.5.5" diff --git a/composer.lock b/composer.lock index 39895411df32ef9265168427550055adfb5bfd72..cd550ee5bc199c41a05fbf89d6c77e0c8992f960 100644 --- a/composer.lock +++ b/composer.lock @@ -4,15 +4,15 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1385fd0265eac1902989e35ded5ade5b", + "content-hash": "2fd0ac161839446cab47ffdbd396e48b", "packages": [ { "name": "jards/eventsapiclient", - "version": "v3.4", + "version": "v3.5", "source": { "type": "git", "url": "https://gitlab.version.fz-juelich.de/jards/EventsAPIClient.git", - "reference": "a4658e687c595e5ba180beb6308d38cee6a54e1e" + "reference": "c711bfd1bc5ea1ba3374a96d5bce07618856f4a8" }, "require": { "ext-curl": "*", @@ -53,7 +53,7 @@ "sdk", "swagger" ], - "time": "2022-03-11T08:03:41+00:00" + "time": "2023-05-25T10:41:07+00:00" }, { "name": "jards/gcsjardsapiclient", diff --git a/examples/sendEventExample.php b/examples/sendEventExample.php index 410bf0605f720be6b82c26a76aab62eaa5da6250..93ae5d10f25d8e6707018e3139f76186f5170734 100644 --- a/examples/sendEventExample.php +++ b/examples/sendEventExample.php @@ -1,6 +1,6 @@ <?php -use jards\eventsapi\EventManagement; +use jards\eventsapiclient\Swagger\Client\Api\EventManagement; require_once __DIR__.'/../vendor/autoload.php'; $eventManagement = new EventManagement(); diff --git a/lib/EventManagement.php b/lib/EventManagement.php index d892f73c306d229132f983c6710e1b3a4a4922a5..ec261a48f6bb671d0f4f21840476b9955ec94f02 100644 --- a/lib/EventManagement.php +++ b/lib/EventManagement.php @@ -173,74 +173,6 @@ class EventManagement{ return new Response("Successfully handled event $newID: $name."); } - /** - * Send an event to a event receiver. - * @param string $name name of the event - * @param string $description description of the event - * @param string $baseURL the root URL of the event receiver REST API - * @param string $certFile path to certificate file to use or null to call URL without certificate - * @param string $certKey path to certificate key file, null to avoid usage of key - * @param string $certPassphrase path to passphrase file for key file, null for no passphrase - * @param int $timeout time out in seconds until curl call is aborted - * @param \jards\eventsapiclient\Swagger\Client\ApiException $exception output parameter, if exception occurs - * - * @return boolean true on success, false on error - */ - public function sendEvent($name, $description, $baseURL='http://localhost/myapps/EventsAPI/rest/events', $certFile = null, $certKey = null, $certPassphrase = null, $timeout = null, &$exception=null){ - - $event = new Event(); - $event->setName($name); - $event->setDescription($description); - $event->setDate(new \DateTime()); - - return $this->sendEventObject($event, $baseURL, $certFile, $certKey, $certPassphrase, $timeout, $exception); - } - - /** - * Send an event according to swagger API model. - * Prepare any event you like, then send it with this function. - * - * @param Event $eventObject the event object you would like to send - * @param string $baseURL the root URL of the event receiver REST API - * @param string $certFile path to certificate file to use or null to call URL without certificate - * @param string $certKey path to certificate key file, null to avoid usage of key - * @param string $certPassphrase path to passphrase file for key file, null for no passphrase - * @param int $timeout time out in seconds until curl call is aborted - * @param \jards\eventsapiclient\Swagger\Client\ApiException $exception output parameter, if exception occurs - * - * @return boolean true on success, false on error - */ - public function sendEventObject($eventObject, $baseURL='http://localhost/myapps/EventsAPI/rest/events', $certFile = null, $certKey = null, $certPassphrase = null, $timeout = null, &$exception=null){ - date_default_timezone_set ( 'Europe/Amsterdam' ); - $apiClient = new \jards\eventsapiclient\Swagger\Client\ApiClient (); - $apiClient->getConfig ()->setHost ( $baseURL ); - - if(! empty($certFile)){ - $apiClient->getConfig ()->setCertificate($certFile); - } - if(! empty($certKey)){ - $apiClient->getConfig ()->setCertificateKey($certKey); - } - if(! empty($certPassphrase)){ - $apiClient->getConfig ()->setCertificatePassphrase($certPassphrase); - } - if(! empty($timeout)){ - $apiClient->getConfig()->setCurlConnectTimeout($timeout); - } - - $eventsApi = new EventsApi($apiClient); - - try{ - $eventsApi->eventsPost($eventObject); - } - catch(\jards\eventsapiclient\Swagger\Client\ApiException $e){ - $exception = $e; - return false; - } - - return true; - } - } ?> \ No newline at end of file diff --git a/tests/EventManagementTest.php b/tests/EventManagementTest.php index c344a5c8b12f4473a18b7b8f412bc4f3af7e0990..80ce59ac902ce0b1dfe4ecb669c889e4856bb29e 100644 --- a/tests/EventManagementTest.php +++ b/tests/EventManagementTest.php @@ -5,6 +5,8 @@ namespace jards\eventsapi\tests; use PHPUnit\Framework\TestCase; use jards\eventsapi\EventManagement; use jards\eventsapiclient\Swagger\Client\Model\Event; +use jards\eventsapiclient\Swagger\Client\Api\EventManagement as ApiEventManagement; + class EventManagementTest extends TestCase{ @@ -48,7 +50,7 @@ class EventManagementTest extends TestCase{ public function testSendEvent(){ echo "testSendEvent\n"; - $eventManagement = new EventManagement(); + $eventManagement = new ApiEventManagement(); $oldEventIDs = $this->getExistingEventIDs(); @@ -94,7 +96,7 @@ class EventManagementTest extends TestCase{ $url = file_get_contents(__DIR__.'/../configs/myurl.cnf'); $invalid = $url.'/thisisinvalidforphpunit'; - $eventManagement = new EventManagement(); + $eventManagement = new ApiEventManagement(); $event = new Event(); $event->setName('My event never sent phpunit');