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

use strict;

package Raritan::RPC::pdumodel::TransferSwitch_2_0_0::Settings;

use Raritan::RPC::pdumodel::TransferSwitch_2_0_0::PowerQualitySettings;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'name'} = "$in->{'name'}";
    $encoded->{'preferredSource'} = 1 * $in->{'preferredSource'};
    $encoded->{'autoRetransfer'} = ($in->{'autoRetransfer'}) ? JSON::true : JSON::false;
    $encoded->{'noAutoRetransferIfPhaseFault'} = ($in->{'noAutoRetransferIfPhaseFault'}) ? JSON::true : JSON::false;
    $encoded->{'autoRetransferWaitTime'} = 1 * $in->{'autoRetransferWaitTime'};
    $encoded->{'manualTransferEnabled'} = ($in->{'manualTransferEnabled'}) ? JSON::true : JSON::false;
    $encoded->{'powerQuality'} = Raritan::RPC::pdumodel::TransferSwitch_2_0_0::PowerQualitySettings::encode($in->{'powerQuality'});
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'name'} = $in->{'name'};
    $decoded->{'preferredSource'} = $in->{'preferredSource'};
    $decoded->{'autoRetransfer'} = ($in->{'autoRetransfer'}) ? 1 : 0;
    $decoded->{'noAutoRetransferIfPhaseFault'} = ($in->{'noAutoRetransferIfPhaseFault'}) ? 1 : 0;
    $decoded->{'autoRetransferWaitTime'} = $in->{'autoRetransferWaitTime'};
    $decoded->{'manualTransferEnabled'} = ($in->{'manualTransferEnabled'}) ? 1 : 0;
    $decoded->{'powerQuality'} = Raritan::RPC::pdumodel::TransferSwitch_2_0_0::PowerQualitySettings::decode($agent, $in->{'powerQuality'});
    return $decoded;
}

1;
