Public/Curanet/Get-CuranetCustomerSubscriptions.ps1

function Get-CuranetCustomerSubscriptions() {
    Param(
        [Parameter()]
        [string]$CustomerId
    )
    # Get a Curanet 3850 API access token
    $AccessToken = Get-CuranetAccessToken

    $AuthorizationHeader = @{
        Authorization="Bearer $AccessToken"
    }
    if($CustomerId) {
        try {
            $Subscriptions = (Invoke-WebRequest -Uri "https://api.curanet.dk/customers/v1/Customers/$($CustomerId)/Subscriptions" -Headers $AuthorizationHeader -UseBasicParsing -Method GET).Content | ConvertFrom-Json
        } catch {
            throw "Failed to retreive subscriptions from Curanet 3850 API: $_"
        }
    } else {
        try {
            $Subscriptions = (Invoke-WebRequest -Uri "https://api.curanet.dk/customers/v1/Customers/Subscriptions" -Headers $AuthorizationHeader -UseBasicParsing -Method GET).Content | ConvertFrom-Json
        } catch {
            throw "Failed to retreive subscriptions from Curanet 3850 API: $_"
        }
    }


    return $Subscriptions
}