#!/usr/bin/perl
use warnings;
use strict;

# sudo apt-get install librpc-xml-perl libio-socket-ssl-perl

#use IO::Socket::SSL qw(debug4);
#use LWP::Debug qw(+);

require RPC::XML;
require RPC::XML::Client;

use Data::Dump qw(dump);

my $code = shift @ARGV;

my $auth = RPC::XML::Client->new('https://www.fer.hr/xmlrpc/xr_auth.php');

my $login_id = $auth->send_request('auth.rlogin', '_koha', $ENV{PASSWD} )->value;

warn "# login_id $login_id\n";

my $users = RPC::XML::Client->new('https://www.fer.hr/xmlrpc/xr_users.php');
my $res = $users->send_request('users.getinfobycode',$login_id, RPC::XML::string->new($code) )->value;

print "[$code] = ", dump($res), $/;

