Using DBus in Plasmoid

I’m trying to use org.kde.plasma.workspace.dbus with a plasmoid and can’t figure out how to get it to work. Since there doesn’t seem to be a section on it in api.kde.org, I looked through the source and found this: components/dbus/dbusconnection.h · master · Plasma / Plasma Workspace · GitLab . When using the snippet

import org.kde.plasma.workspace.dbus
...
    const pendingReply = SessionBus.asyncCall({
      "service": "org.kde.plasmashell",
      "path": "/PlasmaShell",
      "iface": "org.kde.PlasmaShell",
      "member": "wallpaper",
      "signature": "(u)",
      "arguments": [
        new DBus.uint32(0)
      ],
    })
    pendingReply.finished.connect(() => {
      console.log("Current wallpaper is", pendingReply.value["wallpaperPlugin"])
      pendingReply.destroy()
    })
...

The code throws ReferenceError: DBus is not defined. Is there any additional imports required with this? I tried looking through lxr but couldn’t find anywhere this is used.

Nvm, I managed to get it to work. For some reason import org.kde.plasma.workspace.dbus when used without DBus namespace (just unit32 and SessionBus ) doesn’t work, but namespacing import org.kde.plasma.workspace.dbus as DBus along with DBus.SessionBusand DBus.unit32 works.