=head1 DESCRIPTION
This module provides the interface to the Verify methods of the MessageBird
JSON API.
The methods implmented acceept the paramteres as named in the MessageBird API
documentation
y
checking.
=item content
This is a Perl hashref data structure decoded from the API's response JSON
as-is.
Please see the L<MessageBird Developer Documentation|https://www.messagebird.com/en-gb/de
DESCRIPTION
This module provides the interface to the Lookup related methods of the
MessageBird JSON API.
The methods implmented acceept the paramteres as named in the MessageBird API
documentation
y
checking.
=item content
This is a Perl hashref data structure decoded from the API's response JSON
as-is.
Please see the L<MessageBird Developer Documentation|https://www.messagebird.com/en-gb/de
=head1 DESCRIPTION
This module provides the interface to the Balance method of the MessageBird
JSON API.
The methods implmented acceept the paramteres as named in the MessageBird API
documentation
y
checking.
=item content
This is a Perl hashref data structure decoded from the API's response JSON
as-is.
Please see the L<MessageBird Developer Documentation|https://www.messagebird.com/en-gb/de
ssageBird::API;
use strict;
use warnings;
use Encode qw( encode_utf8 );
use LWP::UserAgent;
use JSON;
use URI;
=head1 NAME
SMS::MessageBird::API - Provides API integration base for SMS::MessageBir
eaders => HTTP::Headers->new(
'content-type' => 'application/json',
Accept => 'application/json',
Authorization => 'AccessKey ' . $self->{api_key},
d.
} else {
my $content_payload = JSON->new->encode($data);
$request_params{'Content-Type'} = 'application/json;charset=utf-8',
$request_params{Content} =
ad1 DESCRIPTION
This module provides the interface to the SMS sending methods of the MessageBird
JSON API.
The methods implmented acceept the paramteres as named in the MessageBird API
documentation
y
checking.
=item content
This is a Perl hashref data structure decoded from the API's response JSON
as-is.
Please see the L<MessageBird Developer Documentation|https://www.messagebird.com/en-gb/de
0.23';
use DateTime;
use DateTime::Format::Strptime;
use File::Path;
#use JSON qw/decode_json/;
use JSON::Parse qw/parse_json/;
use Try::Tiny;
use Data::Dump qw/dump pp/;
use File::Find;
# DBIx::Cla
a
# regex pattern, e.g. '\.json$' or can be a precompiled regex
# which apart from the added speed (possibly) offers the flexibility
# of using regex switches, e.g. qr/\.json$/i
sub find_files {
# an
ng, $!"; return undef }
my $json_contents = undef;
{local $/ = undef; $json_contents = <$fh> } close($fh);
my $inhash = Statistics::Covid::Utils::configstring2perl($json_contents);
if( ! defined $
es9.arcgis.com/N9p5hsImWXAccRNI/arcgis/rest/services/Z7biAeD8PAkqgmWhxG2A/FeatureServer/1/query?f=json&where=Confirmed%20%3E%3D%200&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*
N9p5hsImWXAccRNI/arcgis/rest/services/Z7biAeD8PAkqgmWhxG2A/FeatureServer/1/query?cacheHint=true&f=json&orderByFields=Confirmed+desc%2CCountry_Region+asc%2CProvince_State+asc&outFields=*&resultOffset=0
es9.arcgis.com/N9p5hsImWXAccRNI/arcgis/rest/services/Z7biAeD8PAkqgmWhxG2A/FeatureServer/1/query?f=json&where=Confirmed%20%3E%200&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&or
->{start_time},
cfg => $cfg,
);
}
=head2 TO_JSON
C<TO_JSON> will return the entry as a JSON convertible hash.
=cut
sub TO_JSON {
my $self = shift;
{
start_time => $self->star
e;
# read data from db
$covid = Statistics::Covid->new({
'config-file' => 't/config-for-t.json',
'debug' => 2,
}) or die "Statistics::Covid->new() failed";
# retrieve data from DB for sele
ervices1.arcgis.com/0IrmI40n5ZYxTUrV/arcgis/rest/services/DailyIndicators/FeatureServer/0/query?f=json&where=1%3D1&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&resultOffset=0&r
ervices1.arcgis.com/0IrmI40n5ZYxTUrV/arcgis/rest/services/CountyUAs_cases/FeatureServer/0/query?f=json&where=TotalCases%20%3C%3E%200&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=
ervices1.arcgis.com/0IrmI40n5ZYxTUrV/arcgis/rest/services/CountyUAs_cases/FeatureServer/0/query?f=json&where=TotalCases%20%3E%3D%200&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=
;
# read data from db
$covid = Statistics::Covid->new({
'config-file' => 't/config-for-t.json',
'debug' => 2,
}) or die "Statistics::Covid->new() failed";
# retrieve data from DB for sele
6ba-e579c2d3230a";
my $json = eval { require JSON::XS; JSON::XS:: } || do { require JSON::PP; JSON::PP:: };
$json = $json->new->utf8;
$json->boolean_values (0, 1)
if $json->can ("boolean_values")
=> { "content-type" => "application/json; charset=utf-8", "cache-control" => "no-cache" },
sub {
my ($res, $hdr) = @_;
$res = eval { $json->decode ($res) };
$hdr->{S
p, undef, $cb)
}
sub post_ {
my ($self, $ep, $data, $cb) = @_;
$self->req_ (POST => $ep, $json->encode ($data || {}), $cb)
}
sub delete_ {
my ($self, $ep, $cb) = @_;
$self->req_ (DELET
ime;
use File::Spec;
use File::Path;
use Data::Dump;
use JSON::Parse;
use File::Basename;
# this will take all the pv (the perl-vars-from-json fetched)
# and create a data id to be used for labelling
ata_received_string is the json string fetched (or whatever the provider sent)
# data_as_perlvar is the data received as a perlvar (if it's json we received, then JSON::json_decode()
# will give the p
s a perl variable (Data::Dump) with extension .pl
# and also as a json file (verbatim from the data provider)
# with extension .json.
# Ideally you need only the .pl file
# For other data provider
[...]
"So no common::sense for me, alas."
H.Merijn Brand
"Just one more reason to drop JSON::XS from my distribution list"
Pista Palo
"Something in short supply these days..."
Steffen
oyal 'we' in the documentation"
Anonymous Monk
"You just gotta love this thing, its got META.json!!!"
dngor
"Heh. '"<elmex at ta-sa.org>"' The quotes are semantic
distancing from that e
w about quoting this: get a clue, you fucktarded amoeba."
quanth
"common sense is beautiful, json::xs is fast, Anyevent, EV are fast and
furious. I love mlehmannware ;)"
apeiron
"... it's
<<'EXA'
db-search-and-make-new-db.pl --config-file-source config/config.json --config-file-destination config/destination.json --tablename 'Datum' --conditions "{'name'=>'Hackney'}" --attributes "{'r
a DBIx::Class::ResultSet->search() takes
# returns undef on failure
# returns the loaded datum objs on success (can be empty) as a hashref
sub select_datums_from_db {
my ($self, $params) = @_;
my
ovider '$providerstr'." }
my $jsonfiles = Statistics::Covid::Utils::find_files($datadir, qr/\.json$/i);
@basenames = map { s/\.((data)|(meta))\.json$//; $_ } @$jsonfiles;
}
if( scalar(@basenames
tistics::Covid::Datum;
$covid = Statistics::Covid->new({
'config-file' => 't/config-for-t.json',
'providers' => ['UK::BBC', 'UK::GOVUK', 'World::JHU'],
'save-to-file' => 1,
'save-to-db'
from file or set via the config* subs
# this reflects exactly the configuration json file (e.g. t/example-config.json)
# with 'dbparams' as subhash
'config-hash' => undef,
};
bless $self => $c
ename($params->{'log-filename'}) }
# we accept config-file or config-hash, see t/example-config.json for an example
if( exists $params->{'config-file'} ){ if( ! $self->config_file($params->{'config
]->config()->{'dbparams'} }
sub fileparams { return $_[0]->config()->{'fileparams'} }
# reads json data from file which represents the configuration settings
# for this module. It contains a 'file
'} = [
[
# start a url
'https://www.bbc.co.uk/indepthtoolkit/data-sets/coronavirus_lookup/json',
# and its headers if any
[]
]
];
# initialise our parent class
my $self = $class->SU
my $datas = $_[1]; # this is an arrayref of [url, data_received_string, data_as_perlvar]
# this json is idiotic because it's just arrays,
# 0: location id
# 1: location name
# 2: cases
# 3: popu
0]->[0];
for my $apv (reverse @{$datas->[0]->[2]}){ # we only have 1 triplet and we get the perl-json-var
if( $apv->[0] eq 'UpdatedOn' ){
$date = Statistics::Covid::Utils::epoch_stupid_date_form
pp foo.pl
use Mojolicious::Lite -signarues;
get '/foo' => sub($c) { $c->render( json => { foo => 123 } ) };
app->start;
################################################
'/bar' => sub($c) { $c->render( json => { bar => 456 } ) };
post '/baz' => sub($c) {
my $baz = $c->req->json->{baz} || 0;
$c->render( json => { baz => $baz + 42 } );
<<'EXA'
db-search-and-make-new-db.pl --config-file-source config/config.json --config-file-destination config/destination.json --tablename 'Datum' --conditions "{'name'=>'Hackney'}" --attributes "{'r