Private/Format-RyverV1GroupObject.ps1

function Format-RyverV1GroupObject {
    <#
    .SYNOPSIS
        Parse group objects.
 
    .DESCRIPTION
        Parse group 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-RyverV1GroupObject/
 
    .LINK
        https://github.com/tlindsay42/PSRyver/blob/master/PSRyver/Private/Format-RyverV1GroupObject.ps1
 
    .FUNCTIONALITY
        Ryver
    #>

    [CmdletBinding(
        HelpUri = 'https://tlindsay42.github.io/PSRyver/Private/Format-RyverV1GroupObject/'
    )]
    [OutputType( [PSCustomObject[]] )]
    [OutputType( [PSCustomObject] )]
    param (
        [Parameter(
            Mandatory = $true,
            Position = 0,
            ValueFromPipeline = $true
        )]
        $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 ( $group in $InputObject ) {
            $topicSet = $null
            $purposeSet = $null

            if ( $group.Purpose.Last_Set ) {
                $purposeSet = ConvertFrom-UnixTime -UnixTime $group.Purpose.Last_Set
            }

            if ($group.Topic.Last_Set) {
                $topicSet = ConvertFrom-UnixTime -UnixTime $group.topic.Last_Set
            }

            [PSCustomObject]@{
                PSTypeName  = 'PSRyver.Group'
                ID          = $group.ID
                Name        = $group.Name
                Created     = ConvertFrom-UnixTime -UnixTime $group.Created
                Creator     = $group.Creator
                IsArchived  = $group.Is_Archived
                Members     = $group.Members
                Topic       = $group.Topic.Value
                TopicSet    = $topicSet
                Purpose     = $group.Purpose.Value
                PurposeSet  = $purposeSet
                MemberCount = $group.Members.Count
                Raw         = $group
            }
        }
    }

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