guard_admin(); if ( $check ) { return $check; } if ( $staff_id <= 0 || ! class_exists( '\Timetics\Core\Staffs\Staff' ) ) { return [ 'error' => 'A valid staff_id is required.' ]; } $staff = new \Timetics\Core\Staffs\Staff( $staff_id ); if ( ! $staff->is_staff() ) { return [ 'error' => "Staff #{$staff_id} was not found." ]; } if ( ! function_exists( 'timetics_get_staff_integrations' ) ) { return [ 'error' => 'Timetics integrations are unavailable.' ]; } try { $integrations = timetics_get_staff_integrations( $staff_id ); return [ 'staff_id' => $staff_id, 'integrations' => $this->shape_rows( (array) $integrations, fn( $integration ) => [ 'id' => $integration['id'] ?? '', 'name' => $integration['name'] ?? '', 'connected' => ! empty( $integration['connected'] ), 'setup' => ! empty( $integration['setup'] ), ] ), ]; } catch ( \Throwable $e ) { Log::error( 'Timetics_Get_Staff_Integrations_Tool error', [ 'error' => $e->getMessage() ] ); return [ 'error' => 'Failed to get staff integrations: ' . $e->getMessage() ]; } } }