WWW::GoDaddy::REST::Util - Mostly URL tweaking utilities for this package
use WWW::GoDaddy::REST::Util qw/ abs_url add_filters_to_url /; # http://example.com/v1/asdf abs_url('http://example.com/v1','/asdf'); # http://example.com?sort=asc&fname=Fred add_filters_to_url('http://example.com?sort=asc',{ 'fname' => [ { 'value': 'Fred' } ] });
Utilities used commonly in this package. Most have to do with URL manipulation.
Given a json string, return true if it is parsable, false otherwise.
If you need to control the parameters to the JSON module, simply pass additional parameters. These will be passed unchanged to json_instance.
json_instance
Example:
my $yes = is_json('"asdf"'); my $yes = is_json('{"key":"value"}'); my $no = is_json('dafsafsadfsdaf');
Given a json string, return the perl data structure. This will die() if it can not be parsed.
die()
my $hashref = json_decode('{"key":"value"}');
Given a perl data structure, return the json string. This will die() if it can not be serialized.
my $json = json_encode({ 'key' => 'value' });
Returns JSON instance. If no parameters are given the following defaults are set: convert_blessed, allow_nonref.
JSON
convert_blessed
allow_nonref
If called with one parameter, it is assumed to be a JSON instance and this is returned instead of building a new one.
If called with more than one parameter, it is assumed to be key/value pairs and will be passed to the JSON property method two by two.
property
$j = json_instance(); #defaults $j = json_instance( JSON->new ); #pass through $j = json_instance( 'convert_blessed' => 1, 'allow_nonref' => 1 ); # set properies
Given a base and path fragment, generate an absolute url with the two joined.
# http://example.com/v1/asdf abs_url('http://example.com/v1','/asdf');
Given a url and a query filter, generate a url with the filter query parameters added.
Filter syntax can be seen in the docs for WWW::GoDaddy::REST.
add_filters_to_url('http://example.com?sort=asc',{ 'fname' => [ { 'value': 'Fred' } ] }); # http://example.com?sort=asc&fname=Fred
Return a modified URL string given a URL, an optional filter spec, and optional query parameter hash.
If you specify a sort, then an order parameter will be filled in if not present, and and sort or order query parameters in the input string will be replaced.
All other query parameters (filters etc) will be appended to the query parameters of the input URL instead of replacing.
build_complex_query_url( 'http://example.com', { 'foo' => 'bar' }, { 'sort' => 'surname' } ); # http://example.com?foo=bar&sort=surname&order=asc
None by default.
David Bartle, <davidb@mediatemple.net>
<davidb@mediatemple.net>
Copyright (c) 2014 Go Daddy Operating Company, LLC
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
To install WWW::GoDaddy::REST, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::GoDaddy::REST
CPAN shell
perl -MCPAN -e shell install WWW::GoDaddy::REST
For more information on module installation, please visit the detailed CPAN module installation guide.