Closed Persistent13 closed 8 years ago
I like the idea. In fact, it is one of my original long term plans. I didn't implement it from the beginning because I wanted to review other 3rd-party POSH modules first. So that I could research how the other modules are implementing this type of pattern and what common practices that are followed.
Why wait? We can add it now. That said, I believe it should be implement slightly different. The end result would be the same. Instead of the functions asking for the domain, company, and keys, ask only for the CWApiRestConnectionInfo
object that's saved as a script variable.
Proposal
Get-CWConnectionInfo
saves the object to a single global/script scoped variable. $CWServer
, $CWServerInfo
, or something prefixed with CW or ConnectWise. Reasons
CWApiRestConnectionInfo
object up the stack.CWApiRestConnectionInfo
object is created, it will make web request call to the CW server to find its code base (via _setCodeBase()
). So it is not efficient.No problem.
I'll be updating the code and I'll post a comment when I'm complete.
Hi @sgtoj
I've updated the pull request with the changed you asked for; no issues with the pester tests either.
Let me know what you think when you get the chance.
Thanks, Dakota Clark
Thank you! Took me longer than I expected. Because I have made several changes in the past couple weeks, I had to fix many conflicts with the master branch. None the less, your contributions were merged with the master.
Hello @sgtoj
I've re-written the cmdlets to automatically add the server connection information once entered into the Get-CWConnectionInfo cmdlet.
I've done so by placing the Domain, CompanyName, PublicKey, and PrivateKey variables into scoped variables that are available to the module but not the end user.
I've also added the pararmters to each cmdlet in the module so if required or preferred by the end user they may still run the cmdlets without first running the Get-CWConnectionInfo cmdlet.
Some examples of the change below:
And without running Get-CWConnectionInfo
I've adjust all the pester tests and verified them working with this change.
Let me know if you have any questions!
Thanks, Dakota Clark