Public/Get-RyverAuth.ps1

function Get-RyverAuth {
    <#
    .SYNOPSIS
        Checks authentication and tells you who you are.
 
    .DESCRIPTION
        Checks authentication and tells you who you are.
 
    .INPUTS
        System.Management.Automation.PSCredential
 
    .NOTES
        - Troy Lindsay
        - Twitter: @troylindsay42
        - GitHub: tlindsay42
 
    .EXAMPLE
        Get-RyverAuth
        Checks authentication and retrieves the information of the default user
        specified by Get-PSRyverConfig.
 
    .EXAMPLE
        Get-RyverAuth -Raw
        Checks authentication and retrieves the information of the default user
        specified by Get-PSRyverConfig. Returns raw output.
 
    .EXAMPLE
        Get-RyverAuth -Credential ( Get-Credential )
        Checks authentication and retrieves the information of the user specified.
 
    .EXAMPLE
        Get-RyverAuth -Raw -Credential ( Get-Credential )
        Checks authentication and retrieves the information of the user specified.
        Returns raw output.
 
    .LINK
        https://tlindsay42.github.io/PSRyver/Public/Get-RyverAuth/
 
    .LINK
        https://github.com/tlindsay42/PSRyver/blob/master/PSRyver/Public/Get-PSRyverAuth.ps1
 
    .FUNCTIONALITY
        Ryver
    #>


    [CmdletBinding(
        HelpUri = 'https://tlindsay42.github.io/PSRyver/Public/Get-RyverAuth/'
    )]
    [OutputType( [PSCustomObject] )]
    param (
        <#
        Credentials to use for the Ryver API.
 
        Default value is the value set by Set-PSRyverConfig.
        #>

        [Parameter(
            Position = 0,
            ValueFromPipeline = $true
        )]
        [PSCredential]
        $Credential,

        # Return raw output.
        [Parameter( Position = 1 )]
        [Switch]
        $Raw = $false
    )

    begin {
        $function = $MyInvocation.MyCommand.Name

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

        if ( $PSBoundParameters.ContainsKey( 'Credential' ) ) {
            $Script:PSRyver.Authorization = ConvertTo-Authorization -Credential $Credential
            Remove-Variable -Name 'Credential'
        }
    }

    process {
        $splat = @{
            Method = 'auth.test'
        }

        $rawAuthInfo = Invoke-RyverRestMethod @splat

        if ( $Raw ) {
            $rawAuthInfo
        }
        else {
            Format-RyverV1AuthInfoObject -InputObject $rawAuthInfo
        }
    }

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