API-Client
view release on metacpan or search on metacpan
is used to configure the base URL, and the headers hook, which should
return a ArrayRef[Tuple[Str, Str]] which are used to configure the HTTP
request headers.
transacting
# given: synopsis
my $tx1 = $client->resource('patch')->patch(
json => {active => 1}
);
# is equivalent to
my $tx2 = $client->resource('patch')->dispatch(
method => 'patch',
json => {active => 1}
);
[$tx1, $tx2]
An HTTP request is only issued when the "dispatch" method is called,
directly or indirectly. Those calls return a Mojo::Transaction object
which provides access to the request and response objects.
updating
# given: synopsis
my $tx1 = $client->resource('put')->update(
json => {active => 1}
);
# is equivalent to
my $tx2 = $client->resource('put')->dispatch(
method => 'put',
json => {active => 1}
);
[$tx1, $tx2]
This example illustrates how you might update a new API resource.
ATTRIBUTES
This package has the following attributes:
debug
debug(Bool)
This attribute is read-only, accepts (Bool) values, and is optional.
fatal
fatal(Bool)
This attribute is read-only, accepts (Bool) values, and is optional.
logger
logger(InstanceOf["FlightRecorder"])
This attribute is read-only, accepts (InstanceOf["FlightRecorder"])
values, and is optional.
name
name(Str)
This attribute is read-only, accepts (Str) values, and is optional.
retries
retries(Int)
This attribute is read-only, accepts (Int) values, and is optional.
timeout
timeout(Int)
This attribute is read-only, accepts (Int) values, and is optional.
url
url(InstanceOf["Mojo::URL"])
This attribute is read-only, accepts (InstanceOf["Mojo::URL"]) values,
and is optional.
user_agent
user_agent(InstanceOf["Mojo::UserAgent"])
This attribute is read-only, accepts (InstanceOf["Mojo::UserAgent"])
values, and is optional.
version
version(Str)
This attribute is read-only, accepts (Str) values, and is optional.
METHODS
This package implements the following methods:
create
create(Any %args) : InstanceOf["Mojo::Transaction"]
The create method issues a POST request to the API resource represented
by the object.
create example #1
# given: synopsis
$client->resource('post')->create(
json => {active => 1}
);
( run in 0.754 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )