2020-07-06 13:22:36 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Transformers;
|
|
|
|
|
|
|
|
use App\Models\Webhook;
|
|
|
|
use App\Utils\Traits\MakesHash;
|
|
|
|
|
|
|
|
class WebhookTransformer extends EntityTransformer
|
|
|
|
{
|
|
|
|
use MakesHash;
|
|
|
|
|
|
|
|
protected $defaultIncludes = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $availableIncludes = [];
|
|
|
|
|
|
|
|
/**
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param Webhook $webhook
|
2020-07-06 13:22:36 +02:00
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function transform(Webhook $webhook)
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'id' => (string) $this->encodePrimaryKey($webhook->id),
|
|
|
|
'company_id' => (string) $this->encodePrimaryKey($webhook->company_id),
|
|
|
|
'user_id' => (string) $this->encodePrimaryKey($webhook->user_id),
|
2020-09-06 11:38:10 +02:00
|
|
|
'archived_at' => (int) $webhook->deleted_at,
|
|
|
|
'updated_at' => (int) $webhook->updated_at,
|
|
|
|
'created_at' => (int) $webhook->created_at,
|
|
|
|
'is_deleted' => (bool) $webhook->is_deleted,
|
2020-07-06 13:22:36 +02:00
|
|
|
'target_url' => $webhook->target_url ? (string) $webhook->target_url : '',
|
|
|
|
'event_id' => (string) $webhook->event_id,
|
|
|
|
'format' => (string) $webhook->format,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|