Net::OpenSRS::OMA - Client library for the OpenSRS Mail API
use Data::Dumper; use Net::OpenSRS::OMA; my $oma = new Net::OpenSRS::OMA( uri => 'https://admin.a.hostedemail.com/api', user => 'admin@domain.adm', client => 'my client 0.1', password => 'abc123', ); my $response = $oma->get_user( user => 'user@domain.com' ); if ($response->is_success) { print Dumper $response->content; } elsif ($response->error) { print "Request didn't work at OMA level: " . $response->error . "\n"; } else { print "Request didn't work at HTTP level: " . $response->http_status; }
This module requires these modules.
This API is still under development and thus the method calls, arguments and functions are subject to change.
Consult the API documentation for up to date information.
Create and return a new Net::OpenSRS::OMA object.
Takes the following arguments (in a single hash argument)
uri - base uri for the api: http://example.com/api/ user - username for authentication password - password for authentication token - token for authentication client - client identification string
uri, user and either password or token are required.
Get the API address this object is using
Get the username this object is using
Get the client identifier string this object is using
API methods are called as object methods. All methods take a hash argument, that hash has a credentials hashref added, is converted to JSON and sent to the API. Method calls return a Net::OpenSRS::OMA::Response object containing the response from the server.
Consult the API documentation for the arguments and response formats for each method.
The callable methods are:
Returns true if the HTTP status of the request was 200, the response had valid JSON content, and the 'success' field of the response is true.
Returns a hashref, the decoded JSON content of the response, or undef if there is no content.
Returns a scalar, string, the raw response fromt he server, or undef if there is no content
Returns a scalar, the HTTP status of the request, from the LWP module.
Returns a scalar, the error number from the JSON content of the response, or undef if no error number.
Returns a scalar, the error string from the JSON content of the response, or undef if no error string.
Richard Platel <rplatel@opensrs.org>
Copyright 2012 Richard Platel <rplatel@opensrs.org>
This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.
To install Net::OpenSRS::OMA::Response, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::OpenSRS::OMA::Response
CPAN shell
perl -MCPAN -e shell install Net::OpenSRS::OMA::Response
For more information on module installation, please visit the detailed CPAN module installation guide.