classes/BitwardenPasswordHistory.psm1

using namespace System.Runtime.InteropServices

class BitwardenPasswordHistory {

    [datetime]$LastUsedDate = [datetime]::Now
    [securestring]$Password

    [string] Reveal() {

        return [Marshal]::PtrToStringAuto( [Marshal]::SecureStringToBSTR( $this.Password ) )

    }

    BitwardenPasswordHistory() {}

    BitwardenPasswordHistory( [pscustomobject]$JsonObject ) {
    
        $this.LastUsedDate = $JsonObject.LastUsedDate
        $this.Password = ConvertTo-SecureString -String $JsonObject.Password -AsPlainText -Force
    
    }

}