toPhone = $toPhone; $this->body = $body; } /** * Create from array * * @param array $data * @return static */ public static function fromArray(array $data): static { $request = new static( $data['to_phone'] ?? $data['toPhone'] ?? '', $data['body'] ?? $data['message'] ?? '' ); $request->bookingId = $data['booking_id'] ?? $data['bookingId'] ?? null; $request->customerId = $data['customer_id'] ?? $data['customerId'] ?? null; $request->mediaUrl = $data['media_url'] ?? $data['mediaUrl'] ?? null; $request->previewUrl = $data['preview_url'] ?? $data['previewUrl'] ?? false; return $request; } /** * Set booking ID * * @param int|null $bookingId * @return $this */ public function withBooking(?int $bookingId): static { $this->bookingId = $bookingId; return $this; } /** * Set customer ID * * @param int|null $customerId * @return $this */ public function withCustomer(?int $customerId): static { $this->customerId = $customerId; return $this; } /** * Set media URL * * @param string|null $mediaUrl * @return $this */ public function withMedia(?string $mediaUrl): static { $this->mediaUrl = $mediaUrl; return $this; } /** * Enable URL preview * * @param bool $preview * @return $this */ public function withUrlPreview(bool $preview = true): static { $this->previewUrl = $preview; return $this; } /** * Convert to array * * @return array */ public function toArray(): array { return [ 'to_phone' => $this->toPhone, 'body' => $this->body, 'booking_id' => $this->bookingId, 'customer_id' => $this->customerId, 'media_url' => $this->mediaUrl, 'preview_url' => $this->previewUrl, ]; } }