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

use strict;

package Raritan::RPC::smartlock::DoorAccessControl::KeypadCondition;

use Raritan::RPC::smartlock::DoorAccessControl::KeypadInfo;

sub encode {
    my ($in) = @_;
    my $encoded = {};
    $encoded->{'enabled'} = ($in->{'enabled'}) ? JSON::true : JSON::false;
    $encoded->{'pin'} = "$in->{'pin'}";
    $encoded->{'keypad'} = Raritan::RPC::smartlock::DoorAccessControl::KeypadInfo::encode($in->{'keypad'});
    return $encoded;
}

sub decode {
    my ($agent, $in) = @_;
    my $decoded = {};
    $decoded->{'enabled'} = ($in->{'enabled'}) ? 1 : 0;
    $decoded->{'pin'} = $in->{'pin'};
    $decoded->{'keypad'} = Raritan::RPC::smartlock::DoorAccessControl::KeypadInfo::decode($agent, $in->{'keypad'});
    return $decoded;
}

1;
