# SPDX-License-Identifier: BSD-3-Clause
#
# Copyright 2026 Raritan Inc. All rights reserved.
#
# This file was generated by IdlC from User.idl.

use strict;

package Raritan::RPC::usermgmt::UserInfo_2_0_0;

use Raritan::RPC::usermgmt::AuxInfo;
use Raritan::RPC::usermgmt::SnmpV3Settings_2_0_0;
use Raritan::RPC::usermgmt::Preferences;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'enabled'} = ($in->{'enabled'}) ? JSON::true : JSON::false;
    $encoded->{'locked'} = ($in->{'locked'}) ? JSON::true : JSON::false;
    $encoded->{'blocked'} = ($in->{'blocked'}) ? JSON::true : JSON::false;
    $encoded->{'needPasswordChange'} = ($in->{'needPasswordChange'}) ? JSON::true : JSON::false;
    $encoded->{'auxInfo'} = Raritan::RPC::usermgmt::AuxInfo::encode($in->{'auxInfo'});
    $encoded->{'snmpV3Settings'} = Raritan::RPC::usermgmt::SnmpV3Settings_2_0_0::encode($in->{'snmpV3Settings'});
    $encoded->{'sshPublicKey'} = "$in->{'sshPublicKey'}";
    $encoded->{'preferences'} = Raritan::RPC::usermgmt::Preferences::encode($in->{'preferences'});
    $encoded->{'roleIds'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'roleIds'}}; $i0++) {
        $encoded->{'roleIds'}->[$i0] = 1 * $in->{'roleIds'}->[$i0];
    }
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'enabled'} = ($in->{'enabled'}) ? 1 : 0;
    $decoded->{'locked'} = ($in->{'locked'}) ? 1 : 0;
    $decoded->{'blocked'} = ($in->{'blocked'}) ? 1 : 0;
    $decoded->{'needPasswordChange'} = ($in->{'needPasswordChange'}) ? 1 : 0;
    $decoded->{'auxInfo'} = Raritan::RPC::usermgmt::AuxInfo::decode($agent, $in->{'auxInfo'});
    $decoded->{'snmpV3Settings'} = Raritan::RPC::usermgmt::SnmpV3Settings_2_0_0::decode($agent, $in->{'snmpV3Settings'});
    $decoded->{'sshPublicKey'} = $in->{'sshPublicKey'};
    $decoded->{'preferences'} = Raritan::RPC::usermgmt::Preferences::decode($agent, $in->{'preferences'});
    $decoded->{'roleIds'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'roleIds'}}; $i0++) {
        $decoded->{'roleIds'}->[$i0] = $in->{'roleIds'}->[$i0];
    }
    return $decoded;
}

1;
