id; } /** * Assign id after insert. * * @param int $id Id. * * @since 0.1.0 */ public function assign_id( int $id ): void { $this->id = $id; } /** * Uuid. * * @since 0.1.0 */ public function uuid(): Uuid { return $this->uuid; } /** * Booking id. * * @since 0.1.0 */ public function booking_id(): ?int { return $this->booking_id; } /** * Customer id. * * @since 0.1.0 */ public function customer_id(): ?int { return $this->customer_id; } /** * Template key. * * @since 0.1.0 */ public function template_key(): string { return $this->template_key; } /** * Channel. * * @since 0.1.0 */ public function channel(): string { return $this->channel; } /** * Recipient. * * @since 0.1.0 */ public function recipient(): string { return $this->recipient; } /** * Subject. * * @since 0.1.0 */ public function subject(): ?string { return $this->subject; } /** * Body. * * @since 0.1.0 */ public function body(): ?string { return $this->body; } /** * Status. * * @since 0.1.0 */ public function status(): NotificationStatus { return $this->status; } /** * Scheduled for. * * @since 0.1.0 */ public function scheduled_for(): ?DateTimeImmutable { return $this->scheduled_for; } /** * Sent at. * * @since 0.1.0 */ public function sent_at(): ?DateTimeImmutable { return $this->sent_at; } /** * Attempts. * * @since 0.1.0 */ public function attempts(): int { return $this->attempts; } /** * Last error. * * @since 0.1.0 */ public function last_error(): ?string { return $this->last_error; } /** * Action scheduler id. * * @since 0.1.0 */ public function action_scheduler_id(): ?int { return $this->action_scheduler_id; } /** * Idempotency key. * * @since 0.1.0 */ public function idempotency_key(): ?string { return $this->idempotency_key; } /** * Reminder id. * * @since 0.1.0 */ public function reminder_id(): ?int { return $this->reminder_id; } /** * Created at. * * @since 0.1.0 */ public function created_at(): DateTimeImmutable { return $this->created_at; } /** * Updated at. * * @since 0.1.0 */ public function updated_at(): DateTimeImmutable { return $this->updated_at; } /** * Mark as drafted (outbound disabled). * * @param DateTimeImmutable $now Now. * * @since 0.1.0 */ public function mark_drafted( DateTimeImmutable $now ): void { $this->status = NotificationStatus::Drafted; $this->updated_at = $now; } /** * Mark sending. * * @param DateTimeImmutable $now Now. * * @since 0.1.0 */ public function mark_sending( DateTimeImmutable $now ): void { $this->status = NotificationStatus::Sending; ++$this->attempts; $this->updated_at = $now; } /** * Mark sent. * * @param DateTimeImmutable $now Now. * * @since 0.1.0 */ public function mark_sent( DateTimeImmutable $now ): void { $this->status = NotificationStatus::Sent; $this->sent_at = $now; $this->last_error = null; $this->updated_at = $now; } /** * Mark failed. * * @param string $error Error. * @param DateTimeImmutable $now Now. * * @since 0.1.0 */ public function mark_failed( string $error, DateTimeImmutable $now ): void { $this->status = NotificationStatus::Failed; $this->last_error = substr( $error, 0, 1000 ); $this->updated_at = $now; } /** * Mark cancelled. * * @param DateTimeImmutable $now Now. * * @since 0.1.0 */ public function mark_cancelled( DateTimeImmutable $now ): void { $this->status = NotificationStatus::Cancelled; $this->updated_at = $now; } /** * Re-queue after a retryable failure. * * @param DateTimeImmutable $now Now. * * @since 0.1.0 */ public function requeue( DateTimeImmutable $now ): void { $this->status = NotificationStatus::Queued; $this->updated_at = $now; } /** * Bind Action Scheduler id. * * @param int $action_id Action id. * @param DateTimeImmutable $now Now. * * @since 0.1.0 */ public function bind_action( int $action_id, DateTimeImmutable $now ): void { $this->action_scheduler_id = $action_id; $this->updated_at = $now; } }