Private/Format-RyverV1AuthInfoObject.ps1

function Format-RyverV1AuthInfoObject {
    <#
    .SYNOPSIS
        Parse authentication information objects.
 
    .DESCRIPTION
        Parse authentication information objects.
 
    .INPUTS
        System.Management.Automation.PSCustomObject[]
 
    .INPUTS
        System.Management.Automation.PSCustomObject
 
    .NOTES
        - Troy Lindsay
        - Twitter: @troylindsay42
        - GitHub: tlindsay42
 
    .EXAMPLE
 
    .LINK
        https://tlindsay42.github.io/PSRyver/Private/Format-RyverV1AuthInfoObject/
 
    .LINK
        https://github.com/tlindsay42/PSRyver/blob/master/PSRyver/Private/Format-RyverV1AuthInfoObject.ps1
 
    .FUNCTIONALITY
        Ryver
    #>

    [CmdletBinding(
        HelpUri = 'https://tlindsay42.github.io/PSRyver/Private/Format-RyverV1AuthInfoObject/'
    )]
    [OutputType( [PSCustomObject[]] )]
    [OutputType( [PSCustomObject] )]
    param (
        [Parameter(
            Mandatory = $true,
            Position = 0,
            ValueFromPipeline = $true
        )]
        [ValidateNotNull()]
        [PSCustomObject[]]
        $InputObject
    )

    begin {
        $function = $MyInvocation.MyCommand.Name

        Write-Verbose -Message (
            "Beginning: '${function}' with ParameterSetName '$( $PSCmdlet.ParameterSetName )' and Parameters: " +
            ( $PSBoundParameters | Remove-SensitiveData | Format-Table -AutoSize | Out-String )
        )
    }

    process {
        foreach ( $authInfo in $InputObject ) {
            [PSCustomObject] @{
                PSTypeName      = 'PSRyver.AuthInfo'
                IsAuthenticated = [Boolean] $authInfo.OK
                Error           = if ( $authInfo.Error ) { $authInfo.Error } else { }
                Url             = $authInfo.Url
                UserID          = $authInfo.User_ID
                User            = $authInfo.User
                TeamID          = $authInfo.Team_ID
                Team            = $authInfo.Team
                Raw             = $authInfo
            }
        }
    }

    end {
        Write-Verbose -Message "Ending: '${function}'."
    }
}