$foo = RESTExample->new(
server => 'http://localhost:3000',
type => 'application/json',
user => 'mee',
passwd => 'sekrit',
);
$foo->bar;
# controller
sub foo : L
ort.pm> is
here:
package Airport;
use warnings;
use strict;
use LWP::Simple;
use JSON;
# preparing a closure in order not to fetch the same airport code again and again
my $alr
ame&fmt=json";
my $content = get ($url);
warn "Cannot get a response for '$url'\n"
unless defined $content;
my $json = JSON->new->allow_nonref;
my $data = $json->decod
package Net::API::Gett::Request;
use Moo;
use Sub::Quote;
use Carp qw(croak);
use JSON;
use LWP::UserAgent;
use HTTP::Request::Common;
use HTTP::Headers;
our $VERSION = '1.06';
=head1 NAME
Net::AP
f = shift;
my $hr = shift;
return encode_json($hr);
}
sub _decode {
my $self = shift;
my $json = shift;
return decode_json($json);
}
sub _send {
my $self = shift;
my $m
e.
Input:
=over
=item * endpoint fragment
=back
Output:
=over
=item * Perl hash ref of the JSON response from the API
=back
Gives a fatal error under any error condition.
=back
=cut
sub ge
bson, 'BSON matches what we expected';
=head1 DESCRIPTION
BSON is a binary-encoded extension of JSON. Test::BSON makes it easy to
verify that you have built a valid BSON document and that it matche
lid_bson> is provided as an alternative to C<bson_ok> using the same
naming convention as L<Test::JSON> but is not exported by default.
=head2 bson_is
Test passes if the two BSON documents are valid
ame naming
convention as L<Test::JSON> but is not exported by default.
=head1 SEE ALSO
This module uses L<BSON> and L<Test::Differences>, and is based on
L<Test::JSON>. Learn more about BSON at L<h
nklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
use LWP::UserAgent;
use URI::Escape;
use JSON;
# Create a new instance;
# parameters are passed with key => value
# with parameters server, pu
s->is_success) {
# JSON decode and evaluate result
my $results;
eval {
$results = decode_json($res->content);
};
if ($@) {
$self->errorLog("Could not JSON decode: " . $res->content);
return 0;
} else {
retur
sub clone
{
my $self = shift;
my $other = $$self;
bless \$other, ref $self;
}
sub TO_JSON { ${$_[0]} }
sub _no_scheme_ok { 0 }
sub _scheme
{
my $self = shift;
unless (@_) {
re
:Ref
Gitalist::URIStructure::Fragment::WithLog
/;
use File::Type::WebImages ();
use JSON::XS qw/encode_json/;
sub base : Chained('/fragment/repository/find') PathPart('') CaptureArgs(0) {}
sub
tash->{Commit}->sha1,
count => 1,
file => $c->stash->{filename},
);
my $json_obj = !$commit
? { }
: {
sha1 => $commi
};
$c->response->content_type('application/json');
# XXX Make use of the json branch
$c->response->body( encode_json $json_obj );
};
__PACKAGE__->meta->make_immutable;
21 C31 C32 )];
enum NexusPurpose, [qw( P1 P2 P3 P4 P5 )];
enum ResponseType, [qw( xml json xml_simple )];
enum VerificationStatus, [qw( Verified Pending Suspended NA )];
class_type Contac
with "WWW::LogicBoxes::Role::Commands";
# Supported Response Types:
my @response_types = qw(xml json xml_simple);
subtype "LogicBoxesResponseType"
=> as "Str",
=> where {
my $type = $ARG;
{ $t
s' API will be in. The default is XML, all supported protocols are:
=over
=item * xml
=item * json
=item * xml_simple
=back
=head2 Suggest Domains (and many others)
my $response = $logic_boxe
he sample URI for this request would then be:
https://test.httpapi.com/api/domains/suggest-names.json?auth-userid=0&auth-password=password&keyword=domain&tlds=com&tlds=net&no-of-results=0&hyphen-allo
d');
}
__PACKAGE__->config(
default => 'text/html',
map => {
'application/json' => [qw/ JSON /],
map { $_ => [qw/ View Default /] }
qw( text/css text/html text/pl
:LogicBoxes::Contact::Factory->construct_from_response( $response );
Given a HashRef that is the JSON response from LogicBoxes when retrieving contact details, returns an instance of L<WWW::LogicBoxe
::Role;
use MooseX::Params::Validate;
use WWW::LogicBoxes::Types qw( HashRef Str );
use JSON qw( decode_json );
use Try::Tiny;
use Carp;
requires 'response_type';
with 'WWW::LogicBoxes::Role::Comm
our $VERSION = '1.11.0'; # VERSION
# ABSTRACT: Submission of LogicBoxes Commands
# Used to force json as the response_type and restore the existing type afterwards
around submit => sub {
my $orig
e_type;
my $response;
try {
if( $current_response_type ne 'json' ) {
$self->response_type('json');
}
$response = $self->$orig( $args );
}
catch {
hema );
=cut
sub load {
my $self = shift;
$self->{schema} = $_[0];
# TODO load from JSON, YAML, XML
# TODO validation
return $self;
}#sub
=item create
my $ddl = $db_schema
LWP::UserAgent;
use HTTP::Headers;
use HTTP::Request;
use Net::Ping;
use Carp qw(croak);
use JSON;
use Data::Dumper;
use Selenium::Remote::ErrorHandler;
sub new {
my ($class, $remote_
ub/$url";
}
if ((defined $params) && $params ne '') {
my $json = new JSON;
$content = $json->allow_nonref->utf8->encode($params);
}
# HTTP request
my $ua
header =
HTTP::Headers->new(Content_Type => 'application/json; charset=utf-8');
$header->header('Accept' => 'application/json');
my $request = HTTP::Request->new($method, $fullurl, $h
$ctx->req->uri->path("/legacy$path");
}
if($path =~ s/[.]json$// && $ctx->req->content_type eq 'application/json') {
$ctx->req->uri->path($path);
}
};
around uri_for => su
Temp;
use File::Basename qw(dirname);
use IO::Uncompress::Unzip 2.030 qw($UnzipError);
use JSON qw(decode_json);
use MIME::Base64;
use Scalar::Util qw(blessed looks_like_number);
use XML::Simple;
s
keys %prefs ) {
my $value = $prefs{$_};
my $clean_value = '';
if ( JSON::is_bool($value) ) {
$self->set_boolean_preference( $_, $value );
next;
ou can set
multiple preferences at once. If you need to set a boolean preference,
either use JSON::true/JSON::false, or see C<set_boolean_preference()>.
$profile->set_preference("quoted.integer.p
ons for remote viewing
with 'MooseX::Getopt::Dashes';
use IO::Select;
use IO::Socket::INET;
use JSON;
use Scalar::Util 'weaken';
use Term::Filter::Callback;
use Term::ReadKey;
use Try::Tiny;
has
m_metadata_string {
my $self = shift;
my %data = @_;
my $json = JSON::encode_json(\%data);
return "\e[H\x00$json\xff\e[H\e[2J";
}
sub _build_socket {
my $self = shift;
my $
for the duration of the session.
Proxy configuration: "proxy" JSON Defines the current session’s proxy configuration.
New Stuff:
Page load strategy:
Resizing and Positioning Windows.
Session timeouts configuration: "timeouts" JSON Describes the timeouts imposed on certain session operations.
Unhandled prompt behavior:
:Discogs;
use strict;
use warnings;
use LWP::UserAgent;
use URI;
use URI::Escape;
use Carp;
use JSON::XS;
use Data::Dumper;
use 5.008;
our $VERSION = '0.13';
our @namespaces = qw ( Artist Release
\$query_params,
);
my \$json = JSON::XS::decode_json( \$res->decoded_content );
my \$class_data = \$json->{resp}->{'$name'};
\$class_data->{_uri}
\$class_data->{_params} = \$query_params;
if (\$json->{resp}->{status} == JSON::XS::true &&
defined \$json->{resp}->{'$name'}) {
return $pkg->new(\%{\$cl
he sample URI for this request would then be:
https://test.httpapi.com/api/domains/suggest-names.json?auth-userid=0&auth-password=password&keyword=domain&tlds=com&tlds=net&no-of-results=0&hyphen-allo
check that accept the same I<key> multiple times:
https://test.httpapi.com/api/domains/available.json?auth-userid=0&auth-password=password&domain-name=domain1&domain-name=domain2&tlds=com&tlds=net
T
imes except an incrementing digit is appended:
https://test.httpapi.com/api/contacts/set-details.json?auth-userid=0&auth-password=password&contact-id=0&attr-name1=sponsor1&attr-value1=0&product-key=d