diff --git a/HaloAPI.psd1 b/HaloAPI.psd1 index fb6d407..365596c 100644 --- a/HaloAPI.psd1 +++ b/HaloAPI.psd1 @@ -107,6 +107,7 @@ 'Get-HaloSoftwareLicence', 'Get-HaloStatus', 'Get-HaloSupplier', + 'Get-HaloSuppliersFromQBO', 'Get-HaloTeam', 'Get-HaloTicket', 'Get-HaloTicketRules', @@ -116,7 +117,9 @@ 'Get-HaloWorkday', 'Get-HaloWorkflow', 'Get-HaloWorkflows', + 'Import-HaloSuppliersFromAccountingPackage', 'Invoke-HaloRequest', + 'Invoke-HaloSQL', 'New-HaloAction', 'New-HaloActionBatch', 'New-HaloAgent', diff --git a/Public/Helpers/Get-HaloSuppliersFromQBO.ps1 b/Public/Helpers/Get-HaloSuppliersFromQBO.ps1 new file mode 100644 index 0000000..b72cc8c --- /dev/null +++ b/Public/Helpers/Get-HaloSuppliersFromQBO.ps1 @@ -0,0 +1,19 @@ +function Get-HaloSuppliersFromQBO { + param[ + [int32]$ConnectionID, + [string]$datatype = 'vendor' + ] + + $QSCollection = New-HaloQuery -CommandName $CommandName -Parameters $Parameters -IsMulti + $Resource = 'api/integrationdata/get/quickbooksonline' + $RequestParams = @{ + Method = 'GET' + Resource = $Resource + AutoPaginateOff = $Paginate + QSCollection = $QSCollection + ResourceType = 'releases' + } + + $QBOVendors = New-HaloGETRequest @RequestParams + Return $QBOVendors +} \ No newline at end of file diff --git a/Public/Helpers/Import-HaloSuppliersFromAccountingPackage.ps1 b/Public/Helpers/Import-HaloSuppliersFromAccountingPackage.ps1 new file mode 100644 index 0000000..f5de624 --- /dev/null +++ b/Public/Helpers/Import-HaloSuppliersFromAccountingPackage.ps1 @@ -0,0 +1,35 @@ +function Import-HaloSupplierFromQBO { + [CmdletBinding()] + param ( + [Parameter()] + [System.Object] + $APSupplier, + [Parameter()] + [string] + $ImportType = 'quickbooksonline', + [Parameter()] + [string] + $APCompanyID + ) + [PSCustomObject]$returnData = @{ + _isimport = $true + _importtype = $ImportType + accounts_id = $APSupplier.id + details_id = 1 + qbo_company_id = $APCompanyID + name = $APSupplier.companyName + address = "$($APSupplier.billAddr.line1)`n$($APSupplier.billAddr.city)`n$($APSupplier.billAddr.countrySubDivisionCode)`n$($APSupplier.billAddr.postalCode)" + } + + if ($Email = $APSupplier.primaryEmailAddr.address) { + Add-Member -InputObject $returnData -Name email_address -Value $Email -MemberType NoteProperty -Force + } + if ($PhoneNumber = $APSupplier.printOnCheckName.freeFormNumber) { + Add-Member -InputObject $returnData -Name phone_number -Value $PhoneNumber -MemberType NoteProperty -Force + } + + if (($FirstName = $APSupplier.givenName) -or ($LastName = $APSupplier.familyName)) { + Add-Member -InputObject $returnData -Name contact_name -Value ("$($FirstName) $($LastName)".trim()) -MemberType NoteProperty -Force + } + return $returnData +} \ No newline at end of file diff --git a/Public/Invoke/Invoke-HaloSQL.ps1 b/Public/Invoke/Invoke-HaloSQL.ps1 new file mode 100644 index 0000000..8d74ba1 --- /dev/null +++ b/Public/Invoke/Invoke-HaloSQL.ps1 @@ -0,0 +1,47 @@ +Function Invoke-HaloSQL { + <# + .SYNOPSIS + Uses the Reports API endpoint to run arbitrary SQL. + .DESCRIPTION + Function to run a report preview with a SQL query parameter. Use -IncludeFullReport to get the entire report object instead of just the results + .OUTPUTS + Outputs an object containing the response from the web request. + #> + [CmdletBinding( SupportsShouldProcess = $True )] + [OutputType([Object[]])] + Param ( + # String or Here String for SQL Statement + [Parameter( Mandatory = $True, ValueFromPipeline )] + [String]$SQLQuery, + # Return Full Report Object. + [Parameter()] + [Switch]$IncludeFullReport + ) + Invoke-HaloPreFlightCheck + try { + $Payload = @(@{id = 0; name= ''; sql = $SQLQuery; apiquery_id = 0; "_testonly" = $false; "_loadreportonly" = $true}) + if ($PSCmdlet.ShouldProcess($Payload -is [Array] ? 'Reports' : 'Report', 'Execute')) { + $Report = New-HaloPOSTRequest -Object $Payload -Endpoint 'report' + if (-not $Report.report.load_error) { + + if ($Report.report.rows.count -eq 0) { + throw "No results were returned" + } + + else { + if ($IncludeFullReport) { + return $Report + } + else { + return $Report.report.rows + } + } + } else { + Throw $Report.report.load_error + } + } + + } catch { + New-HaloError -ErrorRecord $_ + } +}