Add new fields and pax8 integration
This commit is contained in:
26
layout.xaml
26
layout.xaml
@@ -110,15 +110,33 @@
|
|||||||
<TextBlock Name="PhoneLabel" Text="Phone Number:" Margin="0,10,0,0" Foreground="#cccccc"/>
|
<TextBlock Name="PhoneLabel" Text="Phone Number:" Margin="0,10,0,0" Foreground="#cccccc"/>
|
||||||
<TextBox Name="PhoneBox" Style="{StaticResource RoundedTextBox}"/>
|
<TextBox Name="PhoneBox" Style="{StaticResource RoundedTextBox}"/>
|
||||||
|
|
||||||
|
<TextBlock Name="WebsiteLabel" Text="Website:" Margin="0,5,0,0" Foreground="#cccccc"/>
|
||||||
|
<TextBox Name="WebsiteBox" Style="{StaticResource RoundedTextBox}"/>
|
||||||
|
|
||||||
|
<TextBlock Name="StreetLabel" Text="Street Address:" Margin="0,5,0,0" Foreground="#cccccc"/>
|
||||||
|
<TextBox Name="StreetBox" Style="{StaticResource RoundedTextBox}"/>
|
||||||
|
|
||||||
|
<TextBlock Name="CityLabel" Text="City:" Margin="0,5,0,0" Foreground="#cccccc"/>
|
||||||
|
<TextBox Name="CityBox" Style="{StaticResource RoundedTextBox}"/>
|
||||||
|
|
||||||
|
<TextBlock Name="ProvinceLabel" Text="Province/State:" Margin="0,5,0,0" Foreground="#cccccc"/>
|
||||||
|
<TextBox Name="ProvinceBox" Style="{StaticResource RoundedTextBox}"/>
|
||||||
|
|
||||||
|
<TextBlock Name="PostalLabel" Text="Postal Code:" Margin="0,5,0,0" Foreground="#cccccc"/>
|
||||||
|
<TextBox Name="PostalCodeBox" Style="{StaticResource RoundedTextBox}"/>
|
||||||
|
|
||||||
|
<TextBlock Name="CountryLabel" Text="Country:" Margin="0,5,0,0" Foreground="#cccccc"/>
|
||||||
|
<TextBox Name="CountryBox" Style="{StaticResource RoundedTextBox}"/>
|
||||||
|
|
||||||
<CheckBox Name="SelectAllBox" Content="Select All Tools" Margin="0,15,0,0" FontWeight="Bold" Foreground="White" Style="{StaticResource ModernCheckBox}"/>
|
<CheckBox Name="SelectAllBox" Content="Select All Tools" Margin="0,15,0,0" FontWeight="Bold" Foreground="White" Style="{StaticResource ModernCheckBox}"/>
|
||||||
|
|
||||||
<StackPanel Margin="10,5,0,0">
|
<StackPanel Margin="10,5,0,0">
|
||||||
<CheckBox Name="AutotaskBox" Content="Autotask" Margin="0,4" Style="{StaticResource ModernCheckBox}"/>
|
<CheckBox Name="AutotaskBox" Content="Autotask" Margin="0,4" Style="{StaticResource ModernCheckBox}"/>
|
||||||
<CheckBox Name="DattoBox" Content="Datto RMM" Margin="0,4" Style="{StaticResource ModernCheckBox}"/>
|
<CheckBox Name="DattoBox" Content="Datto RMM" Margin="0,4" Style="{StaticResource ModernCheckBox}"/>
|
||||||
<CheckBox Name="ITGlueBox" Content="ITGlue" Margin="0,4" Style="{StaticResource ModernCheckBox}"/>
|
<CheckBox Name="ITGlueBox" Content="ITGlue (Disabled)" Margin="0,4" Style="{StaticResource ModernCheckBox}"/>
|
||||||
<CheckBox Name="BackupBox" Content="Backup V2" Margin="0,4" Style="{StaticResource ModernCheckBox}"/>
|
<CheckBox Name="BackupBox" Content="Backup V2 (Disabled)" Margin="0,4" Style="{StaticResource ModernCheckBox}"/>
|
||||||
<CheckBox Name="RocketcyberBox" Content="Rocketcyber" Margin="0,4" Style="{StaticResource ModernCheckBox}"/>
|
<CheckBox Name="RocketcyberBox" Content="Rocketcyber (Disabled)" Margin="0,4" Style="{StaticResource ModernCheckBox}"/>
|
||||||
<CheckBox Name="CyberQPBox" Content="Cyber QP" Margin="0,4" Style="{StaticResource ModernCheckBox}"/>
|
<CheckBox Name="CyberQPBox" Content="Cyber QP (Disabled)" Margin="0,4" Style="{StaticResource ModernCheckBox}"/>
|
||||||
<CheckBox Name="Pax8Box" Content="Pax8" Margin="0,4" Style="{StaticResource ModernCheckBox}"/>
|
<CheckBox Name="Pax8Box" Content="Pax8" Margin="0,4" Style="{StaticResource ModernCheckBox}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
|||||||
97
main.ps1
97
main.ps1
@@ -17,6 +17,7 @@ Write-Host "[INFO] MSAL.PS module loaded."
|
|||||||
$urls = @{
|
$urls = @{
|
||||||
autotask = "https://git.svstools.com/cpayne/InstaClientPS/raw/branch/main/tools/autotask.ps1"
|
autotask = "https://git.svstools.com/cpayne/InstaClientPS/raw/branch/main/tools/autotask.ps1"
|
||||||
datto = "https://git.svstools.com/cpayne/InstaClientPS/raw/branch/main/tools/dattormm.ps1"
|
datto = "https://git.svstools.com/cpayne/InstaClientPS/raw/branch/main/tools/dattormm.ps1"
|
||||||
|
pax8 = "https://git.svstools.com/cpayne/InstaClientPS/raw/branch/main/tools/pax8.ps1"
|
||||||
config = "https://git.svstools.com/cpayne/InstaClientPS/raw/branch/main/config.ps1"
|
config = "https://git.svstools.com/cpayne/InstaClientPS/raw/branch/main/config.ps1"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,21 +60,34 @@ Add-Type -AssemblyName WindowsBase
|
|||||||
Add-Type -AssemblyName System.Xaml
|
Add-Type -AssemblyName System.Xaml
|
||||||
|
|
||||||
# Map named UI controls
|
# Map named UI controls
|
||||||
$CompanyNameBox = $window.FindName("CompanyNameBox")
|
$CompanyNameBox = $window.FindName("CompanyNameBox")
|
||||||
$PhoneBox = $window.FindName("PhoneBox")
|
$PhoneBox = $window.FindName("PhoneBox")
|
||||||
$SelectAllBox = $window.FindName("SelectAllBox")
|
$SelectAllBox = $window.FindName("SelectAllBox")
|
||||||
$AutotaskBox = $window.FindName("AutotaskBox")
|
$AutotaskBox = $window.FindName("AutotaskBox")
|
||||||
$DattoBox = $window.FindName("DattoBox")
|
$DattoBox = $window.FindName("DattoBox")
|
||||||
$BackupBox = $window.FindName("BackupBox")
|
$BackupBox = $window.FindName("BackupBox")
|
||||||
$ITGlueBox = $window.FindName("ITGlueBox")
|
$ITGlueBox = $window.FindName("ITGlueBox")
|
||||||
$RocketcyberBox = $window.FindName("RocketcyberBox")
|
$RocketcyberBox = $window.FindName("RocketcyberBox")
|
||||||
$CyberQPBox = $window.FindName("CyberQPBox")
|
$CyberQPBox = $window.FindName("CyberQPBox")
|
||||||
$Pax8Box = $window.FindName("Pax8Box")
|
$Pax8Box = $window.FindName("Pax8Box")
|
||||||
$LoginBtn = $window.FindName("LoginBtn")
|
$LoginBtn = $window.FindName("LoginBtn")
|
||||||
$SubmitBtn = $window.FindName("SubmitBtn")
|
$SubmitBtn = $window.FindName("SubmitBtn")
|
||||||
$StatusBlock = $window.FindName("StatusBlock")
|
$StatusBlock = $window.FindName("StatusBlock")
|
||||||
$phoneLabel = $window.FindName("PhoneLabel")
|
$phoneLabel = $window.FindName("PhoneLabel")
|
||||||
$companyLabel = $window.FindName("CompanyLabel")
|
$companyLabel = $window.FindName("CompanyLabel")
|
||||||
|
$websiteBox = $window.FindName("WebsiteBox")
|
||||||
|
$streetBox = $window.FindName("StreetBox")
|
||||||
|
$cityBox = $window.FindName("CityBox")
|
||||||
|
$provinceBox = $window.FindName("ProvinceBox")
|
||||||
|
$postalCodeBox = $window.FindName("PostalCodeBox")
|
||||||
|
$countryBox = $window.FindName("CountyBox")
|
||||||
|
$websiteLabel = $window.FindName("WebsiteLabel")
|
||||||
|
$streetLabel = $window.FindName("StreetLabel")
|
||||||
|
$cityLabel = $window.FindName("CityLabel")
|
||||||
|
$provinceLabel = $window.FindName("ProvinceLabel")
|
||||||
|
$postalCodeLabel = $window.FindName("PostalCodeLabel")
|
||||||
|
$countryLabel = $window.FindName("CountyLabel")
|
||||||
|
|
||||||
|
|
||||||
$PhoneBox.Visibility = 'Collapsed'
|
$PhoneBox.Visibility = 'Collapsed'
|
||||||
$phoneLabel.Visibility = 'Collapsed'
|
$phoneLabel.Visibility = 'Collapsed'
|
||||||
@@ -88,22 +102,68 @@ $Pax8Box.Visibility = 'Collapsed'
|
|||||||
$SelectAllBox.Visibility = 'Collapsed'
|
$SelectAllBox.Visibility = 'Collapsed'
|
||||||
$CompanyNameBox.Visibility = 'Collapsed'
|
$CompanyNameBox.Visibility = 'Collapsed'
|
||||||
$companyLabel.Visibility = 'Collapsed'
|
$companyLabel.Visibility = 'Collapsed'
|
||||||
|
$websiteBox.Visibility = 'Collapsed'
|
||||||
|
$websiteLabel.Visibility = 'Collapsed'
|
||||||
|
$streetBox.Visibility = 'Collapsed'
|
||||||
|
$streetLabel.Visibility = 'Collapsed'
|
||||||
|
$cityBox.Visibility = 'Collapsed'
|
||||||
|
$cityLabel.Visibility = 'Collapsed'
|
||||||
|
$provinceBox.Visibility = 'Collapsed'
|
||||||
|
$provinceLabel.Visibility = 'Collapsed'
|
||||||
|
$postalCodeBox.Visibility = 'Collapsed'
|
||||||
|
$postalCodeLabel.Visibility = 'Collapsed'
|
||||||
|
$countryBox.Visibility = 'Collapsed'
|
||||||
|
$countryLabel.Visibility = 'Collapsed'
|
||||||
|
|
||||||
$BackupBox.IsEnabled = $false
|
$BackupBox.IsEnabled = $false
|
||||||
$ITGlueBox.IsEnabled = $false
|
$ITGlueBox.IsEnabled = $false
|
||||||
$RocketcyberBox.IsEnabled = $false
|
$RocketcyberBox.IsEnabled = $false
|
||||||
$CyberQPBox.IsEnabled = $false
|
$CyberQPBox.IsEnabled = $false
|
||||||
$Pax8Box.IsEnabled = $false
|
|
||||||
|
|
||||||
$AutotaskBox.Add_Checked({
|
$AutotaskBox.Add_Checked({
|
||||||
$PhoneBox.Visibility = 'Visible'
|
$PhoneBox.Visibility = 'Visible'
|
||||||
$phoneLabel.Visibility = 'Visible'
|
$phoneLabel.Visibility = 'Visible'
|
||||||
})
|
})
|
||||||
|
|
||||||
$AutotaskBox.Add_Unchecked({
|
$AutotaskBox.Add_Unchecked({
|
||||||
$PhoneBox.Visibility = 'Collapsed'
|
$PhoneBox.Visibility = 'Collapsed'
|
||||||
$phoneLabel.Visibility = 'Collapsed'
|
$phoneLabel.Visibility = 'Collapsed'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
$Pax8Box.Add_Checked({
|
||||||
|
$PhoneBox.Visibility = 'Visible'
|
||||||
|
$phoneLabel.Visibility = 'Visible'
|
||||||
|
$websiteBox.Visibility = 'Visible'
|
||||||
|
$websiteLabel.Visibility = 'Visible'
|
||||||
|
$streetBox.Visibility = 'Visible'
|
||||||
|
$streetLabel.Visibility = 'Visible'
|
||||||
|
$cityBox.Visibility = 'Visible'
|
||||||
|
$cityLabel.Visibility = 'Visible'
|
||||||
|
$provinceBox.Visibility = 'Visible'
|
||||||
|
$provinceLabel.Visibility = 'Visible'
|
||||||
|
$postalCodeBox.Visibility = 'Visible'
|
||||||
|
$postalCodeLabel.Visibility = 'Visible'
|
||||||
|
$countryBox.Visibility = 'Visible'
|
||||||
|
$countryLabel.Visibility = 'Visible'
|
||||||
|
})
|
||||||
|
|
||||||
|
$Pax8Box.Add_Unchecked({
|
||||||
|
$PhoneBox.Visibility = 'Collapsed'
|
||||||
|
$phoneLabel.Visibility = 'Collapsed'
|
||||||
|
$websiteBox.Visibility = 'Collapsed'
|
||||||
|
$websiteLabel.Visibility = 'Collapsed'
|
||||||
|
$streetBox.Visibility = 'Collapsed'
|
||||||
|
$streetLabel.Visibility = 'Collapsed'
|
||||||
|
$cityBox.Visibility = 'Collapsed'
|
||||||
|
$cityLabel.Visibility = 'Collapsed'
|
||||||
|
$provinceBox.Visibility = 'Collapsed'
|
||||||
|
$provinceLabel.Visibility = 'Collapsed'
|
||||||
|
$postalCodeBox.Visibility = 'Collapsed'
|
||||||
|
$postalCodeLabel.Visibility = 'Collapsed'
|
||||||
|
$countryBox.Visibility = 'Collapsed'
|
||||||
|
$countryLabel.Visibility = 'Collapsed'
|
||||||
|
})
|
||||||
|
|
||||||
Write-Host "[INFO] UI control references assigned."
|
Write-Host "[INFO] UI control references assigned."
|
||||||
|
|
||||||
# Global tool credentials
|
# Global tool credentials
|
||||||
@@ -223,6 +283,11 @@ $SubmitBtn.Add_Click({
|
|||||||
Invoke-DattoProvision -CompanyName $company -Credentials $script:toolCredentials
|
Invoke-DattoProvision -CompanyName $company -Credentials $script:toolCredentials
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($Pax8Box.IsChecked) {
|
||||||
|
Write-Host "[INFO] Provisioning Pax8..."
|
||||||
|
Invoke-Pax8Provision -CompanyName $company -Phone $phone -Website $WebsiteBox.Text.Trim() -Street $StreetBox.Text.Trim() -City $CityBox.Text.Trim() -Province $ProvinceBox.Text.Trim() -PostalCode $PostalCodeBox.Text.Trim() -Country $CountryBox.Text.Trim() -Credentials $script:toolCredentials
|
||||||
|
}
|
||||||
|
|
||||||
$StatusBlock.Text = "Provisioning completed successfully."
|
$StatusBlock.Text = "Provisioning completed successfully."
|
||||||
Write-Host "[SUCCESS] Provisioning complete."
|
Write-Host "[SUCCESS] Provisioning complete."
|
||||||
$CompanyNameBox.Text = ""
|
$CompanyNameBox.Text = ""
|
||||||
|
|||||||
87
tools/pax8.ps1
Normal file
87
tools/pax8.ps1
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
# pax8.ps1
|
||||||
|
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory = $true)][string]$CompanyName,
|
||||||
|
[Parameter(Mandatory = $true)][string]$Phone,
|
||||||
|
[Parameter(Mandatory = $true)][string]$Website,
|
||||||
|
[Parameter(Mandatory = $true)][string]$Street,
|
||||||
|
[Parameter(Mandatory = $true)][string]$City,
|
||||||
|
[Parameter(Mandatory = $true)][string]$Province,
|
||||||
|
[Parameter(Mandatory = $true)][string]$PostalCode,
|
||||||
|
[Parameter(Mandatory = $true)][string]$Country,
|
||||||
|
[Parameter(Mandatory = $true)][hashtable]$Credentials
|
||||||
|
)
|
||||||
|
|
||||||
|
function Get-Pax8AccessToken {
|
||||||
|
param (
|
||||||
|
[string]$ClientId,
|
||||||
|
[string]$ClientSecret
|
||||||
|
)
|
||||||
|
|
||||||
|
$body = @{
|
||||||
|
client_id = $ClientId
|
||||||
|
client_secret = $ClientSecret
|
||||||
|
audience = "https://api.pax8.com"
|
||||||
|
grant_type = "client_credentials"
|
||||||
|
} | ConvertTo-Json
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = Invoke-RestMethod -Method Post -Uri "https://api.pax8.com/v1/token" -ContentType "application/json" -Body $body
|
||||||
|
return $response.access_token
|
||||||
|
} catch {
|
||||||
|
throw "Failed to obtain Pax8 access token: $($_.Exception.Message)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Invoke-Pax8Provision {
|
||||||
|
param (
|
||||||
|
[string]$CompanyName,
|
||||||
|
[string]$Phone,
|
||||||
|
[string]$Website,
|
||||||
|
[string]$Street,
|
||||||
|
[string]$City,
|
||||||
|
[string]$Province,
|
||||||
|
[string]$PostalCode,
|
||||||
|
[string]$Country,
|
||||||
|
[hashtable]$Credentials
|
||||||
|
)
|
||||||
|
|
||||||
|
$clientId = $Credentials.Pax8Client
|
||||||
|
$clientSecret = $Credentials.Pax8Secret
|
||||||
|
|
||||||
|
if (-not $clientId -or -not $clientSecret) {
|
||||||
|
throw "Missing Pax8 credentials."
|
||||||
|
}
|
||||||
|
|
||||||
|
$accessToken = Get-Pax8AccessToken -ClientId $clientId -ClientSecret $clientSecret
|
||||||
|
|
||||||
|
$companyPayload = @{
|
||||||
|
name = $CompanyName
|
||||||
|
phone = $Phone
|
||||||
|
website = $Website
|
||||||
|
externalId = ""
|
||||||
|
billOnBehalfOfEnabled = $true
|
||||||
|
selfServiceAllowed = $true
|
||||||
|
orderApprovalRequired = $false
|
||||||
|
address = @{
|
||||||
|
street = $Street
|
||||||
|
city = $City
|
||||||
|
stateOrProvince = $Province
|
||||||
|
postalCode = $PostalCode
|
||||||
|
country = $Country
|
||||||
|
}
|
||||||
|
} | ConvertTo-Json -Depth 3
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = Invoke-RestMethod -Method Post -Uri "https://api.pax8.com/v1/companies" `
|
||||||
|
-Headers @{ Authorization = "Bearer $accessToken" } `
|
||||||
|
-ContentType "application/json" -Body $companyPayload
|
||||||
|
|
||||||
|
Write-Host "[PAX8] Company provisioned successfully: $($response.id)"
|
||||||
|
} catch {
|
||||||
|
throw "[PAX8] Company creation failed: $($_.Exception.Message)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Entrypoint if sourced
|
||||||
|
Invoke-Pax8Provision -CompanyName $CompanyName -Phone $Phone -Website $Website -Street $Street -City $City -Province $Province -PostalCode $PostalCode -Country $Country -Credentials $Credentials
|
||||||
Reference in New Issue
Block a user