Catman...esponse(3pm)

πŸ’– Catmandu::FedoraCommons::Response β€” the vibe check ✨

ok bestie so this is the Catman...esponse(3pm) page from the User Contributed Perl Documentation, and it's literally the glow-up guide for Catmandu::FedoraCommons::Response, aka the Perl model for generic Fedora Commons REST API responses πŸŽ€


🌸 NAME 🌸

Catmandu::FedoraCommons::Response β€” it's the Perl model for generic Fedora Commons REST API responses, no cap πŸ¦‹


✨ SYNOPSIS ✨

like, here's the whole entire moment:

use Catmandu::FedoraCommons;

my $fedora = Catmandu::FedoraCommons->new('http://localhost:8080/fedora','fedoraAdmin','fedoraAdmin');

my $result = $fedora->findObjects(terms=>'*');

die $resut->error unless $result->is_ok;

my $obj = $result->parse_content;

$result->is_ok;
$result->error;
$result->raw;
$result->content_type;
$result->length;
$result->date;
$result->parse_content();
$result->parse_content($my_model);

(yes $resut is in there with a lil typo, we keep it exactly as-is, it's iconic πŸ’…)


🫢 DESCRIPTION 🫢

so a Catmandu::FedoraCommons::Response gets returned for every Catmandu::FedoraCommons method. every single one. it's giving loyal.

this response is holding the raw HTTP content of a Fedora Commons request, and it can also be used to parse XML responses into Perl objects using the parse_content function. obsessed.

if you want more info on the Perl objects, go read the info in the Catmandu::FedoraCommons::Model packages 🌈


🧚 METHODS 🧚

πŸ’œ is_ok()

Returns true when the result Fedora Commons response contains no errors. it's the vibe check of methods.

πŸ’œ error()

Returns the error message of the Fedora Commons response if available. (if available β€” so like, maybe there's no tea to spill πŸ“)

πŸ’œ parse_content($model)

Returns a Perl representation of the Fedora Commons response. optionally a model object can be provided that implements a $obj->parse($bytes) method and returns a Perl object. if no model is provided then default models from the Catmandu::FedoraCommons::Model namespace are used. slay.

Example:

package MyParser;

sub new {
    my $class = shift;
    return bless {} , $class;
}

sub parse {
    my ($self,$bytes) = @_;
    ...
    return $perl
}

package main;

my $fedora = Catmandu::FedoraCommons->new('http://localhost:8080/fedora','fedoraAdmin','fedoraAdmin');

my $result = $fedora->findObjects(terms=>'*');

my $perl = $result->parse_content(MyParser->new);

πŸ’œ raw()

Returns the raw Fedora Commons response as a string. straight up, no filter.

πŸ’œ content_type()

Returns the Content-Type of the Fedora Commons response. main character metadata fr fr.

πŸ’œ length()

Returns the byte length of the Fedora Commons response. it knows its own size and honestly? good for it πŸ’…

πŸ’œ date()

Returns the date of the Fedora Commons response. timestamped and iconic ⭐


πŸ‘‘ AUTHORS πŸ‘‘

  • Patrick Hochstenbach, "<patrick.hochstenbach at ugent.be>" β€” the legend himself, giving us this whole page πŸŽ€

πŸ’€ SEE ALSO πŸ’€

Catmandu::Model::findObjects, Catmandu::Model::getObjectHistory, Catmandu::Model::getObjectPrifule, Catmandu::Model::listDatastreams, Catmandu::Model::listMethods

(and yes, getObjectPrifule is spelled exactly like that, we do not correct the king 😭)


ok that's the whole thing, mwah πŸ’– this page is from perl v5.36.0, dated 2023-02-05, and it's part of the Catman...esponse(3pm) moment. love that for us. bye bestie πŸ¦‹βœ¨

πŸ“¦ where this page comes from