. */ declare(strict_types=1); namespace FireflyIII\Transformers; use FireflyIII\Models\WebhookMessage; /** * Class WebhookMessageTransformer */ class WebhookMessageTransformer extends AbstractTransformer { /** * Transform the preference */ public function transform(WebhookMessage $message): array { $json = '{}'; try { $json = json_encode($message->message, JSON_THROW_ON_ERROR); } catch (\JsonException $e) { app('log')->error(sprintf('Could not encode webhook message #%d: %s', $message->id, $e->getMessage())); } return [ 'id' => (string)$message->id, 'created_at' => $message->created_at->toAtomString(), 'updated_at' => $message->updated_at->toAtomString(), 'sent' => $message->sent, 'errored' => $message->errored, 'webhook_id' => (string)$message->webhook_id, 'uuid' => $message->uuid, 'message' => $json, ]; } }