#!/usr/local/cpanel/3rdparty/bin/perl -w
use cPstrict;

use Whostmgr::360Monitoring::Setup ();
use Whostmgr::360Monitoring::User  ();
use Cpanel::PwCache                ();

sub doit() {
    my $username = Cpanel::PwCache::getusername();
    my $user     = Whostmgr::360Monitoring::User->new( username => $username );
    my $api_key  = $user->api_key;
    my $user_id  = $user->user_id;

    return {
        user_id => $user_id,
        api_key => $api_key
    } if $api_key;

    # In the case we never setup the monitor
    $user = Whostmgr::360Monitoring::Setup::initialize();
    return {
        user_id => $user->user_id,
        api_key => $user->api_key,
    };
}

my $ret = doit();

use v5.34;
use Data::Dumper;
$Data::Dumper::Sortkeys = 1;
say STDERR Dumper($ret);
