id = isset($data['id']) ? (int)$data['id'] : null; $this->submissionId = $data['submission_id'] ?? ''; $this->providerId = $data['provider_id'] ?? ''; $this->formId = $data['form_id'] ?? ''; $this->connectionId = $data['connection_id'] ?? ''; $this->spreadsheetIdMasked = $data['spreadsheet_id_masked'] ?? ''; $this->worksheetName = $data['worksheet_name'] ?? ''; $this->status = $data['status'] ?? 'success'; $this->errorCode = $data['error_code'] ?? null; $this->errorMessage = $data['error_message'] ?? null; $rawPayload = $data['payload'] ?? null; if (is_string($rawPayload)) { $this->payload = json_decode($rawPayload, true); } else { $this->payload = is_array($rawPayload) ? $rawPayload : null; } $this->createdAt = $data['created_at'] ?? current_time('mysql'); } /** * Convert log entry to an array format. * * @return array */ public function toArray(): array { return [ 'id' => $this->id, 'submission_id' => $this->submissionId, 'provider_id' => $this->providerId, 'form_id' => $this->formId, 'connection_id' => $this->connectionId, 'spreadsheet_id_masked' => $this->spreadsheetIdMasked, 'worksheet_name' => $this->worksheetName, 'status' => $this->status, 'error_code' => $this->errorCode, 'error_message' => $this->errorMessage, 'payload' => $this->payload ? json_encode($this->payload) : null, 'created_at' => $this->createdAt, ]; } // Getters and Setters public function getId(): ?int { return $this->id; } public function setId(int $id): void { $this->id = $id; } public function getSubmissionId(): string { return $this->submissionId; } public function getProviderId(): string { return $this->providerId; } public function getFormId(): string { return $this->formId; } public function getConnectionId(): string { return $this->connectionId; } public function getSpreadsheetIdMasked(): string { return $this->spreadsheetIdMasked; } public function getWorksheetName(): string { return $this->worksheetName; } public function getStatus(): string { return $this->status; } public function getErrorCode(): ?string { return $this->errorCode; } public function getErrorMessage(): ?string { return $this->errorMessage; } public function getPayload(): ?array { return $this->payload; } public function getCreatedAt(): string { return $this->createdAt; } }