diff --git a/docs/Api/EventsApi.md b/docs/Api/EventsApi.md new file mode 100644 index 0000000..50957d9 --- /dev/null +++ b/docs/Api/EventsApi.md @@ -0,0 +1,67 @@ +# Brevo\Client\EventsApi + +All URIs are relative to *https://api.brevo.com/v3* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**createEvent**](EventsApi.md#createEvent) | **POST** /events | Create an event + + +# **createEvent** +> createEvent($event) + +Create an event + +Create an event to track a contact's interaction. + +### Example +```php +setApiKey('api-key', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// $config = Brevo\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api-key', 'Bearer'); +// Configure API key authorization: partner-key +$config = Brevo\Client\Configuration::getDefaultConfiguration()->setApiKey('partner-key', 'YOUR_API_KEY'); +// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +// $config = Brevo\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('partner-key', 'Bearer'); + +$apiInstance = new Brevo\Client\Api\EventsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$event = new \Brevo\Client\Model\Event(); // \Brevo\Client\Model\Event | + +try { + $apiInstance->createEvent($event); +} catch (Exception $e) { + echo 'Exception when calling EventsApi->createEvent: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **event** | [**\Brevo\Client\Model\Event**](../Model/Event.md)| | + +### Return type + +void (empty response body) + +### Authorization + +[api-key](../../README.md#api-key), [partner-key](../../README.md#partner-key) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to Model list]](../../README.md#documentation-for-models) [[Back to README]](../../README.md) + diff --git a/docs/Model/Event.md b/docs/Model/Event.md new file mode 100644 index 0000000..959614d --- /dev/null +++ b/docs/Model/Event.md @@ -0,0 +1,14 @@ +# Event + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**eventName** | **string** | The name of the event that occurred. This is how you will find your event in Brevo. Limited to 255 characters, alphanumerical characters and - _ only. | +**eventDate** | **string** | Timestamp of when the event occurred (e.g. \"2024-01-24T17:39:57+01:00\"). If no value is passed, the timestamp of the event creation is used. | [optional] +**identifiers** | [**\Brevo\Client\Model\EventIdentifiers**](EventIdentifiers.md) | | +**contactProperties** | **object** | Properties defining the state of the contact associated to this event. Useful to update contact attributes defined in your contacts database while passing the event. For example: **\"FIRSTNAME\": \"Jane\" , \"AGE\": 37** | [optional] +**eventProperties** | **object** | Properties of the event. Top level properties and nested properties can be used to better segment contacts and personalise workflow conditions. The following field type are supported: string, number, boolean (true/false), date (Timestamp e.g. \"2024-01-24T17:39:57+01:00\"). Keys are limited to 255 characters, alphanumerical characters and - _ only. Size is limited to 50Kb. | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + + diff --git a/docs/Model/EventIdentifiers.md b/docs/Model/EventIdentifiers.md new file mode 100644 index 0000000..f515fb9 --- /dev/null +++ b/docs/Model/EventIdentifiers.md @@ -0,0 +1,14 @@ +# EventIdentifiers + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**emailId** | **string** | Email Id associated with the event | [optional] +**phoneId** | **string** | SMS associated with the event | [optional] +**whatsappId** | **string** | whatsapp associated with the event | [optional] +**landlineNumberId** | **string** | landline_number associated with the event | [optional] +**extId** | **string** | ext_id associated with the event | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + + diff --git a/lib/Api/EventsApi.php b/lib/Api/EventsApi.php new file mode 100644 index 0000000..88a81c4 --- /dev/null +++ b/lib/Api/EventsApi.php @@ -0,0 +1,361 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation createEvent + * + * Create an event + * + * @param \Brevo\Client\Model\Event $event event (required) + * + * @throws \Brevo\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return void + */ + public function createEvent($event) + { + $this->createEventWithHttpInfo($event); + } + + /** + * Operation createEventWithHttpInfo + * + * Create an event + * + * @param \Brevo\Client\Model\Event $event (required) + * + * @throws \Brevo\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of null, HTTP status code, HTTP response headers (array of strings) + */ + public function createEventWithHttpInfo($event) + { + $returnType = ''; + $request = $this->createEventRequest($event); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + return [null, $statusCode, $response->getHeaders()]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Brevo\Client\Model\ErrorModel', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Brevo\Client\Model\ErrorModel', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation createEventAsync + * + * Create an event + * + * @param \Brevo\Client\Model\Event $event (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createEventAsync($event) + { + return $this->createEventAsyncWithHttpInfo($event) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation createEventAsyncWithHttpInfo + * + * Create an event + * + * @param \Brevo\Client\Model\Event $event (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function createEventAsyncWithHttpInfo($event) + { + $returnType = ''; + $request = $this->createEventRequest($event); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + return [null, $response->getStatusCode(), $response->getHeaders()]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'createEvent' + * + * @param \Brevo\Client\Model\Event $event (required) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function createEventRequest($event) + { + // verify the required parameter 'event' is set + if ($event === null || (is_array($event) && count($event) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $event when calling createEvent' + ); + } + + $resourcePath = '/events'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // body params + $_tempBody = null; + if (isset($event)) { + $_tempBody = $event; + } + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + ['application/json'] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + $httpBody = $_tempBody; + + if($headers['Content-Type'] === 'application/json') { + // \stdClass has no __toString(), so we should encode it manually + if ($httpBody instanceof \stdClass) { + $httpBody = \GuzzleHttp\json_encode($httpBody); + } + // array has no __toString(), so we should encode it manually + if(is_array($httpBody)) { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody)); + } + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + } + } + + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('api-key'); + if ($apiKey !== null) { + $headers['api-key'] = $apiKey; + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('partner-key'); + if ($apiKey !== null) { + $headers['partner-key'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\Query::build($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } +} diff --git a/lib/Model/Event.php b/lib/Model/Event.php new file mode 100644 index 0000000..8335cfe --- /dev/null +++ b/lib/Model/Event.php @@ -0,0 +1,431 @@ + 'string', + 'eventDate' => 'string', + 'identifiers' => '\Brevo\Client\Model\EventIdentifiers', + 'contactProperties' => 'object', + 'eventProperties' => 'object' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'eventName' => null, + 'eventDate' => null, + 'identifiers' => null, + 'contactProperties' => null, + 'eventProperties' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'eventName' => 'event_name', + 'eventDate' => 'event_date', + 'identifiers' => 'identifiers', + 'contactProperties' => 'contact_properties', + 'eventProperties' => 'event_properties' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'eventName' => 'setEventName', + 'eventDate' => 'setEventDate', + 'identifiers' => 'setIdentifiers', + 'contactProperties' => 'setContactProperties', + 'eventProperties' => 'setEventProperties' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'eventName' => 'getEventName', + 'eventDate' => 'getEventDate', + 'identifiers' => 'getIdentifiers', + 'contactProperties' => 'getContactProperties', + 'eventProperties' => 'getEventProperties' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['eventName'] = isset($data['eventName']) ? $data['eventName'] : null; + $this->container['eventDate'] = isset($data['eventDate']) ? $data['eventDate'] : null; + $this->container['identifiers'] = isset($data['identifiers']) ? $data['identifiers'] : null; + $this->container['contactProperties'] = isset($data['contactProperties']) ? $data['contactProperties'] : null; + $this->container['eventProperties'] = isset($data['eventProperties']) ? $data['eventProperties'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + if ($this->container['eventName'] === null) { + $invalidProperties[] = "'eventName' can't be null"; + } + if ($this->container['identifiers'] === null) { + $invalidProperties[] = "'identifiers' can't be null"; + } + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets eventName + * + * @return string + */ + public function getEventName() + { + return $this->container['eventName']; + } + + /** + * Sets eventName + * + * @param string $eventName The name of the event that occurred. This is how you will find your event in Brevo. Limited to 255 characters, alphanumerical characters and - _ only. + * + * @return $this + */ + public function setEventName($eventName) + { + $this->container['eventName'] = $eventName; + + return $this; + } + + /** + * Gets eventDate + * + * @return string + */ + public function getEventDate() + { + return $this->container['eventDate']; + } + + /** + * Sets eventDate + * + * @param string $eventDate Timestamp of when the event occurred (e.g. \"2024-01-24T17:39:57+01:00\"). If no value is passed, the timestamp of the event creation is used. + * + * @return $this + */ + public function setEventDate($eventDate) + { + $this->container['eventDate'] = $eventDate; + + return $this; + } + + /** + * Gets identifiers + * + * @return \Brevo\Client\Model\EventIdentifiers + */ + public function getIdentifiers() + { + return $this->container['identifiers']; + } + + /** + * Sets identifiers + * + * @param \Brevo\Client\Model\EventIdentifiers $identifiers identifiers + * + * @return $this + */ + public function setIdentifiers($identifiers) + { + $this->container['identifiers'] = $identifiers; + + return $this; + } + + /** + * Gets contactProperties + * + * @return object + */ + public function getContactProperties() + { + return $this->container['contactProperties']; + } + + /** + * Sets contactProperties + * + * @param object $contactProperties Properties defining the state of the contact associated to this event. Useful to update contact attributes defined in your contacts database while passing the event. For example: **\"FIRSTNAME\": \"Jane\" , \"AGE\": 37** + * + * @return $this + */ + public function setContactProperties($contactProperties) + { + $this->container['contactProperties'] = $contactProperties; + + return $this; + } + + /** + * Gets eventProperties + * + * @return object + */ + public function getEventProperties() + { + return $this->container['eventProperties']; + } + + /** + * Sets eventProperties + * + * @param object $eventProperties Properties of the event. Top level properties and nested properties can be used to better segment contacts and personalise workflow conditions. The following field type are supported: string, number, boolean (true/false), date (Timestamp e.g. \"2024-01-24T17:39:57+01:00\"). Keys are limited to 255 characters, alphanumerical characters and - _ only. Size is limited to 50Kb. + * + * @return $this + */ + public function setEventProperties($eventProperties) + { + $this->container['eventProperties'] = $eventProperties; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + #[\ReturnTypeWillChange] + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/EventIdentifiers.php b/lib/Model/EventIdentifiers.php new file mode 100644 index 0000000..a71997e --- /dev/null +++ b/lib/Model/EventIdentifiers.php @@ -0,0 +1,426 @@ + 'string', + 'phoneId' => 'string', + 'whatsappId' => 'string', + 'landlineNumberId' => 'string', + 'extId' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $swaggerFormats = [ + 'emailId' => null, + 'phoneId' => null, + 'whatsappId' => null, + 'landlineNumberId' => null, + 'extId' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerTypes() + { + return self::$swaggerTypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function swaggerFormats() + { + return self::$swaggerFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'emailId' => 'email_id', + 'phoneId' => 'phone_id', + 'whatsappId' => 'whatsapp_id', + 'landlineNumberId' => 'landline_number_id', + 'extId' => 'ext_id' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'emailId' => 'setEmailId', + 'phoneId' => 'setPhoneId', + 'whatsappId' => 'setWhatsappId', + 'landlineNumberId' => 'setLandlineNumberId', + 'extId' => 'setExtId' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'emailId' => 'getEmailId', + 'phoneId' => 'getPhoneId', + 'whatsappId' => 'getWhatsappId', + 'landlineNumberId' => 'getLandlineNumberId', + 'extId' => 'getExtId' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$swaggerModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['emailId'] = isset($data['emailId']) ? $data['emailId'] : null; + $this->container['phoneId'] = isset($data['phoneId']) ? $data['phoneId'] : null; + $this->container['whatsappId'] = isset($data['whatsappId']) ? $data['whatsappId'] : null; + $this->container['landlineNumberId'] = isset($data['landlineNumberId']) ? $data['landlineNumberId'] : null; + $this->container['extId'] = isset($data['extId']) ? $data['extId'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets emailId + * + * @return string + */ + public function getEmailId() + { + return $this->container['emailId']; + } + + /** + * Sets emailId + * + * @param string $emailId Email Id associated with the event + * + * @return $this + */ + public function setEmailId($emailId) + { + $this->container['emailId'] = $emailId; + + return $this; + } + + /** + * Gets phoneId + * + * @return string + */ + public function getPhoneId() + { + return $this->container['phoneId']; + } + + /** + * Sets phoneId + * + * @param string $phoneId SMS associated with the event + * + * @return $this + */ + public function setPhoneId($phoneId) + { + $this->container['phoneId'] = $phoneId; + + return $this; + } + + /** + * Gets whatsappId + * + * @return string + */ + public function getWhatsappId() + { + return $this->container['whatsappId']; + } + + /** + * Sets whatsappId + * + * @param string $whatsappId whatsapp associated with the event + * + * @return $this + */ + public function setWhatsappId($whatsappId) + { + $this->container['whatsappId'] = $whatsappId; + + return $this; + } + + /** + * Gets landlineNumberId + * + * @return string + */ + public function getLandlineNumberId() + { + return $this->container['landlineNumberId']; + } + + /** + * Sets landlineNumberId + * + * @param string $landlineNumberId landline_number associated with the event + * + * @return $this + */ + public function setLandlineNumberId($landlineNumberId) + { + $this->container['landlineNumberId'] = $landlineNumberId; + + return $this; + } + + /** + * Gets extId + * + * @return string + */ + public function getExtId() + { + return $this->container['extId']; + } + + /** + * Sets extId + * + * @param string $extId ext_id associated with the event + * + * @return $this + */ + public function setExtId($extId) + { + $this->container['extId'] = $extId; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + #[\ReturnTypeWillChange] + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/test/Api/EventsApiTest.php b/test/Api/EventsApiTest.php new file mode 100644 index 0000000..971a577 --- /dev/null +++ b/test/Api/EventsApiTest.php @@ -0,0 +1,83 @@ +