The type field was always being sent to the API even if a value wasn't
given. Change code to only send type field if --type was actually used
as an argument
Added tests for this case
Change-Id: Idb495eceb189db341753fd82be57d414e17cd64b
Closes-Bug: #1664326