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.

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
;