strictures 2;
use Carp qw(croak);
use GraphViz2 ();
use List::Util qw(first);
use Mojo::JSON qw(from_json to_json);
use Mojo::SQLite ();
use YAML qw(Load LoadFile);
use namespace::clean;
has model =
sts '
. $self->model
. ' (
id integer primary key autoincrement,
settings json not null,
name text not null
)'
);
# create the model specs table unless it's a
. ' (
id integer primary key autoincrement,
model text not null,
spec json not null
)'
);
}
sub make_setting {
my ($self, %args) = @_;
my $id = delete $args{i
#~ @ARGV = qw[];
#~ @ARGV = qw[-json];
#~ @ARGV = qw[-h];
#~ @ARGV = qw[-unsolicited];
#~ @ARGV = qw[-unsolicited -json];
#~ @ARGV = qw[-slip];
#~ @ARGV = qw[-slip -json];
#~ @ARGV = qw[-flavors];
#
m
y $raw = 0;
my $flavor;
sub _echo ($advice) {
$raw && eval 'require JSON::Tiny' ? JSON::Tiny::encode_json( {%$advice} ) : $advice;
}
GetOptions(
\my %h, 'language=s',
'help' => su
> sub { exit !say 'Supported advice flavors: ' . join ', ', Acme::Free::Advice::flavors() },
'json!' => \$raw,
'slip!' => sub { $flavor = 'slip' },
'unsolicited!' => sub { $f
'import';
use Scalar::Util qw(looks_like_number);
use Data::Dumper;
use Syntax::Keyword::Try;
use JSON::MaybeXS qw(is_bool);
our $VERSION = '0.003'; ## VERSION
our @EXPORT_OK = qw(eval_condition);
) if there was error
## or result with the data returned as a result
# "The response contains a JSON object, which always has a Boolean field ‘ok’ and may have an optional String field ‘descri
FeatureResult;
use strict;
use warnings;
no indirect;
use Object::Pad;
use Log::Any qw($log);
use JSON::MaybeXS;
our $VERSION = '0.003'; ## VERSION
class WebService::GrowthBook::FeatureResult{
f
w[-json];
#~ @ARGV = qw[-language fr];
#~ @ARGV = qw[-h];
#
my $raw = 0;
sub _echo ($insult) { # JSON::Tiny is loaded in Acme::Free::Advice::Unsolicited anyway
$raw ? JSON::Tiny::encode_json(
} ) : $insult;
}
GetOptions( \my %h, 'language=s', 'help' => sub { pod2usage( -exitval => 1 ) }, 'json!' => \$raw );
my $shade = Acme::Insult::Evil::insult(%h);
exit !( $shade ? say _echo($shade) : !s
SIS
evil_insult # generate a random insult
evil_insult -json # insult someone if you're a robot
evil_insult -lang fr
imental::postderef /;
use Business::TrueLayer::Webhook::Mandate;
use namespace::autoclean;
use JSON;
use Mojo::JWT;
use Mojo::UserAgent;
use Carp qw/ croak /;
=head1 ATTRIBUTES
=head2 jwt
The JW
g...
my $jwkset = Mojo::UserAgent->new->get( $jku )
->result->json;
# add the jkws to the instance to allow it to check the signature
:Slip 1.1 { # https://api.adviceslip.com/
use v5.38;
use HTTP::Tiny;
use JSON::Tiny qw[decode_json];
use parent 'Exporter';
our %EXPORT_TAGS = ( all => [ our @EXPORT_OK = qw[adv
state $http
//= HTTP::Tiny->new( default_headers => { Accept => 'application/json' }, agent => sprintf '%s/%.2f ', __PACKAGE__, our $VERSION );
my $res = $http->get($uri);
ice is not found but we'll at least know when we have valid JSON
$res->{success} ? decode_json( $res->{content} ) : ();
}
#
sub advice ( $slip_id //= () ) {
my $res = _http
# https://www.freepublicapis.com/insult-api
use v5.38;
use HTTP::Tiny;
use JSON::Tiny qw[decode_json];
use URI;
use parent 'Exporter';
our %EXPORT_TAGS = ( all => [ our @EXPOR
ers => { Accept => 'application/json' }, agent => sprintf '%s/%.2f ', __PACKAGE__, our $VERSION );
( my $hey = $api->clone )->path( '/api/' . $endpoint . '.json' );
$hey->query_form(%p
true even when advice is not found but we'll at least know when we have valid JSON
$res->{success} ? decode_json( $res->{content} ) : ();
}
#
sub insult (%args) { my $ref = _http(
ARGV = qw[-h];
#
my $raw = 0;
sub _echo ($insult) { # JSON::Tiny is loaded in Acme::Insult::Glax anyway
$raw ? JSON::Tiny::encode_json( {%$insult} ) : $insult;
}
GetOptions( \my %h, 'who=s', '
template=s', 'plural!', 'help' => sub { pod2usage( -exitval => 1 ) }, 'json!' => \$raw, 'adjective!', 'sfw!' );
$h{lang} = 'en_corporate' if delete $h{sfw};
my $shade = delete $h{adjective} ? Acme::In
nsult -template='...' # generate insults with a specific format
glax_insult -json # insult someone if you're a robot
glax_insult -who John
ARGV = qw[-json];
#~ @ARGV = qw[-id 5 -json];
#~ @ARGV = qw[-json -id 333];
#~ @ARGV = qw[-all -json];
#~ @ARGV = qw[-id 216];
#
my $raw = 0;
my ( $id, $all );
sub _echo ($slip) { # JSON::Tiny is
loaded in Acme::Free::Advice::Unsolicited anyway
$raw ? JSON::Tiny::encode_json($slip) : $slip;
}
GetOptions( 'json' => \$raw, 'help' => sub { pod2usage( -exitval => 1 ) }, 'id=i' => \$id, 'all!'
_kk -id 5 -json # specific advice by ID but you're a robot
advice_kk -all # get all advice
advice_kk -help # get help
=head1 OPTIONS
-json
-json];
#~ @ARGV = qw[-h];
#~ @ARGV = qw[-evil];
#~ @ARGV = qw[-pirate];
#~ @ARGV = qw[-glax];
#~ @ARGV = qw[-flavors];
#
my $raw = 0;
my $flavor;
sub _echo ($insult) {
$raw && eval 'require JSON
::Tiny' ? JSON::Tiny::encode_json( {%$insult} ) : $insult;
}
GetOptions(
\my %h, 'language=s',
'help' => sub { pod2usage( -exitval => 1 ) },
'flavors!' => sub { exit !say 'Supported in
sult flavors: ' . join ', ', Acme::Insult::flavors() },
'json!' => \$raw,
'glax!' => sub { $flavor = 'glax' },
'evil!' => sub { $flavor = 'evil' },
'pirate!' => sub { $flavor
d 1.1 { # https://kk-advice.koyeb.app/api
use v5.38;
use HTTP::Tiny;
use JSON::Tiny qw[decode_json];
use parent 'Exporter';
our %EXPORT_TAGS = ( all => [ our @EXPORT_OK = qw[adv
state $http
//= HTTP::Tiny->new( default_headers => { Accept => 'application/json' }, agent => sprintf '%s/%.2f ', __PACKAGE__, our $VERSION );
my $res = $http->get($uri);
ice is not found but we'll at least know when we have valid JSON
$res->{success} ? decode_json( $res->{content} ) : ();
}
#
sub advice ( $advice_id //= () ) {
my $res = _ht
www.freepublicapis.com/evil-insult-generator
use v5.38;
use HTTP::Tiny;
use JSON::Tiny qw[decode_json];
use URI;
use parent 'Exporter';
our %EXPORT_TAGS = ( all => [ our @EXPOR
state $http
//= HTTP::Tiny->new( default_headers => { Accept => 'application/json' }, agent => sprintf '%s/%.2f ', __PACKAGE__, our $VERSION );
state $api //= URI->new('ht
but returns the language in a field called 'language'... why?
$api->query_form( type => 'json', ( defined $params{language} ? ( lang => delete $params{language} ) : () ), %params );
m
use strict;
use warnings;
no indirect;
use feature qw(state);
use Object::Pad;
use JSON::MaybeUTF8 qw(decode_json_text);
use Scalar::Util qw(blessed);
use Data::Compare qw(Compare);
use Log::Any qw(
= $instance->get_feature_value('number_feature');
# get decoded json
my $json_feature = $instance->get_feature_value('json_feature');
=head1 DESCRIPTION
This module is a sdk of growthbo
Test
#~ @ARGV = qw[];
#~ @ARGV = qw[-json];
#~ @ARGV = qw[-h];
#
my $raw = 0;
sub _echo ($insult) {
$raw && eval 'require JSON::Tiny' ? JSON::Tiny::encode_json( {%$insult} ) : $insult;
}
GetOptio
ns( \my %h, 'help' => sub { pod2usage( -exitval => 1 ) }, 'json!' => \$raw );
my $shade = Acme::Insult::Pirate::insult(%h);
exit !( $shade ? say _echo($shade) : !say( $raw ? 'null' : '' ) );
__END__
l_insult -json # insult someone if you're a robot
evil_insult -help # get help
=head1 OPTIONS
-json Echo raw JSON encoded
package Acme::Insult::Pirate 1.1 {
use v5.38;
use HTTP::Tiny;
#~ use JSON::Tiny qw[decode_json]; # Not needed here (yet)
use URI;
use parent 'Exporter';
our %EXPORT_TAGS = ( a
state $http
//= HTTP::Tiny->new( default_headers => { Accept => 'application/json' }, agent => sprintf '%s/%.2f ', __PACKAGE__, our $VERSION );
state $api //= URI->new('ht
not found but we'll at least know when we have valid JSON
# This API only returns strings for now
#~ $res->{success} ? decode_json( $res->{content} ) : ();
$res->{success} ? {
@ARGV = qw[-search time];
#~ @ARGV = qw[-json];
#~ @ARGV = qw[-search time -json];
#~ @ARGV = qw[-id 5 -json];
#~ @ARGV = qw[-json -id 333];
#~ @ARGV = qw[-json -id 2];
#~ @ARGV = qw[-help];
#
my $raw
= 0;
my ( $id, $query );
sub _echo ($slip) { # JSON::Tiny is loaded in Acme::Free::Advice::* anyway
$raw ?
JSON::Tiny::encode_json(
builtin::blessed $slip ? {%$slip} : [
{
{%$_}
} @$slip
]
) :
$slip;
}
GetOptions( 'json' => \$raw, 'help' => sub { pod2usage( -exitval => 1 ) }, 'id=i' => \$id, 'search=s' => \$query );
use Log::Any qw($log);
use Digest::MD5 qw(md5_base64);
use Syntax::Keyword::Try;
use JSON::MaybeUTF8 qw(decode_json_utf8);
use WebService::GrowthBook::InMemoryFeatureCache;
our $VERSION = '0.003'; ##
my $decoded = decode_json_utf8($r->{content});
return $decoded;
}
catch ($e){
$log->warnf("Failed to decode feature JSON from GrowthBook API: %s", $e)
}
method _get($url){
my $headers = {
'Content-Type' => 'application/json',
};
return $http->get($url, {headers => $headers});
}
method _get_fea
er
A L<Business::TrueLayer::User> object. Hash refs will be coerced.
=back
=cut
# the mandate JSON, as per the TrueLayer docs, contains a key
# "mandate" that has all the stuff in it, rather than