refactored to add idempotence/abstraction and remove duplication

Joined separate 'update template for category and pkg, then POST XML'
calls into one customizeAndPostXMLtoAPI. Made pkg copy idempotent.
TODO: all previous and output variables