Private/Send-GlimpsMalwareApiRequest.ps1

function Send-GlimpsMalwareApiRequest {

    [CmdletBinding()]
    Param (
        [Parameter(Position = 0)]
        [Microsoft.PowerShell.Commands.WebRequestMethod]
        $Method = 'Get',

        [Parameter(
            Mandatory = $true,
            Position = 1
        )]
        [System.Uri]
        $Uri,

        [Parameter(Position = 3)]
        [System.Object]
        $Body
    )
    Begin {
    }
    Process {
        $params = @{
            Method      = $Method
            Uri         = $uri
            Headers     = @{"Accept"="application/json"; "X-Auth-Token"=$(New-Object PSCredential 0, $_ApiKey).GetNetworkCredential().Password}
        }
        if ($null -ne $body) {
            Write-Debug "Adding body to payload"
            $params.Add("Body",$($body | ConvertTo-Json))
        }
        Try {
            Write-Verbose "Params: $($params | convertto-json -Compress)"
            $WebResponse = Invoke-WebRequest @params
            $WebResponse
        } Catch {
            throw $_
        }
    }
    End {

    }

}