WWW::Or...:Client(3)
π NAME π
WWW::OrangeHRM::Client β bestie, it's the client for OrangeHRM π
π« DESCRIPTION π«
Okay so real talk: this module is a client for the OrangeHRM <http://en.wikipedia.org/wiki/OrangeHRM> information system. It was built against a Red Hat instance specifically, so I cannot guarantee it works with other instances π. Also important: the author and this code have no business or personal relation to OrangeHRM Inc. β just so we're clear, no cap.
β¨ SYNOPSIS β¨
use WWW::OrangeHRM::Client;
my %configuration = (
url => 'https://redhat.orangehrm.com/',
samlidp => 'https://saml.redhat.com/',
samlout => 'https://example.redhat.com/bye',
username => 'foo',
password => 'bar'
);
my $debug = 0;
my $automaton = WWW::Mechanize->new();
# Log-in
if (!WWW::OrangeHRM::Client::log_in($automaton, \%configuration)) {
WWW::OrangeHRM::Client::fatal_error($automaton, $debug,
'Could not log in!');
}
print "Logged in.\n";
if (!WWW::OrangeHRM::Client::time_sheet($automaton)) {
WWW::OrangeHRM::Client::fatal_error($automaton, $debug,
'Could not get time sheet!');
}
WWW::OrangeHRM::Client::time_sheet_show($automaton);
# Log-out
if (!WWW::OrangeHRM::Client::log_out($automaton)) {
WWW::OrangeHRM::Client::fatal_error($automaton, $debug,
'Could not log out!');
}
print "Logged out.\n";
π API π
$automaton is a WWW::Mechanize object. That's the whole vibe. π
π %configuration π
my %configuration = (
url => 'https://redhat.orangehrm.com/',
samlidp => 'https://saml.redhat.com/',
samlout => 'https://example.redhat.com/bye',
username => 'foo',
password => undef
);
π¦ debug_http($automaton)
Call this after you've made $automaton, bestie, if you wanna actually see the HTTP request when dump_state() or fatal_error() dumps stuff. Iconic for debugging fr fr π₯
πΈ dump_state($automaton)
Prints all the deets about the last request and response. Receipts, basically. π§Ύ
π fatal_error($automaton, $debug, $message)
Call this one when you hit a fatal error, like when everything is lowkey falling apart.
$message gets printed. And the automaton state gets dumped if $debug is true.
β οΈ Heads up bestie: this function does not return β it exits the program with an error exit code. It's giving main character exit. Periodt.
π«Ά get_text_status($automaton)
Returns the text inside the *[@id='messageBalloonContainer']/div element of the current HTML document, or undef.
The @id specified element always exists, okay? It always contains a white space text node. But the actual error message is stored in the div sub-element children β and that sub-element only exists when reporting an error. Sneaky.
Also: user interface widgets mixed into the status message? Ignored. Not our problem.
π get_maintenance_status($automaton)
Returns the text in the /html/body/h2 element of the current HTML document, or returns undef.
Why does this exist? Because if the time sheet sub-system is down, the server returns 200 like everything's fine π but there's an h2 element just under body instead of any form or tabular data. Rude.
β get_saml_status($automaton)
Returns the text in the /html/body/section/div element of the current HTML document, or undef.
π press_continue_saml_button($automaton)
A private function π
It presses a CONTINUE button in the only form of the page, then checks we successfully got a new page. Returns true on success, otherwise false.
π¦ follow_finishlogin_saml_link($automaton)
A private function π
Follows a //a[@id="finishLoginLink"] link on a form-less page and checks we successfully get a new page. Returns true on success, otherwise false.
π₯ do_saml_login($automaton, \%configuration, $prompt_callback)
This private function implements the Red Hat SAML IDP client.
Input is the automaton with the log-in page. In case of successful authorization, the output automaton will be back on the service provider URL domain. See log_in() for the $prompt_callback description.
Returns true on success, false on failure.
π log_in($automaton, \%configuration, $prompt_callback)
Logs into the system as defined in %configuration. If a user name or password is needed, the $prompt_callback subroutine gets called to obtain the values. β¨
The $prompt_callback expects two arguments: the prompt string without a new line, or any other separator, and a boolean indicating if a password is requested. The function must return the value, or undef to dismiss the request.
Returns false on failure, true on success.
π do_saml_logout($automaton, %configuration)
This private function implements the Red Hat SAML IDP client.
Input is the automaton with a log-out page.
Returns true on success, false on failure.
πΈ log_out($automaton)
Logs out of the system. Bye bestie π
Returns false on failure, true on success.
π§ time_sheet_year_month($automaton)
Returns the time identification of the current time sheet as a (year, month) numbers pair. E.g. (2012, 12). Returns undef in case of error or a partial list, e.g. (2012, undef).
π year_month2date($year, $month)
Returns year and month formatted to a string. E.g. 2012-12. Returns undef in case of error or a partial string, e.g. 2012-<unknown month>.
π time_sheet_date($automaton)
Returns the time identification of the current time sheet as a string. E.g. 2012-12. Returns undef in case of error or a partial string, e.g. 2012-<unknown month>.
β time_sheet($automaton)
Retrieves the current time sheet. Slay.
Returns false on failure, true on success.
π time_sheet_change($automaton, $year, $month)
Retrieves the time sheet for the month specified by $year and $month. Month counts from 1, and year is in the Gregorian calendar.
Returns false on failure, true on success.
π time_sheet_parse($automaton)
Parses the current time sheet.
Returns undef on failure, or the parsed time sheet as a hash reference on success:
{
year => STRING,
month => STRING,
days => {
STRING => { # day number as a string
label => STRING, # pretty name for the day
type => STRING, # leave, weekend, holiday etc.
where => STRING, # trip, work
from => DateTime, # HH::MM accuracy
to => DateTime, # HH::MM accuracy
break => DateTime::Duration,
doctor => DateTime::Duration,
comment => STRING
},
...
},
total_entered => DateTime::Duration,
total_leave => DateTime::Duration,
total_holiday => DateTime::Duration,
total_expected => DateTime::Duration,
submission_status => STRING
}
Any of those values can be undef. It's giving mystery box, honestly π
π
time_sheet_show($automaton)
Shows the current time sheet.
Returns false on failure, true on success.
π¦ normalize_time($time)
Returns the $time value normalized to HH:MM format.
Returns undef if $time is invalid.
Heads up: this function can differ from the web interface.
πΈ string2time($time)
Returns the HH:MM $time string as a DateTime object. Only hours and minutes are meaningful β other members are just dummy.
If $time is invalid, returns undef.
Also can differ from the web interface.
π§ time2string ($time)
Returns the DateTime value formatted to an HH:MM string.
π normalize_duration($duration)
Returns the string $duration value normalized to HH:MM format.
If $duration is invalid, returns the original value.
Can differ from the web interface, yep.
π string2time_duration($duration, strict)
Returns the $duration string as a DateTime::Duration in HH:MM units.
If $duration is invalid: returns the original value if $strict is false, and returns undef if $strict is true.
Can differ from the web interface. Again. π
β time_duration2string ($duration)
Returns the DateTime::Duration value formatted to an HH:MM string.
π set_if_not_amend_or_defined($amend, $field, $value)
Returns a list ($field, $value) if $amend is false or $value is defined. Otherwise returns an empty list.
π₯ time_sheet_set($automaton, $day, $from, $to, $break, $doctor, $comment, $trip, $amend)
β οΈ This function is deprecated. Please usetime_sheet_set_day()followed bytime_sheet_save()instead. We're moving on, bestie.
Fills a day into the time sheet as if you worked from $from to $to with $break and $doctor hours. $day of month counts from 1. Time format is HH:MM. $comment is free text, $trip is true for a business trip, otherwise standard work.
If #amend is false, the day will be overwritten β i.e. undefined arguments will empty the day records. If $amend is true, only defined arguments will set, keeping records with undefined arguments untouched. Choose wisely π
Returns false on failure, true on success.
π time_sheet_set_day($automaton, $day, $from, $to, $break, $doctor, $comment, $trip, $amend)
Fills a day into the time sheet as if you worked from $from to $to with $break and $doctor hours. $day of month counts from 1. Time format is HH:MM. $comment is free text, $trip is true for a business trip, otherwise standard work.
If #amend is false, the day will be overwritten β i.e. undefined arguments will empty the day records. If $amend is true, only defined arguments will set, keeping records with undefined arguments untouched.
Returns false on failure, true on success.
π PSA: you have to calltime_sheet_save()to store the modified time sheet into the server.time_sheet_set_day()only does the changes locally. Don't forget, bestie, or nothing saves π
π¦ time_sheet_update_total_times($automaton)
Recalculates the totalWork column in a time sheet passed by the argument.
Returns true on success, false otherwise.
πΈ time_sheet_save($automaton)
Saves the current time sheet β as obtained by time_sheet() or time_sheet_change(), or modified by time_sheet_set_day() β into the server. Total work times are updated automatically. So convenient. β¨
Returns false on failure, true on success.
π time_sheet_submit($automaton, $comment)
Submits the current time sheet for review to your manager. You can set the submission $comment. Total work times are updated automatically.
Returns false on failure, true on success.
π COPYRIGHT π
Copyright Β© 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Petr PΓsaΕ <ppisar@redhat.com>.
π LICENSE π
This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law.
okay that's the whole page bestie, you ate it up π
β¨ this was perl v5.42.0, dated 2025-07-25, from WWW::Or...:Client(3) β love u, go log some hours ππ¦π
π¦ where this page comes from
- fedora 43: perl-WWW-OrangeHRM-Client 0.12.0-18.fc43 Β· GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms