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

use strict;

package Raritan::RPC::lhxmodel::Lhx_3_2_4::Capabilities;

use Raritan::RPC::lhxmodel::Lhx_3_2_4::AlertStatus;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'alerts'} = Raritan::RPC::lhxmodel::Lhx_3_2_4::AlertStatus::encode($in->{'alerts'});
    $encoded->{'features'} = [];
    foreach my $key0 (keys %{$in->{'features'}}) {
        my $value0 = $in->{'features'}->{$key0};
        my $elem0 = {};
        $elem0->{'key'} = "$key0";
        $elem0->{'value'} = ($value0) ? JSON::true : JSON::false;
        push(@{$encoded->{'features'}}, $elem0);
    }
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'alerts'} = Raritan::RPC::lhxmodel::Lhx_3_2_4::AlertStatus::decode($agent, $in->{'alerts'});
    $decoded->{'features'} = {};
    for (my $i0 = 0; $i0 <= $#{$in->{'features'}}; $i0++) {
        my $key0 = $in->{'features'}->[$i0]->{'key'};
        my $value0 = ($in->{'features'}->[$i0]->{'value'}) ? 1 : 0;
        $decoded->{'features'}->{$key0} = $value0;
    }
    return $decoded;
}

1;
