Business-Monzo
view release on metacpan or search on metacpan
monzo_emulator.pl view on Meta::CPAN
webhooks => _webhooks( $account_id ),
} );
};
del '/webhooks/:webhook_id' => sub {
shift->render( json => {} );
};
post '/attachment/upload' => sub {
my ( $c ) = @_;
my $file_name = $c->param( 'file_name' )
|| return $c->render( status => 400, text => "file_name required" );
my $file_type = $c->param( 'file_type' )
|| return $c->render( status => 400, text => "file_type required" );
my $url = $c->req->url;
my $entity_id = "user_00009237hliZellUicKuG1";
$c->render( json => {
"file_url" => $url->base . "/file/$entity_id/LcCu4ogv1xW28OCcvOTL-foo.png",
"upload_url" => $url->base . "/upload/$entity_id/LcCu4ogv1xW28OCcvOTL-foo.png?AWSAccessKeyId=AKIAIR3IFH6UCTCXB5PQ\u0026Expires=1447353431\u0026Signature=k2QeDCCQQHaZeynzYKckejqXRGU%!D(MISSING)"
} );
};
post '/attachment/register' => sub {
my ( $c ) = @_;
my $external_id = $c->param( 'external_id' )
|| return $c->render( status => 400, text => "external_id required" );
my $file_url = $c->param( 'file_url' )
|| return $c->render( status => 400, text => "file_url required" );
my $file_type = $c->param( 'file_type' )
|| return $c->render( status => 400, text => "file_type required" );
$c->render( json => {
"attachment" => {
"id" => "attach_00009238aOAIvVqfb9LrZh",
"user_id" => "user_00009238aMBIIrS5Rdncq9",
"external_id" => $external_id,
"file_url" => $file_url,
"file_type" => $file_type,
"created" => "2015-11-12T18:37:02Z"
}
} );
};
post '/attachment/deregister' => sub {
my ( $c ) = @_;
my $id = $c->param( 'id' )
|| return $c->render( status => 400, text => "id required" );
$c->render( json => {} );
}
};
# convenience methods for file upload emulation, these endpoints
# do not exist in the Monzo API, they are here to fake uploads
get '/file/:entity_id/:file_name' => sub {
my ( $c ) = @_;
$c->render( text => "OK" );
};
post '/upload/:entity_id/:file_name' => sub {
my ( $c ) = @_;
$c->render( text => "OK" );
};
sub _convert_map_params_to_hash {
my ( $c,$prefix ) = @_;
# converts { params[foo] => bar } to { foo => bar }
# (this is horrible! why not just send JSON in the request body?)
my $params = $c->req->params->to_hash;
my %extracted_params =
map { my $v = $params->{$_}; s/^$prefix\[//g; chop; $_ => $v }
grep { /^$prefix\[[^\[]+\]$/ } keys %{ $params // {} };
return \%extracted_params;
}
sub _transactions {
my ( $expand,$metadata ) = @_;
$expand //= 'none';
$metadata //= {
stuff => 'yes',
more_stuff => 'yep',
};
my $attachment = {
"created" => "2016-04-23T12:46:41Z",
"external_id" => "tx_0000...",
"file_type" => "image/jpeg",
"file_url" => "https://...",
"id" => "attach_0000...",
"type" => "image/jpeg",
"url" => "https://...",
"user_id" => "user_0000..."
};
return [
{
"currency" => "GBP",
"merchant" => undef,
"counterparty" => {},
"local_amount" => 10000,
"id" => "1",
"created" => "2016-04-22T12:35:55.563Z",
"is_load" => Mojo::JSON::true,
"updated" => "2016-04-28T20:15:35.043Z",
"notes" => "",
"dedupe_id" => "5529515640563",
( run in 0.631 second using v1.01-cache-2.11-cpan-e1769b4cff6 )