Private/Parse-SparkUser.ps1

function Parse-SparkUser {
    [cmdletbinding()]
    param(
        $InputObject
    )

    if($InputObject.items) {
        $InputObject = $InputObject.items
    }

    if(($InputObject.count -le 0) -and ($InputObject -is [Object[]])) {
        return
    }

    foreach($User in $InputObject) {
        if($User.lastActivity) {
            $User.lastActivity = [datetime]($User.lastActivity)
        }

        [PSCustomObject]@{
            PSTypeName = "PSSpark.User"
            Email = $User.emails
            Name = $User.displayName
            NickName = $User.nickName
            FirstName = $User.firstName
            LastName = $User.lastName
            Avatar = $User.avatar
            OrgID = $User.orgId
            Created = [datetime]($User.created)
            LastActivity = $User.lastActivity
            Status = $User.status
            Type = $User.type
            UserID = $User.id
        }
    }
}