NAME
PayProp::API::Public::Client::Role::Request - Role to encapsulate async requests.
SYNOPSIS
package Module::Requiring::Requests;
with qw/ PayProp::API::Public::Client::Role::Request /;
...;
sub query_params { [qw/ ... /] }
__PACKAGE__->meta->make_immutable;
my $Module = Module::Requiring::Requests->new( url => 'https://mock.com' );
my $Promise = $Module
->get_req_p({ params => {}, headers => {} })
->then(sub {
my ( $Transaction, ... ) = @_;
...;
})
->wait
;
DESCRIPTION
Define methods to make async requests via Mojo::UserAgent
and return Mojo::Promise
.
METHODS
get_req_p
Perform GET
request and return Mojo::Promise
. See https://docs.mojolicious.org/Mojo/UserAgent#get_p for returned values.
$self
->get_req_p({
params => {},
headers => {},
})
->then( sub {
my ( $Transaction, ... ) = @_;
...;
} )
->wait
;
post_req_p
Perform POST
request and return Mojo::Promise
. See https://docs.mojolicious.org/Mojo/UserAgent#post_p for returned values.
$self
->post_req_p({
params => {},
headers => {},
content => { json => { ... } },
})
->then( sub {
my ( $Transaction, ... ) = @_;
...;
} )
->wait
;
put_req_p
Perform PUT
request and return Mojo::Promise
. See https://docs.mojolicious.org/Mojo/UserAgent#put_p for returned values.
$self
->put_req_p({
params => {},
headers => {},
content => { json => { ... } },
})
->then( sub {
my ( $Transaction, ... ) = @_;
...;
} )
->wait
;
delete_req_p
Perform DELETE
request and return Mojo::Promise
. See https://docs.mojolicious.org/Mojo/UserAgent#delete_p for returned values.
$self
->delete_req_p({ ... })
->then( sub {
my ( $Transaction, ... ) = @_;
...;
} )
->wait
;
AUTHOR
Yanga Kandeni <yangak@cpan.org>
Valters Skrupskis <malishew@cpan.org>
COPYRIGHT
Copyright 2023- PayProp
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
If you would like to contribute documentation or file a bug report then please raise an issue / pull request: