customers->resolveFor('service', $row['domain'] ?: $row['id'], (int) $row['userid']), productId: $this->products->resolve((int) $row['packageid']), legacyProductId: (int) $row['packageid'], orderItemId: $this->orderItems->resolve($legacyId), serverName: $row['domain'] ?: null, status: $this->mapStatus($row['domainstatus']), autoRenew: $row['billingcycle'] !== 'One Time', startedAt: $this->nullableDate($row['regdate'] ?? null), expiresAt: $this->nullableDate($row['nextduedate'] ?? null), cancelledAt: $this->nullableDate($row['termination_date'] ?? null), note: $row['notes'] ?: null, ); } /** * services.status: pending, active, suspended, expired, cancelled, terminated. */ private function mapStatus(string $whmcsStatus): string { return match ($whmcsStatus) { 'Active', 'Completed' => 'active', 'Suspended' => 'suspended', 'Terminated' => 'terminated', 'Cancelled', 'Fraud' => 'cancelled', default => 'pending', }; } private function nullableDate(?string $value): ?string { if (! $value || (int) substr($value, 0, 4) < 1970) { return null; } return $value; } }