#!perl
use strict;
use warnings;
use Mojolicious::Lite;
use Mojo::JSON;
$ENV{MOJO_LOG_LEVEL} = 'debug';
plugin 'OAuth2::Server' => {
access_token_ttl => 21600,
authorize_route => '/',
post '/ping/whoami' => sub {
my ( $c ) = @_;
$c->render( json => {
authenticated => Mojo::JSON::true,
client_id => $c->oauth->{client},
user_
,
} );
};
get '/accounts' => sub {
my ( $c ) = @_;
$c->render( json => {
accounts => [
{
id => "acc_00009237
ta to a file as it may contain
sensitive information such as API key(s).
=cut
# plain string or JSON
has message => (
is => 'ro',
required => 1,
coerce => sub {
my ( $mes
nzo::Transaction;
use Business::Monzo::Account;
use Data::Dumper;
use Mojo::UserAgent;
use Mojo::JSON;
use Carp qw/ carp /;
=head1 ATTRIBUTES
=head2 token
Your Monzo access token, this is required
= (
'Authorization' => "Bearer " . $self->token,
'Accept' => 'application/json',
);
if ( $method =~ /POST|PUT|PATCH/i ) {
$tx = $self->_ua->$method( $path => {
if ( $res->is_success ) {
carp( "RES: " . Dumper $res->json )
if $ENV{MONZO_DEBUG};
return $res->json;
}
else {
my $error = $res->message;
car
nstead.
=cut
use strict;
use warnings;
use Moo;
use Carp qw/ confess carp /;
use Mojo::JSON qw/ encode_json /;
use Scalar::Util qw/ blessed /;
use Try::Tiny;
=head1 ATTRIBUTES
The Resource class
ash;
}
=head2 as_json
Returns a json string representation of the object.
my $json = $transaction->as_json;
=cut
sub as_json {
my ( $self ) = @_;
return encode_json( { $self->to_hash
} );
}
# for JSON encoding modules (convert_blessed)
sub TO_JSON { shift->to_hash; }
=head2 get
Returns a new instance of the object populated with the attributes having called
the API
my $po