nputs
my $_resource_path = '/getQueryColumns';
$_resource_path =~ s/{format}/json/; # default format to json
my $_method = 'POST';
my $query_params = {};
my $header_params = {};
tent-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'text/html');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', 'text/xml');
my $_body_data;
# body params
if ( exists $args{'query'}) {
$
se JSON::PP ();
our $VERSION = '0.16';
sub opt_c { shift->_elem('opt_c', @_) }
sub live_cpan_url {
my $self = shift;
my $module = shift;
if ($self->opt_c) {
my $module_json =
ibution");
if (!$module_json) {
die "Unable to fetch changes for $module";
}
my $module_details = JSON::PP::decode_json($module_json);
my $dist = $module_de
e);
my $content = $self->fetch_url($url);
if ($self->opt_c) {
$content = JSON::PP::decode_json($content)->{content};
$content = "=pod\n\n$content";
}
return $content;
r more examples see the t/cases directory in the tarball, which contains
some sample VCARDs and JSON dumps of the hash representation.
BEGIN:VCARD
KEY;PKEY=PVALUE:VALUE
KEY2:VALUE2
END:VCAR
Mojo::Base 'Mojolicious::Plugin';
our $VERSION = '0.03';
use Data::Dumper;
use Mojo::JSON qw(decode_json encode_json);
use Mojo::Util qw{encode decode xml_escape hmac_sha1_sum secure_compare
charset, $html);
}
sub serialize {
return b64_encode(encode_json(shift // return), '');
}
sub deserialize {
return decode_json(b64_decode(shift // return));
}
sub sign {
my ($value, $se
use 5.010;
use strict;
use warnings;
use HTTP::Request::Common;
require LWP::UserAgent;
require JSON;
require Carp;
our $VERSION = '1.03';
sub new {
my $class = shift;
my $self = bless {@
f->{secret} && $self->{postback});
$self->{ua} ||= LWP::UserAgent->new();
$self->{json} ||= JSON->new;
return $self;
}
sub authorize {
my ($self, $params) = @_;
my %params;
d_content unless $response->is_success;
return $response->content if $raw;
return $self->{json}->decode($response->content);
}
sub request_data {
my ( $self, $params ) = @_;
my %para
arget/swagger-codegen-cli.jar generate \
-i [URL or file path to JSON swagger API spec] \
-l perl \
-c /path/to/config/file.json \
-o /path/to/output/folder
Bang, all done. Run the C<autodoc>
Mojo::Base 'Mojolicious::Plugin';
our $VERSION = '0.03';
use Data::Dumper;
use Mojo::JSON qw(decode_json encode_json);
use Mojo::Util qw{encode decode xml_escape hmac_sha1_sum secure_compare
charset, $html);
}
sub serialize {
return b64_encode(encode_json(shift // return), '');
}
sub deserialize {
return decode_json(b64_decode(shift // return));
}
sub sign {
my ($value, $se
(optional) - the payload for POST updates as XML
RETURNS
The response is requested in JSON format which is then processed into a Perl structure that
is returned to the caller.
=cut
::WebApi::Object::TransformResult;
require 5.6.0;
use strict;
use warnings;
use utf8;
use JSON qw(decode_json);
use Data::Dumper;
use Module::Runtime qw(use_module);
use Log::Any qw($log);
use Date::
# return perl hash
sub to_hash {
return decode_json(JSON->new->convert_blessed->encode( shift ));
}
# used by JSON for serialization
sub TO_JSON {
my $self = shift;
my $_data = {};
f
deserialize the data
while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
my $_json_attribute = $self->attribute_map->{$_key};
if ($_type =~ /^array\[/i) { # array
Struct::Dumb qw( readonly_struct );
use Protocol::Matrix::HTTP::Federation;
require JSON;
my $JSON_pretty = JSON->new->utf8(1)->pretty(1);
my $opt_parser = Getopt::Long::Parser->new(
config => [
encode => "raw", # client tokens are already base64 encoded
);
};
}
sub JSON_pretty { $JSON_pretty }
## Builtin commands
package
App::MatrixTool::Command::help;
use base qw( Ap
ilder::WebApi::Object::Pagination;
require 5.6.0;
use strict;
use warnings;
use utf8;
use JSON qw(decode_json);
use Data::Dumper;
use Module::Runtime qw(use_module);
use Log::Any qw($log);
use Date::
# return perl hash
sub to_hash {
return decode_json(JSON->new->convert_blessed->encode( shift ));
}
# used by JSON for serialization
sub TO_JSON {
my $self = shift;
my $_data = {};
f
deserialize the data
while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
my $_json_attribute = $self->attribute_map->{$_key};
if ($_type =~ /^array\[/i) { # array
);
our $VERSION = '0.08';
use MIME::Base64 qw( decode_base64 );
use Protocol::Matrix qw( verify_json_signature );
use constant DESCRIPTION => "Fetch a server's signing key via another server";
use
tary_v2
{
my $self = shift;
my ( $server_name, $via ) = @_;
$self->http_client->request_json(
method => "GET",
server => $via,
path => "/_matrix/key/v2/query/$server_name
);
next unless defined $signing_key;
my $verified = eval { verify_json_signature( $result,
public_key => $signing_key,
origin =>
ryBuilder::WebApi::Object::Totals;
require 5.6.0;
use strict;
use warnings;
use utf8;
use JSON qw(decode_json);
use Data::Dumper;
use Module::Runtime qw(use_module);
use Log::Any qw($log);
use Date::
# return perl hash
sub to_hash {
return decode_json(JSON->new->convert_blessed->encode( shift ));
}
# used by JSON for serialization
sub TO_JSON {
my $self = shift;
my $_data = {};
f
deserialize the data
while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
my $_json_attribute = $self->attribute_map->{$_key};
if ($_type =~ /^array\[/i) { # array
tomatically supply this
access token on every request:
$ matrixtool client -u @me:example.com json /_matrix/client/r0/publicRooms
...
=head1 OPTIONS
The following additional options are recog
sub-commands are recognised
=head2 json
Perform a direct JSON request
$ matrixtool client json PATH [DATA]
See also L<App::MatrixTool::Command::client::json>.
=head2 login
Obtain a client au
{$_} for qw( server user_id user_id_parameter );
return $self->SUPER::run( @args );
}
sub do_json
{
my $self = shift;
my ( $method, $path, %opts ) = @_;
my $client = $self->http_client;
);
our $VERSION = '0.08';
use MIME::Base64 qw( decode_base64 );
use Protocol::Matrix qw( verify_json_signature );
use Net::Async::HTTP;
Net::Async::HTTP->VERSION( '0.40' ); # ->request on_ready
us
$self = shift;
my ( $server_name ) = @_;
my $server_cert;
$self->http_client->request_json(
server => $server_name,
request => $self->federation->make_key_v1_request(
$self = shift;
my ( $server_name ) = @_;
my $server_cert;
$self->http_client->request_json(
server => $server_name,
request => $self->federation->make_key_v2_server_request(
presence.
# See also
# https://github.com/matrix-org/matrix-doc/issues/734
$self->do_json( GET => "/_matrix/client/r0/sync",
params => {
filter =>
'{"room":{' .
yBuilder::WebApi::Object::Sorting;
require 5.6.0;
use strict;
use warnings;
use utf8;
use JSON qw(decode_json);
use Data::Dumper;
use Module::Runtime qw(use_module);
use Log::Any qw($log);
use Date::
# return perl hash
sub to_hash {
return decode_json(JSON->new->convert_blessed->encode( shift ));
}
# used by JSON for serialization
sub TO_JSON {
my $self = shift;
my $_data = {};
f
deserialize the data
while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
my $_json_attribute = $self->attribute_map->{$_key};
if ($_type =~ /^array\[/i) { # array
word = <$stdin>; chomp $password; print "\n";
$stdin->setflag_echo( 1 );
}
$self->do_json( POST => "/_matrix/client/r0/login",
content => {
type => "m.login.password",
uilder::WebApi::Object::Transform;
require 5.6.0;
use strict;
use warnings;
use utf8;
use JSON qw(decode_json);
use Data::Dumper;
use Module::Runtime qw(use_module);
use Log::Any qw($log);
use Date::
# return perl hash
sub to_hash {
return decode_json(JSON->new->convert_blessed->encode( shift ));
}
# used by JSON for serialization
sub TO_JSON {
my $self = shift;
my $_data = {};
f
deserialize the data
while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
my $_json_attribute = $self->attribute_map->{$_key};
if ($_type =~ /^array\[/i) { # array
(.*)$/ or
return Future->fail( "Cannot parse room alias" );
$self->http_client->request_json(
method => "GET",
server => $server,
path => "/_matrix/client/r0/directory/ro