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

use strict;

package Raritan::RPC::smartlock::DoorAccessControl_1_1_1::PeriodicTimeCondition;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'enabled'} = ($in->{'enabled'}) ? JSON::true : JSON::false;
    $encoded->{'daysOfWeek'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'daysOfWeek'}}; $i0++) {
        $encoded->{'daysOfWeek'}->[$i0] = 1 * $in->{'daysOfWeek'}->[$i0];
    }
    $encoded->{'fromHourOfDay'} = 1 * $in->{'fromHourOfDay'};
    $encoded->{'tillHourOfDay'} = 1 * $in->{'tillHourOfDay'};
    $encoded->{'fromMinuteOfHour'} = 1 * $in->{'fromMinuteOfHour'};
    $encoded->{'tillMinuteOfHour'} = 1 * $in->{'tillMinuteOfHour'};
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'enabled'} = ($in->{'enabled'}) ? 1 : 0;
    $decoded->{'daysOfWeek'} = [];
    for (my $i0 = 0; $i0 <= $#{$in->{'daysOfWeek'}}; $i0++) {
        $decoded->{'daysOfWeek'}->[$i0] = $in->{'daysOfWeek'}->[$i0];
    }
    $decoded->{'fromHourOfDay'} = $in->{'fromHourOfDay'};
    $decoded->{'tillHourOfDay'} = $in->{'tillHourOfDay'};
    $decoded->{'fromMinuteOfHour'} = $in->{'fromMinuteOfHour'};
    $decoded->{'tillMinuteOfHour'} = $in->{'tillMinuteOfHour'};
    return $decoded;
}

1;
