:Filter::json;
use Pcore -class, -res;
use Pcore::Util::Src qw[:FILTER_STATUS];
with qw[Pcore::Util::Src::Filter];
sub decompress ($self) {
eval {
my $data = P->data->from_json( $self->
lf->{data} = P->data->to_json( $data, readable => 1 );
};
return $@ ? $SRC_FATAL : $SRC_OK;
}
sub compress ($self) {
eval {
my $data = P->data->from_json( $self->{data} );
$self->{data} = P->data->to_json( $data, readable => 0 );
};
return $@ ? $SRC_FATAL : $SRC_OK;
}
1;
## -----SOURCE FILTER LOG BEGIN-----
##
## PerlCritic profile "pcore-script" policy vio
odule_name ~ "::Node::SystemLog" :>;
use Pcore -class, -const, -sql;
use Pcore::Util::Data qw[to_json];
with qw[<: $module_name ~ "::Node" :>];
has store_interval => 0; # PositiveOrZeroInt
has
my $row = [ #
$ev->@{qw[timestamp channel level title]},
ref $ev->{data} ? to_json $ev->{data}, readable => 1 : $ev->{data},
];
# push log record to the store buffer
i
', \%args ) }
# path, Scalar, ArrayRef
# data, Str
# type, ArrayRef[ Enum ['css', 'html', 'js', 'json', 'perl']], list of types to process, used if path is directory
# ignore, Bool, ignore unsupporte
Pcore::API::anticaptcha;
use Pcore -class, -const, -res;
use Pcore::Util::Data qw[to_b64 to_json from_json];
use Pcore::Util::Scalar qw[is_plain_scalarref];
use Pcore::API::anticaptcha::Captcha;
has
tory Server API within 5 seconds' ],
38 => [ 'ERROR_FACTORY_SERVER_BAD_JSON', 'Incorrect Factory Server JSON response, something is broken' ],
39 => [ 'ERROR_FACTORY_SERVER_ERRORI
ptcha.com/getBalance',
data => to_json { #
clientKey => $self->{api_key},
}
);
if ($res) {
my $data = from_json $res->{data}->$*;
# OK
=> {
ENV => \%ENV,
UUID => sub { return P->uuid->str },
TO_JSON => sub { return P->data->to_json(@_) },
TO_XML => sub {
my $data = shift;
my $args = shift;
;
}
return;
}
# TODO, sort query params
sub canon ($self) {
...;
}
# SERIALIZE
*TO_JSON = *TO_CBOR = sub ($self) {
return $self->{uri};
};
1;
## -----SOURCE FILTER LOG BEGIN-----
#
return;
}
sub is_bool : prototype($) {
return ( is_ref $_[0] && ( UNIVERSAL::isa( $_[0], JSON::PP::Boolean:: ) || UNIVERSAL::isa( $_[0], "Data::MessagePack::Boolean" ) ) ) || ( exists $INC{'T
nt-Type' => 'application/json',
],
data => $data ? P->data->to_json($data) : undef
);
my $data = $res->{data} && $res->{data}->$* ? P->data->from_json( $res->{data} ) : undef;
Pcore::Util::Scalar qw[is_path];
our $EXT_TYPE_MAP = {
perl => $DATA_TYPE_PERL,
json => $DATA_TYPE_JSON,
cbor => $DATA_TYPE_CBOR,
yaml => $DATA_TYPE_YAML,
yml => $DATA_TYPE_YAML,
ALL => [qw[encode_data decode_data]],
PERL => [qw[to_perl from_perl]],
JSON => [qw[to_json from_json]],
CBOR => [qw[to_cbor from_cbor]],
YAML => [qw[to_yaml from_yaml]],
X
=> [qw[$DATA_TYPE_PERL $DATA_TYPE_JSON $DATA_TYPE_CBOR $DATA_TYPE_YAML $DATA_TYPE_XML $DATA_TYPE_INI]],
};
const our $DATA_TYPE_PERL => 1;
const our $DATA_TYPE_JSON => 2;
const our $DATA_TYPE_CBOR =
> { #
$DATA_CIPHER_DES => 'DES',
};
our $JSON_CACHE;
# JSON is used by default
# JSON can't serialize ScalarRefs
# objects should have TO_JSON method, otherwise object will be serialized as n
th);
}
sub _clear_cache ($self) {
delete $self->@{qw[_encoded _to_uri]};
return;
}
*TO_JSON = *TO_CBOR = sub ($self) {
return $self->{path};
};
sub TO_DUMP1 ( $self, @ ) {
my $res;
nt-Type' => 'application/json',
],
data => defined $data ? P->data->to_json($data) : undef,
);
if ($res) {
return res $res, P->data->from_json( $res->{data} );
}
else {
return res $res, $res->{data} ? P->data->from_json( $res->{data} ) : ();
}
}
# https://api.cloudflare.com/#zone-list-zones
sub zones ( $self ) {
my $res = $self->_req( 'GET'
ckage Pcore::API::Facebook;
use Pcore -const, -class, -res;
use Pcore::Util::Data qw[to_uri from_json];
use Pcore::Util::Scalar qw[is_plain_arrayref];
with qw[
Pcore::API::Facebook::User
Pcore::
,
url => $url,
data => $data,
);
my $res_data = $res->{data} ? from_json $res->{data} : undef;
if ($res) {
if ($res_data) {
if ( $res_data->{pagi
>set_scandeps("$dist->{share_dir}/pardeps-$self->{SCRIPT_NAME}-@{[$^V->normal]}-$Config{archname}.json");
}
}
return;
}
sub set_scandeps ( $self, $path ) {
$self->{SCANDEPS} = $p
return $self->{main_dist};
}
}
END {
if ( $ENV->{SCANDEPS} ) {
require Cpanel::JSON::XS; ## no critic qw[Modules::ProhibitEvilModules]
my ( $fh, $index );
if (
n]
flock $fh, LOCK_EX or die;
local $/;
my $deps = Cpanel::JSON::XS->new->utf8->decode(<$fh>);
$index->@{ $deps->@* } = ();
}
else {
ri( {
key => $self->{api_key},
action => 'get',
id => $id,
json => 0,
} );
my $url = P->uri( "$self->{api_host}/res.php?$q", proxy => $self->{proxy} )
get( 'http://httpbin.org/ip', proxy => $self );
if ($res) {
my $data = P->data->from_json( $res->{data} );
return res 200, $data->{origin};
}
else {
return $res;
use Pcore::Util::Scalar qw[is_plain_arrayref];
use Pcore::Util::Data qw[to_cbor from_cbor to_json from_json];
use Pcore::Util::UUID qw[uuid_v1mc_str];
use Pcore::HTTP qw[:TLS_CTX];
use Pcore::WebSocke
();
has api_ver => (); # eg: 'v1', default API version for relative methods
has use_json => ();
has timeout => ();
has connect_timeout => 10;
has tls_ctx => $TLS_CTX_HIG
ken}",
'Content-Type' => $self->{use_json} ? 'application/json' : 'application/cbor',
],
data => $self->{use_json} ? to_json $payload : to_cbor $payload
);
if ( !$
com/api2/moz/$self->{api_key}/$domain]);
return $res if !$res;
my $data = P->data->from_json( $res->{data} );
return res 200, $data;
}
1;
__END__
=pod
=encoding utf8
=head1 NAME
Pco
s;
use Pcore::Util::Scalar qw [is_plain_arrayref];
use Pcore::Util::Data qw[to_b64 to_uri to_json from_json];
has api_user => ( required => 1 );
has api_key => ( required => 1 );
has free =>
data => to_json $params,
);
if ($res) {
my $data = from_json $res->{data};
$res = res 200, $data;
}
elsif ( $res->{data} ) {
my $data = from_json $res->{data
ge Pcore::API::PDF;
use Pcore -class, -const, -res;
use Config;
use Pcore::Util::Data qw[to_json from_json];
use Pcore::Util::Scalar qw[is_plain_scalarref];
use Pcore::Util::Sys::Proc qw[:PROC_REDIRE
es ? scalar $resources->@* : 0;
# write job
my $json = to_json $job;
$princexml->{stdin}->write( 'job ' . length($json) . "\n$json\n" );
if ($resources) {
for my $resource (