These changes came from my modifications allowing me to use the module to upload ticket attachments. There are three sets of related changes in this PR:
New-AutotaskBody currently pulls from the $Script:PatchParameter for its picklist. However, some entities do not have patch methods, only post methods. To address this I
Modifed New-ResourceDynamicParameter so that it can iterate over multiple methods and provide a picklist of entities with either a post or a patch method
Modifed Add-AutotaskBaseURI so it creates an additional PostPatchParameter variable with all entities with either a post or a patch method
Modifed New-AutotaskBody so it uses that PostPatchParameter for its picklist and also checks post and patch queries for a url
Some entities do not have UDFs, and when using New-AutotaskBody on these the function fails when it gets a 404. To address this I
Added try/catch around UDF query so that 404 responses do not cause the function to error out (non 404 errors do terminate)
New-AutotaskAPIResource does not handle child entities. To address this I
Added optional parameter ParentId. If a child resource is specified but no parent id is provided, function breaks with informative note.
One note - In order to support child resources, the changes I made to New-AutotaskAPIResource could probably be applied identically to Set-AutotaskAPIResource. However, I don't currently have a use case (or time) to test. In addition, I know you are probably working on child resource enhancements that might conflict with what I did in New-AutotaskAPIResource. If there are conflicts or if this PR feels too targeted, I'm open to making adjustments.
These changes came from my modifications allowing me to use the module to upload ticket attachments. There are three sets of related changes in this PR:
One note - In order to support child resources, the changes I made to New-AutotaskAPIResource could probably be applied identically to Set-AutotaskAPIResource. However, I don't currently have a use case (or time) to test. In addition, I know you are probably working on child resource enhancements that might conflict with what I did in New-AutotaskAPIResource. If there are conflicts or if this PR feels too targeted, I'm open to making adjustments.