Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EventsAPIClient
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jards
EventsAPIClient
Commits
c711bfd1
Commit
c711bfd1
authored
2 years ago
by
Mahmoud Wardeh
Browse files
Options
Downloads
Patches
Plain Diff
added sendEvent and sendEventObject from EventsAPI
parent
a4658e68
No related branches found
No related tags found
1 merge request
!2
added sendEvent and sendEventObject from EventsAPI
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/Api/EventManagement.php
+80
-0
80 additions, 0 deletions
lib/Api/EventManagement.php
with
80 additions
and
0 deletions
lib/Api/EventManagement.php
0 → 100644
+
80
−
0
View file @
c711bfd1
<?php
namespace
jards\eventsapiclient\Swagger\Client\Api
;
use
jards\eventsapiclient\Swagger\Client\Model\Event
;
use
jards\eventsapiclient\Swagger\Client\Api\EventsApi
;
class
EventManagement
{
/**
* 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
;
}
}
?>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment