public/api/Get-MBSAPIFilteredBilling.ps1

function Get-MBSAPIFilteredBilling {
    <#
    .SYNOPSIS
    Gets a filter billing report
     
    .DESCRIPTION
    Calls the PUT api/Billing API to get a filtered billing report with the option to specify a company or date.
     
    .PARAMETER CompanyName
    Name of the company
     
    .PARAMETER Date
    Date from which the report would start.
     
    .PARAMETER ProfileName
    Profile name used with MSP360 PowerShell for MBS API (set via Set-MBSApiCredential)
     
    .EXAMPLE
    Get-MBSAPIFilteredBilling -ProfileName ao -Date (Get-Date -year 2020 -month 1 -Format s)
 
    Get filtered billing for the specified period
     
    .EXAMPLE
    Get-MBSAPIFilteredBilling -ProfileName ao -Company 'test'
 
    Get billing of the specified company for the current month
     
    .INPUTS
    System.Management.Automation.PSCustomObject
 
    .OUTPUTS
    System.Management.Automation.PSCustomObject
 
    .NOTES
        Author: Andrey Oshukov
    .LINK
 
    #>

    
    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$false, HelpMessage="The company name", ValueFromPipelineByPropertyName)]
        [string]$CompanyName,
        [Parameter(Mandatory=$false, HelpMessage="Date range", ValueFromPipelineByPropertyName)]
        [string]$Date,
        [Parameter(Mandatory=$false, HelpMessage="The profile name")]
        [string]$ProfileName
    )
    begin {
        
    }
    process {
        $FilteredBillingPut = New-Object -TypeName PSCustomObject -Property ([ordered]@{
            CompanyName = $CompanyName
            Date = $Date    
        })
        $FilteredBillingPut = Remove-NullProperties ($FilteredBillingPut)
        $FilteredBilling = Invoke-RestMethod -Uri ((Get-MBSApiUrl).Billing) -Method Put -Headers (Get-MBSAPIHeader -ProfileName $ProfileName) -Body ($FilteredBillingPut | ConvertTo-Json) -ContentType 'application/json'
        return $FilteredBilling
    }
    end {
    }
}