NAME
Rest::Client::Builder - Base class to build simple object-oriented REST clients
SYNOPSIS
use Rest::Client::Builder;
package Your::API::Class;
use base qw(Rest::Client::Builder);
use JSON;
sub new {
my ($class) = @_;
my $self;
$self = $class->SUPER::new({
on_request => sub {
return $self->request(@_);
},
}, 'http://hostname/api');
return bless($self, $class);
};
sub request {
my ($self, $method, $path, $args) = @_;
print sprintf("%s %s %s\n", $method, $path, encode_json($args));
}
my $api = Your::API::Class->new();
$api->resource->get({ value => 1 });
# output: GET http://hostname/api/resource {"value":1}
$api->resource(10)->post({ value => 1 });
# output: POST http://hostname/api/resource/10 {"value":1}
$api->resource(10)->subresource('alfa', 'beta')->state->put({ value => 1 });
# output: PUT http://hostname/api/resource/10/subresource/alfa/beta/state {"value":1}
$api->resource(10)->delete->();
# output: DELETE http://hostname/api/resource/10
SEE ALSO
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Rest::Client::Builder
You can also look for information at:
Code Repository at GitHub
GitHub Issue Tracker
RT, CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Rest-Client-Builder
AUTHOR
Alexey A. Komarov <alexkom@cpan.org>
COPYRIGHT
2014 Alexey A. Komarov