Whilst I do agree this is weird, especially on the different options for display, why don’t you simply use system.perspective.closeDock and system.perspective.openDock ?
system.perspective.toggleDock also exists in case you do not keep track of the state of the dock.
Unless obviously you want to change more parameters, but this is also doable using the functions I mentioned above.
The options for display are the push/cover/auto. Unless it's missing from the documentation I don't know if you can change ondemand to visible during runtime.