Hetula::Client - Perl client implementation to communicate with Hetula.
Perl client implementation to communicate with Hetula, the Patron data store
my $hc = Hetula::Client->new({baseURL => 'https://hetula.example.com'}); my $loginResponse = $hc->login({username => 'master', password => 'blaster', organization => 'Administratoria'}); die($loginResponse->{error}) if ($loginResponse->{error}); my $loginActiveResp = $hc->loginActive(); ok(! $loginActiveResp->{error}, "Login active"); my $ssnAddResp = $hc->ssnAdd({ssn => 'bad-ssn'}); ok($ssnAddResp->{error}, "SSN add failed - Bad SSN '$ssnAddResp->{error}'"); my $ssnGetResp = $hc->ssnGet({id => 1}); ok(! $ssnGetResp->{error}, "SSN got"); my $ssnsBatchAddResp = $hc->ssnsBatchAdd(['101010-101A', '101010-102B']); is(@$ssnsBatchAddResp, 2, "SSNs batch add");
@param1 {HASHRef} baseURL => https://hetula.example.com credentials => filepath, Where to load the credentials file. see slurpCredentials() for more info.
See Hetula API doc for endpoint POST /api/v1/auth
@param1 {HASHRef} username => String || undef if given via credentials during construction, password => String || undef if given via credentials during construction, organization => String || undef if given via credentials during construction,
See Hetula API doc for endpoint POST /api/v1/ssns
See Hetula API doc for endpoint GET /api/v1/users/<id>
@param1 {HASHRef} id => ssn id to get
See Hetula API doc for endpoint GET /api/v1/ssns/batch
@param1 {ARRAYRef} of ssns
Invokes the ssnsBatchAdd()-method repeatedly in small chunks. Useful for importing an inconveniently large amount of ssns that would otherwise timeout the Hetula-server.
@param1 {sub} Receives a feeder callback, which sends ssn-lists to the ssnsBatchAdd()-method. for ex. sub { #Keep sending ssns while there are ssns to send return ['ssn1','ssn2','ssn3'] if @ssns; #When ssns run out, return false to signal the end of transmission return undef || []; } @param2 {sub} Receives a digester callback, which receives the ssnsBatchAdd()-methods response|return value. for ex. sub { my ($ssnReportsFromHetula) = @_; print $FH_OUT "$_->{ssn}->{id},$_->{ssn}->{ssn},$_->{error}\n" for @$ssnReportsFromHetula; }
Wrapper for ssnsBatchAddChunked(), where this manages the file IO as well.
@param1 {filepath} Where to read ssns from. This can be a simple .csv-file, in this case the last (or only) column is expected to be one containing the ssn that is intended to be migrated to Hetula. If there are any extra columns, they are appended to the ssn report/result .csv-file as ssn report context. @param2 {filepath} Where to write the ssn migration results/reports
See Hetula API doc for endpoint POST /api/v1/users
Adds a user with only the most minimum permisions needed to push records into Hetula. Organization the user belongs to is implied from the currently logged in organization.
@param {HASHRef} username => 'MattiM', password => 'Secret', realname => 'Matti Meikäläinen',
Adds a user with read access to Hetula. Organization the user belongs to is implied from the currently logged in organization.
See Hetula API doc for endpoint PUT /api/v1/users/<id>
@param {HASHRef} username or id => mandatory, other patron attributes => and values, ...
@param {HASHRef} username or id => mandatory, password => mandatory - the new password,
To recover from a disabled account, change the password
@param {String} username or id
Reads the contents of a credentials file.
The credentials file must consist of up to 4 lines, with each line specifying the following commandline argument replacements: username password organization url
@param1 {String} Path to the credentials file @param2 {HASHRef} Optional, HASHRef where to inject the found credentials
To install Hetula::Client, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Hetula::Client
CPAN shell
perl -MCPAN -e shell install Hetula::Client
For more information on module installation, please visit the detailed CPAN module installation guide.