Skip to content

Commit

Permalink
2.0.2beta - 2022-07-07
Browse files Browse the repository at this point in the history
#### Critical

**Comment DTO**

- Replaced $body_without_blockquote variable with $body_filtered
- Dropped $body_only_blockquote

#### Core
- Dropped support for PHP versions below < 8.1
- Replaced PHPUnit for PEST
- Moved HTTP requests to a dedicated class `RequestClass.php`

#### Improvements

- Added dynamic retry values for failed HTTP requests that can be set via the configuration file.
- You can now pass User attributes within the searchOrCreateByEmail method to update or create user
  attributes within the same request.
- Added a dynamic HTML Stripe-Out possibiliites via configuration file.
- Define via configuration variable if a 'Unprocessable Entity' response related to an object reference should be
  ignored. [More information](https://docs.zammad.org/en/latest/api/user.html#update).

#### Features

- Create & Update Zammad Objects
- Update Zammad User
  • Loading branch information
StanBarrows authored Jul 7, 2022
1 parent ca79c92 commit e3d9ec4
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 32 deletions.
9 changes: 4 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

All notable changes to `laravel-zammad` will be documented in this file.

### 2.0.0beta - 2022-07-06
### 2.0.2beta - 2022-07-07

#### Critical

Expand All @@ -12,17 +12,16 @@ All notable changes to `laravel-zammad` will be documented in this file.
- Dropped $body_only_blockquote

#### Core

- Dropped support for PHP versions below 8.1
- Dropped support for PHP versions below < 8.1
- Replaced PHPUnit for PEST
- Moved HTTP requests to a dedicated class `RequestClass.php`

#### Improvements

- Added dynamic retry values for failed HTTP requests that can be set via the configuration file
- Added dynamic retry values for failed HTTP requests that can be set via the configuration file.
- You can now pass User attributes within the searchOrCreateByEmail method to update or create user
attributes within the same request.
- Added a dynamic HTML Stripe-Out for Signature and Replied HTML via the configuration file
- Added a dynamic HTML Stripe-Out possibiliites via configuration file.
- Define via configuration variable if a 'Unprocessable Entity' response related to an object reference should be
ignored. [More information](https://docs.zammad.org/en/latest/api/user.html#update).

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ return [
|
*/

'http_retry_maximum' => env('ZAMMAD_HTTP_RETRY_MAXIMUM', 5),
'http_retry_delay' => env('ZAMMAD_HTTP_RETRY_DELAY', 1000),
'http_retry_maximum' => env('ZAMMAD_HTTP_RETRY_MAXIMUM', 3),
'http_retry_delay' => env('ZAMMAD_HTTP_RETRY_DELAY', 1500),

/*
|--------------------------------------------------------------------------
Expand All @@ -447,6 +447,7 @@ return [
*/

'filter_images' => true,
'filter_tables' => true,
'filter_signature_marker' => true,
'filter_signature_marker_value' => '<span class="js-signatureMarker"></span>',
'filter_data_signature' => true,
Expand All @@ -470,7 +471,6 @@ return [
],

];

```

## 🚧 Testing
Expand Down
3 changes: 2 additions & 1 deletion config/zammad.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/

'http_retry_maximum' => env('ZAMMAD_HTTP_RETRY_MAXIMUM', 3),
'http_retry_delay' => env('ZAMMAD_HTTP_RETRY_DELAY', 2500),
'http_retry_delay' => env('ZAMMAD_HTTP_RETRY_DELAY', 1500),

/*
|--------------------------------------------------------------------------
Expand All @@ -65,6 +65,7 @@
*/

'filter_images' => true,
'filter_tables' => true,
'filter_signature_marker' => true,
'filter_signature_marker_value' => '<span class="js-signatureMarker"></span>',
'filter_data_signature' => true,
Expand Down
21 changes: 2 additions & 19 deletions src/Classes/RequestClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,6 @@ public function __construct()
$this->objectHasReferenceError = config('zammad.objet_reference_error');
}

/**
* @throws \Illuminate\Http\Client\RequestException
*/
public function getRequestOnBehalf($userId, $url): Response
{
$response = Http::withToken(config('zammad.token'))
->withHeaders([
'X-On-Behalf-Of' => $userId,
])
->retry($this->httpRetryMaxium, $this->httpRetryDelay)
->get($url);

event(new ZammadResponseLog($response));

return $response->throw();
}

/**
* @throws \Illuminate\Http\Client\RequestException
*/
Expand All @@ -63,7 +46,7 @@ public function getRequest($url): Response
public function postRequest($url, $data = null): Response
{
$response = Http::withToken(config('zammad.token'))
// ->retry($this->httpRetryMaxium, $this->httpRetryDelay)
->retry($this->httpRetryMaxium, $this->httpRetryDelay)
->post($url, $data);

event(new ZammadResponseLog($response));
Expand Down Expand Up @@ -91,7 +74,7 @@ public function putRequest($url, $data): Response
public function deleteRequest($url): Response
{
$response = Http::withToken(config('zammad.token'))
// ->retry($this->httpRetryMaxium, $this->httpRetryDelay)
//->retry($this->httpRetryMaxium, $this->httpRetryDelay)
->delete($url);

$ignoreReferenceError = [
Expand Down
7 changes: 6 additions & 1 deletion src/DTO/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static function fromJson(array $data): self
});

$filterImages = config('zammad.filter_images');
$filterTables = config('zammad.filter_tables');
$filterSigantureMarker = config('zammad.filter_signature_marker');
$filterSigantureMarkerValue = config('zammad.filter_signature_marker_value');
$filterDataSignature = config('zammad.filter_data_signature');
Expand All @@ -32,7 +33,11 @@ public static function fromJson(array $data): self
$bodyFiltered = $data['body'];

if ($filterImages) {
$bodyFiltered = preg_replace("/<img[^>]+\>/i", ' ', $bodyFiltered);
$bodyFiltered = preg_replace("/<img[^>]+\>/i", '$1', $bodyFiltered);
}

if ($filterTables) {
$bodyFiltered = preg_replace("/<table[^>]+\>/i", '$1', $bodyFiltered);
}

if ($filterSigantureMarker) {
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/CommentResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public function showByTicket(int $id): Collection

$response = self::getRequest($url);

$comment = $response->json();
$comments = $response->json();

return collect($comment)->map(fn (array $comment) => Comment::fromJson($comment));
return collect($comments)->map(fn (array $comment) => Comment::fromJson($comment));
}

public function show(int $id): ?Comment
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/ObjectAttributeResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@
Event::assertDispatched(ZammadResponseLog::class, 2);
})->group('objects');

# this test is migrating the zammad database which can take up to 30seconds.
it('execute database migrations', function () {
(new Zammad())->object()->executeMigrations();
Event::assertDispatched(ZammadResponseLog::class, 1);
sleep(30);
})->group('objects');
2 changes: 1 addition & 1 deletion tests/Feature/UserAccessTokenRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
it('creates a user token', function () {
$data = [
'label' => Str::orderedUuid()->toString(),
'permission' => [],
'permission' => ['admin'],
];
$token = (new Zammad())->userAccesstoken()->create($data);
Event::assertDispatched(ZammadResponseLog::class, 1);
Expand Down

0 comments on commit e3d9ec4

Please sign in to comment.