"value1", "2" => "value2"] * - 360dialog: ["body" => [["type" => "text", "text" => "value"]], "header" => [...]] */ public array $variables = []; /** * Header parameters (for templates with headers) */ public array $headerParams = []; /** * Button parameters (for templates with dynamic buttons) */ public array $buttonParams = []; /** * Optional booking ID to link */ public ?int $bookingId = null; /** * Optional customer ID to link */ public ?int $customerId = null; /** * Create a new SendTemplateRequest * * @param string $toPhone * @param string $templateId */ public function __construct(string $toPhone, string $templateId) { $this->toPhone = $toPhone; $this->templateId = $templateId; } /** * Create from array * * @param array $data * @return static */ public static function fromArray(array $data): static { $request = new static( $data['to_phone'] ?? $data['toPhone'] ?? '', $data['template_id'] ?? $data['templateId'] ?? $data['content_sid'] ?? '' ); $request->templateName = $data['template_name'] ?? $data['templateName'] ?? null; $request->language = $data['language'] ?? 'en'; $request->variables = $data['variables'] ?? []; $request->headerParams = $data['header_params'] ?? $data['headerParams'] ?? []; $request->buttonParams = $data['button_params'] ?? $data['buttonParams'] ?? []; $request->bookingId = $data['booking_id'] ?? $data['bookingId'] ?? null; $request->customerId = $data['customer_id'] ?? $data['customerId'] ?? null; return $request; } /** * Set template name * * @param string|null $name * @return $this */ public function withName(?string $name): static { $this->templateName = $name; return $this; } /** * Set language * * @param string $language * @return $this */ public function withLanguage(string $language): static { $this->language = $language; return $this; } /** * Set variables * * @param array $variables * @return $this */ public function withVariables(array $variables): static { $this->variables = $variables; return $this; } /** * Set header parameters * * @param array $params * @return $this */ public function withHeaderParams(array $params): static { $this->headerParams = $params; return $this; } /** * Set button parameters * * @param array $params * @return $this */ public function withButtonParams(array $params): static { $this->buttonParams = $params; return $this; } /** * 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; } /** * Convert to array * * @return array */ public function toArray(): array { return [ 'to_phone' => $this->toPhone, 'template_id' => $this->templateId, 'template_name' => $this->templateName, 'language' => $this->language, 'variables' => $this->variables, 'header_params' => $this->headerParams, 'button_params' => $this->buttonParams, 'booking_id' => $this->bookingId, 'customer_id' => $this->customerId, ]; } /** * Create a booking template request with common variables * * @param string $toPhone * @param string $templateId * @param array $bookingData ['customer_name', 'date', 'time', 'party', etc.] * @param int|null $bookingId * @param int|null $customerId * @return static */ public static function forBooking( string $toPhone, string $templateId, array $bookingData, ?int $bookingId = null, ?int $customerId = null ): static { $request = new static($toPhone, $templateId); $request->bookingId = $bookingId; $request->customerId = $customerId; // Store raw booking data - provider will format appropriately $request->variables = $bookingData; return $request; } }