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

use strict;

package Raritan::RPC::event::TimerEventManager_2_0_0::Schedule;

use Raritan::RPC::event::TimerEventManager_2_0_0::Range;
use Raritan::RPC::event::TimerEventManager_2_0_0::Range;
use Raritan::RPC::event::TimerEventManager_2_0_0::Range;
use Raritan::RPC::event::TimerEventManager_2_0_0::Range;
use Raritan::RPC::event::TimerEventManager_2_0_0::Range;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'enabled'} = ($in->{'enabled'}) ? JSON::true : JSON::false;
    $encoded->{'minute'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'minute'}}; $i0++) {
        $encoded->{'minute'}->[$i0] = Raritan::RPC::event::TimerEventManager_2_0_0::Range::encode($in->{'minute'}->[$i0]);
    }
    $encoded->{'hour'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'hour'}}; $i0++) {
        $encoded->{'hour'}->[$i0] = Raritan::RPC::event::TimerEventManager_2_0_0::Range::encode($in->{'hour'}->[$i0]);
    }
    $encoded->{'dayOfMonth'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'dayOfMonth'}}; $i0++) {
        $encoded->{'dayOfMonth'}->[$i0] = Raritan::RPC::event::TimerEventManager_2_0_0::Range::encode($in->{'dayOfMonth'}->[$i0]);
    }
    $encoded->{'month'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'month'}}; $i0++) {
        $encoded->{'month'}->[$i0] = Raritan::RPC::event::TimerEventManager_2_0_0::Range::encode($in->{'month'}->[$i0]);
    }
    $encoded->{'dayOfWeek'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'dayOfWeek'}}; $i0++) {
        $encoded->{'dayOfWeek'}->[$i0] = Raritan::RPC::event::TimerEventManager_2_0_0::Range::encode($in->{'dayOfWeek'}->[$i0]);
    }
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'enabled'} = ($in->{'enabled'}) ? 1 : 0;
    $decoded->{'minute'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'minute'}}; $i0++) {
        $decoded->{'minute'}->[$i0] = Raritan::RPC::event::TimerEventManager_2_0_0::Range::decode($agent, $in->{'minute'}->[$i0]);
    }
    $decoded->{'hour'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'hour'}}; $i0++) {
        $decoded->{'hour'}->[$i0] = Raritan::RPC::event::TimerEventManager_2_0_0::Range::decode($agent, $in->{'hour'}->[$i0]);
    }
    $decoded->{'dayOfMonth'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'dayOfMonth'}}; $i0++) {
        $decoded->{'dayOfMonth'}->[$i0] = Raritan::RPC::event::TimerEventManager_2_0_0::Range::decode($agent, $in->{'dayOfMonth'}->[$i0]);
    }
    $decoded->{'month'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'month'}}; $i0++) {
        $decoded->{'month'}->[$i0] = Raritan::RPC::event::TimerEventManager_2_0_0::Range::decode($agent, $in->{'month'}->[$i0]);
    }
    $decoded->{'dayOfWeek'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'dayOfWeek'}}; $i0++) {
        $decoded->{'dayOfWeek'}->[$i0] = Raritan::RPC::event::TimerEventManager_2_0_0::Range::decode($agent, $in->{'dayOfWeek'}->[$i0]);
    }
    return $decoded;
}

1;
