re::Const;
use common::header;
use Const::Fast qw[const];
use Pcore::Core::Exporter;
use Cpanel::JSON::XS qw[];
# <<<
const our $ANSI => {
RESET => 0,
BOLD => 1,
DARK
our $EMPTY => q[];
const our $SPACE => q[ ];
const our $TRUE => $Cpanel::JSON::XS::true;
const our $FALSE => $Cpanel::JSON::XS::false;
sub TO_BOOL : prototype($) {
return $_[0] ? $TRUE : $FALS
;
The C<post()> method adds or updates the license for the cluster. The C<body>
can be passed as JSON or as a string.
See the L<license.put docs|https://www.elastic.co/guide/en/x-pack/current/instal
LWP::UserAgent qw//;
use JSON qw//;
use HTTP::Request qw//;
use Stance::GitHub::Organization;
sub from_json {
JSON->new->utf8->decode(@_);
}
sub to_json {
JSON->new->utf8->encode(@_);
$url))
or die "unable to create GET $url request: $!\n";
$req->header('Accept' => 'application/json');
$req->header('Authorization', 'token [REDACTED]')
if $self->{_token};
if ($self->{_debug})
-----------------\n";
print STDERR $res->as_string;
print STDERR "\n\n";
}
my $body = from_json($res->decoded_content);
if (!$res->is_success) {
$self->{_error} = $body;
return undef;
}
N = "1.0.0";
use LWP::UserAgent qw//;
use JSON qw//;
use HTTP::Request qw//;
sub from_json {
JSON->new->utf8->decode(@_);
}
sub to_json {
JSON->new->utf8->encode(@_);
}
sub new {
my (
$url))
or die "unable to create GET $url request: $!\n";
$req->header('Accept' => 'application/json');
$req->header('X-Vault-Token', '[REDACTED]')
if $self->{_token};
if ($self->{_debug}) {
p
-----------------\n";
print STDERR $res->as_string;
print STDERR "\n\n";
}
my $body = from_json($res->decoded_content);
if (!$res->is_success) {
$self->{_error} = $body;
return undef;
}
);
The C<put()> method adds or updates the license for the cluster. The C<body>
can be passed as JSON or as a string.
See the L<license.put docs|https://www.elastic.co/guide/en/shield/current/licens
=> 'proxyip',
'10.10.0.2' => 'proxyip',
);
=cut
use strict;
use warnings;
use Carp;
use JSON;
use YAML::XS;
use Net::IP::Match::Regexp qw( match_ip create_iprange_regexp_depthfirst );
use Da
>is_success;
}
my $data = eval{ JSON->new->allow_nonref->utf8(1)->decode( $res->content ); };
die "from_json fail: $@" if $@;
$self{conf} = $data->{stat
ast, almanac, satellite and radar maps, etc.
=head1 SYNOPSIS
Connect to the Weather Underground JSON/XML webservice
and parse the response data into something usable.
The entire response is availab
t result from the most recent API call. This will be either xml or json depending on api_type.
You can also set this to whatever json/xml you'd like, though I can't imagine why you'd want to.
=head2
ns raw xml result from wunderground server where applicable
=head2 json()
*Deprecated* - use L</"raw()"> instead.
Returns raw json result from wunderground server where applicable
=head2 data()
C
package WWW::Wunderground::API;
use 5.006;
use Moo;
use URI;
use JSON::MaybeXS;
use LWP::Simple;
use XML::Simple;
use Hash::AsObject;
=head1 NAME
WWW::Wunderground::API - Interface to Weather Under
||$ENV{WUNDERGROUND_KEY} });
has api_type => (is=>'rw', lazy=>1, default=>sub { $_[0]->api_key ? 'json' : 'xml' });
has cache => (is=>'ro', lazy=>1, default=>sub { WWW::Wunderground::API::BadCache->ne
ta => (is=>'rw', lazy=>1, default=>sub{ Hash::AsObject->new } );
sub json {
my $self = shift;
return $self->api_type eq 'json' ? $self->raw : undef;
}
sub xml {
my $self = shift;
return $sel
SCK;
use strict;
use warnings;
use LWP::Protocol::https;
use URI::Escape qw/uri_escape_utf8/;
use JSON;
our $VERSION = '0.8'; # VERSION
# ABSTRACT: Perl interface to sck.pm
use 5.006;
use parent
( $sck_url . '/shorten?' . $url, );
return unless $resp->is_success;
my $content = decode_json( $resp->content );
if ( ref $content && $content->{status} eq 'OK' ) {
return $conten
//api.sck.pm/expand?" . $sck_url );
return unless $resp->is_success;
my $content = decode_json( $resp->content );
if ( ref $content && $content->{status} eq 'OK' ) {
return $conten
package MYDan::API;
use strict;
use warnings;
use Carp;
use JSON;
use LWP::UserAgent;
use MYDan::Util::OptConf;
use URI::Escape;
use YAML::XS;
my $o; BEGIN{ $o = MYDan::Util::OptConf->load()->dump(
uri";
return +{ stat => JSON::true, data => $url } if $self->{urlonly};
my $res = $self->{ua}->get( $url );
my $cont = $res->content;
return +{ stat => JSON::false, info => $res->cont
ent } unless $res->is_success;
my $data = eval{ JSON::from_json $cont };
return $@ ? +{ stat => JSON::false, info => $@ } : $data;
}
sub get
{
my ( $self, $uri ) = @_;
my $error = "
;
The C<post()> method adds or updates the license for the cluster. The C<body>
can be passed as JSON or as a string.
See the L<license.put docs|https://www.elastic.co/guide/en/x-pack/current/instal
ver.
=item C<x-unparseable-data-received>
The http request was completed successfully but Mojo::JSON could not
decode the response received from the reCAPTCHA server.
=back
=head1 SEE ALSO
=over
return Data::CSel::WrapStruct::ScalarRef->new($data, $parent, undef);
} elsif ($ref eq 'JSON::PP::Boolean') {
return Data::CSel::WrapStruct::Scalar->new($$data, $parent, undef);
either a scalar (assumed to be the JSON string
contents of the Slack webhook), or a hash containing a Slack webhook
structure (will be encoded to JSON using C<JSON::PP>).
More information about the
s a Github-compatible Webhook.
The function should be passed a hash containing two keys: C<json> as the JSON
string of a Github webhook, and C<event> as the string containing the name of
the Github e
rnings;
# Module for interacting with the REST service
use HTTP::Tiny;
# JSON decode
use JSON::PP qw(encode_json decode_json);
# Base64 encode for avatar images
use MIME::Base64 qw(encode_base64);
res after a webhook request
sub _parse_response {
my $self = shift;
my $json = shift;
my $response = decode_json($json);
# sanity
if ( $self->{id} ne $response->{id} ) {
croak "SERVICE
quest(
'PATCH', $url,
{
headers => { 'Content-Type' => 'application/json' },
content => encode_json( \%request )
}
);
if ( !$response->{success} ) {
# non-200 code ret
BSTRACT: use Googles "No CAPTCHA reCAPCTHA" (reCAPTCHA v2) service in Mojolicious apps
use Mojo::JSON qw();
use Mojo::UserAgent qw();
has conf => sub { +{} };
has ua => sub { Mojo::UserAgent->new(
my $json = '';
eval { $json = Mojo::JSON::decode_json( $tx->res->body ); };
if ( $@ ) {
$c->app->log->error( 'Decoding JSON respons
nless ( $json->{'success'} == Mojo::JSON->true ) {
@{$err} = @{ $json->{'error-codes'} // [] };
}
$verified = $json->{'succe
Util/dumper> except for
C<download>.
=head2 dispatch_cmd_raw_p
Returns a promise of the decoded JSON value or C<download>ed content.
=head2 dir_walk_p
Takes C<$from_dir>, C<$to_dir>, C<$from_map>,
ub _error_or_json {
my $res = $_[0]->res;
die $res->code . ": " . $res->message . "\n" if $res->code != 200;
$res->json;
}
sub _uapi_error_or_json {
my $json = $_[0];
if (!$json->{status})
{
die join '', "Failed:\n",
map "$_\n", map @{ $json->{$_} || [] }, qw(errors warnings);
}
$json;
}
sub uapi_p {
my ($module, $function, @args) = @_;
die "No module\n" unless $modul
iption - sets the metadata value
=item *
init - Reveal.js initialization options, a hashref for JSON conversion documented below
=item *
theme - a string representing a theme css to be included.
I
this driver
=head1 METHODS
=cut
use base 'SMS::Send::Driver';
use LWP::UserAgent();
use JSON qw(encode_json);
use URI::Escape qw(uri_escape);
use Scalar::Util qw( looks_like_number );
use Crypt::JW
Agent->new;
my $to = clean_number($params{to});
# Send the request
my $body = encode_json({
phone_number => $to,
template_id => $self->{template_id},
personalisat
st(
$self->{'base_url'} . '/v2/notifications/sms',
'Content-Type' => 'application/json',
Authorization => 'Bearer ' . $self->{'token'},
Content => $body
);
er the use of these
serializers:
=over 4
=item C<< ".yaml" => "YAML::Syck" >>
=item C<< ".json" => "JSON" >>
=item C<< ".sto" => "Storable" >>
=item C<< ".dd" => "Data::Dumper" >>
=back
=cut