-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from greenlighttec/develop
Added some helper cmdlets
- Loading branch information
Showing
4 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
35 changes: 35 additions & 0 deletions
35
Public/Helpers/Import-HaloSuppliersFromAccountingPackage.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 $_ | ||
} | ||
} |