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

use strict;

package Raritan::RPC::cert::ServerSSLCert_3_0_0::Info;

use Raritan::RPC::cert::ServerSSLCert_3_0_0::CertInfo;
use Raritan::RPC::cert::ServerSSLCert_3_0_0::CertInfo;
use Raritan::RPC::cert::ServerSSLCert_3_0_0::ReqInfo;
use Raritan::RPC::cert::ServerSSLCert_3_0_0::CertInfo;
use Raritan::RPC::cert::ServerSSLCert_3_0_0::CertInfo;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'havePendingReq'} = ($in->{'havePendingReq'}) ? JSON::true : JSON::false;
    $encoded->{'havePendingCert'} = ($in->{'havePendingCert'}) ? JSON::true : JSON::false;
    $encoded->{'pendingReqInfo'} = Raritan::RPC::cert::ServerSSLCert_3_0_0::ReqInfo::encode($in->{'pendingReqInfo'});
    $encoded->{'pendingCertInfo'} = Raritan::RPC::cert::ServerSSLCert_3_0_0::CertInfo::encode($in->{'pendingCertInfo'});
    $encoded->{'pendingCertChainInfos'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'pendingCertChainInfos'}}; $i0++) {
        $encoded->{'pendingCertChainInfos'}->[$i0] = Raritan::RPC::cert::ServerSSLCert_3_0_0::CertInfo::encode($in->{'pendingCertChainInfos'}->[$i0]);
    }
    $encoded->{'activeCertInfo'} = Raritan::RPC::cert::ServerSSLCert_3_0_0::CertInfo::encode($in->{'activeCertInfo'});
    $encoded->{'activeCertChainInfos'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'activeCertChainInfos'}}; $i0++) {
        $encoded->{'activeCertChainInfos'}->[$i0] = Raritan::RPC::cert::ServerSSLCert_3_0_0::CertInfo::encode($in->{'activeCertChainInfos'}->[$i0]);
    }
    $encoded->{'maxSignDays'} = 1 * $in->{'maxSignDays'};
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'havePendingReq'} = ($in->{'havePendingReq'}) ? 1 : 0;
    $decoded->{'havePendingCert'} = ($in->{'havePendingCert'}) ? 1 : 0;
    $decoded->{'pendingReqInfo'} = Raritan::RPC::cert::ServerSSLCert_3_0_0::ReqInfo::decode($agent, $in->{'pendingReqInfo'});
    $decoded->{'pendingCertInfo'} = Raritan::RPC::cert::ServerSSLCert_3_0_0::CertInfo::decode($agent, $in->{'pendingCertInfo'});
    $decoded->{'pendingCertChainInfos'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'pendingCertChainInfos'}}; $i0++) {
        $decoded->{'pendingCertChainInfos'}->[$i0] = Raritan::RPC::cert::ServerSSLCert_3_0_0::CertInfo::decode($agent, $in->{'pendingCertChainInfos'}->[$i0]);
    }
    $decoded->{'activeCertInfo'} = Raritan::RPC::cert::ServerSSLCert_3_0_0::CertInfo::decode($agent, $in->{'activeCertInfo'});
    $decoded->{'activeCertChainInfos'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'activeCertChainInfos'}}; $i0++) {
        $decoded->{'activeCertChainInfos'}->[$i0] = Raritan::RPC::cert::ServerSSLCert_3_0_0::CertInfo::decode($agent, $in->{'activeCertChainInfos'}->[$i0]);
    }
    $decoded->{'maxSignDays'} = $in->{'maxSignDays'};
    return $decoded;
}

1;
