Private/ConvertFrom-SCAResponse.ps1

function ConvertFrom-SCAResponse {
    <#
    .SYNOPSIS
        Parses a raw CyberArk API response body into PowerShell objects.
    .DESCRIPTION
        Wraps ConvertFrom-Json and optionally stamps a PSTypeName onto the result so downstream
        formatting (Types/Formats) can pick it up. All properties returned by the service are
        preserved as-is; the module never projects a response down to a fixed property list, so
        new fields CyberArk adds to a response show up on the object without a module update.
    .PARAMETER InputObject
        The raw JSON response body.
    .PARAMETER TypeName
        Optional PSTypeName (e.g. 'psSCA.AccessRequest') to add to each returned object.
    .OUTPUTS
        System.Management.Automation.PSCustomObject
    #>

    [CmdletBinding()]
    [OutputType([psobject])]
    param(
        [Parameter(Position = 0)]
        [AllowEmptyString()]
        [string]$InputObject,

        [string]$TypeName
    )

    if ([string]::IsNullOrWhiteSpace($InputObject)) {
        return $null
    }

    $parsed = $InputObject | ConvertFrom-Json -Depth 20

    if ($TypeName) {
        foreach ($item in @($parsed)) {
            if ($item -is [psobject]) {
                $item.PSObject.TypeNames.Insert(0, $TypeName)
            }
        }
    }

    return $parsed
}