class PendingRequest implements Transient mixin PendingRequest

Traits

Properties

protected array<string, mixed> $context from  HasContext
protected TResource> $resource
protected list<callable|object|string> $requestMiddleware
protected list<callable|object|string> $responseMiddleware
protected PendingRequest|null $request
protected Pipeline $pipeline
protected ApiRequest|null $activeRequest

Methods

mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

mixed
forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

mixed
forwardDecoratedCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object, returning $this if the forwarded call returned itself.

static never
throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

withContext(array|string $key, mixed $value = null)

Set the API request/response context.

mixed
context(string|null $key = null, mixed $default = null)

Get the API request/response context.

__construct(Pipeline|null $pipeline = null)

Create a new pending API request instance.

withApiRequestMiddleware(callable|object|string $middleware)

Add middleware to the API request pipeline.

replaceApiRequestMiddleware(array $middleware)

Replace the API request middleware pipeline.

withApiResponseMiddleware(callable|object|string $middleware)

Add middleware to the API response pipeline.

replaceApiResponseMiddleware(array $middleware)

Replace the API response middleware pipeline.

withoutApiMiddleware()

Remove all API middleware from the request.

prependMiddleware(callable $middleware)

Prepend middleware to the underlying HTTP request pipeline.

withResource(string $resource)

Set the resource class for the request.

get(string $url, Arrayable|array|JsonSerializable|string|null $query = null)

Issue a GET request to the given URL.

head(string $url, Arrayable|array|JsonSerializable|string|null $query = null)

Issue a HEAD request to the given URL.

query(string $url, Arrayable|array|JsonSerializable $data = [])

Issue a QUERY request to the given URL.

post(string $url, Arrayable|array|JsonSerializable $data = [])

Issue a POST request to the given URL.

patch(string $url, Arrayable|array|JsonSerializable $data = [])

Issue a PATCH request to the given URL.

put(string $url, Arrayable|array|JsonSerializable $data = [])

Issue a PUT request to the given URL.

delete(string $url, Arrayable|array|JsonSerializable $data = [])

Issue a DELETE request to the given URL.

send(string $method, string $url, array $options = [])

Send the request to the given URL.

async(bool $async = true)

Enable or disable asynchronous requests.

never
setClient(ClientInterface $client)

Reject a custom Guzzle client that would bypass the API request pipeline.

sendRequest(string $method, mixed ...$arguments)

Send an API request.

runRequestMiddleware(ApiRequest $request)

Run the API request middleware.

runResponseMiddleware(ApiResponse $response)

Run the API response middleware.

getRequest()

Get the underlying HTTP pending request.

mixed
__call(string $method, array $parameters)

Dynamically pass method calls to the underlying HTTP client.

static void
baseUrl(string $url)

No description

static void
withBody(Stringable $content, string $contentType = '\'application/json\'')

No description

static void
asJson()

No description

static void
asForm()

No description

static void
attach(array|string $name, resource|string $contents = '\'\'', ?string $filename = 'null', array $headers = '[]')

No description

static void
asMultipart()

No description

static void
bodyFormat(string $format)

No description

static void
withQueryParameters(array $parameters)

No description

static void
contentType(string $contentType)

No description

static void
acceptJson()

No description

static void
accept(string $contentType)

No description

static void
withHeaders(array $headers)

No description

static void
withHeader(string $name, mixed $value)

No description

static void
replaceHeaders(array $headers)

No description

static void
withBasicAuth(string $username, string $password)

No description

static void
withDigestAuth(string $username, string $password)

No description

static void
withToken(string $token, string $type = '\'Bearer\'')

No description

static void
withUserAgent(bool|string $userAgent)

No description

static void
withUrlParameters(array $parameters = '[]')

No description

static void
withCookie(SetCookie $cookie)

No description

static void
withCookies(array $cookies, string $domain)

No description

static void
maxRedirects(int $max)

No description

static void
withoutRedirecting()

No description

static void
withoutVerifying()

No description

static void
sink(StreamInterface|string $to)

No description

static void
timeout(float|int $seconds)

No description

static void
connectTimeout(float|int $seconds)

No description

static void
retry(array|int $times, Closure|int $sleepMilliseconds = '0', ?callable $when = 'null', bool $throw = 'true')

No description

static void
withOptions(array $options)

No description

static void
withMiddleware(callable $middleware)

No description

static void
withRequestMiddleware(callable $middleware)

No description

static void
withResponseMiddleware(callable $middleware)

No description

static void
withAttributes(array $attributes)

No description

static void
withoutTelescope()

No description

static void
withTelescopeTags(array $tags)

No description

static void
beforeSending(callable $callback)

No description

static void
afterResponse(callable $callback)

No description

static void
throw(?callable $callback = 'null')

No description

static void
throwIf(bool|callable $condition, ?callable $callback = 'null')

No description

static void
throwUnless(bool|callable $condition, ?callable $callback = 'null')

No description

static void
dump()

No description

static void
dd()

No description

static void
stub(Collection $callback)

No description

static void
preventStrayRequests(bool $prevent = 'true')

No description

static void
allowStrayRequests(array $only)

No description

static void
truncateExceptionsAt(int $length)

No description

static void
dontTruncateExceptions()

No description

static void
setHandler(callable $handler)

No description

static void
connection(string $connection, ?array $config = 'null')

No description

Details

in Conditionable at line 23
mixed when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in Conditionable at line 56
mixed unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in ForwardsCalls at line 22
protected mixed forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in ForwardsCalls at line 52
protected mixed forwardDecoratedCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object, returning $this if the forwarded call returned itself.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in ForwardsCalls at line 66
static protected never throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

Parameters

string $method

Return Value

never

Exceptions

BadMethodCallException

in HasContext at line 19
HasContext withContext(array|string $key, mixed $value = null)

Set the API request/response context.

Parameters

array|string $key
mixed $value

Return Value

HasContext

in HasContext at line 35
mixed context(string|null $key = null, mixed $default = null)

Get the API request/response context.

Parameters

string|null $key
mixed $default

Return Value

mixed

at line 116
__construct(Pipeline|null $pipeline = null)

Create a new pending API request instance.

Parameters

Pipeline|null $pipeline

at line 124
PendingRequest withApiRequestMiddleware(callable|object|string $middleware)

Add middleware to the API request pipeline.

Parameters

callable|object|string $middleware

Return Value

PendingRequest

at line 136
PendingRequest replaceApiRequestMiddleware(array $middleware)

Replace the API request middleware pipeline.

Parameters

array $middleware

Return Value

PendingRequest

at line 146
PendingRequest withApiResponseMiddleware(callable|object|string $middleware)

Add middleware to the API response pipeline.

Parameters

callable|object|string $middleware

Return Value

PendingRequest

at line 158
PendingRequest replaceApiResponseMiddleware(array $middleware)

Replace the API response middleware pipeline.

Parameters

array $middleware

Return Value

PendingRequest

at line 168
PendingRequest withoutApiMiddleware()

Remove all API middleware from the request.

Return Value

PendingRequest

at line 181
PendingRequest prependMiddleware(callable $middleware)

Prepend middleware to the underlying HTTP request pipeline.

Parameters

callable $middleware

Return Value

PendingRequest

at line 205
PendingRequest withResource(string $resource)

Set the resource class for the request.

Parameters

string $resource

Return Value

PendingRequest

Exceptions

InvalidArgumentException

at line 225
ApiResource get(string $url, Arrayable|array|JsonSerializable|string|null $query = null)

Issue a GET request to the given URL.

Parameters

string $url
Arrayable|array|JsonSerializable|string|null $query

Return Value

ApiResource

Exceptions

ConnectionException
InvalidArgumentException

at line 239
ApiResource head(string $url, Arrayable|array|JsonSerializable|string|null $query = null)

Issue a HEAD request to the given URL.

Parameters

string $url
Arrayable|array|JsonSerializable|string|null $query

Return Value

ApiResource

Exceptions

ConnectionException
InvalidArgumentException

at line 253
ApiResource query(string $url, Arrayable|array|JsonSerializable $data = [])

Issue a QUERY request to the given URL.

Parameters

string $url
Arrayable|array|JsonSerializable $data

Return Value

ApiResource

Exceptions

ConnectionException
InvalidArgumentException

at line 265
ApiResource post(string $url, Arrayable|array|JsonSerializable $data = [])

Issue a POST request to the given URL.

Parameters

string $url
Arrayable|array|JsonSerializable $data

Return Value

ApiResource

Exceptions

ConnectionException
InvalidArgumentException

at line 277
ApiResource patch(string $url, Arrayable|array|JsonSerializable $data = [])

Issue a PATCH request to the given URL.

Parameters

string $url
Arrayable|array|JsonSerializable $data

Return Value

ApiResource

Exceptions

ConnectionException
InvalidArgumentException

at line 289
ApiResource put(string $url, Arrayable|array|JsonSerializable $data = [])

Issue a PUT request to the given URL.

Parameters

string $url
Arrayable|array|JsonSerializable $data

Return Value

ApiResource

Exceptions

ConnectionException
InvalidArgumentException

at line 301
ApiResource delete(string $url, Arrayable|array|JsonSerializable $data = [])

Issue a DELETE request to the given URL.

Parameters

string $url
Arrayable|array|JsonSerializable $data

Return Value

ApiResource

Exceptions

ConnectionException
InvalidArgumentException

at line 313
ApiResource send(string $method, string $url, array $options = [])

Send the request to the given URL.

Parameters

string $method
string $url
array $options

Return Value

ApiResource

Exceptions

Throwable
InvalidArgumentException

at line 321
PendingRequest async(bool $async = true)

Enable or disable asynchronous requests.

Parameters

bool $async

Return Value

PendingRequest

at line 333
never setClient(ClientInterface $client)

Reject a custom Guzzle client that would bypass the API request pipeline.

Parameters

ClientInterface $client

Return Value

never

at line 345
protected ApiResource sendRequest(string $method, mixed ...$arguments)

Send an API request.

Parameters

string $method
mixed ...$arguments

Return Value

ApiResource

at line 371
protected ApiRequest runRequestMiddleware(ApiRequest $request)

Run the API request middleware.

Parameters

ApiRequest $request

Return Value

ApiRequest

at line 382
protected ApiResponse runResponseMiddleware(ApiResponse $response)

Run the API response middleware.

Parameters

ApiResponse $response

Return Value

ApiResponse

at line 393
protected PendingRequest getRequest()

Get the underlying HTTP pending request.

Return Value

PendingRequest

at line 420
mixed __call(string $method, array $parameters)

Dynamically pass method calls to the underlying HTTP client.

Parameters

string $method
array $parameters

Return Value

mixed

at line 86
static void baseUrl(string $url)

No description

Parameters

string $url

Return Value

void

at line 86
static void withBody(Stringable $content, string $contentType = '\'application/json\'')

No description

Parameters

Stringable $content
string $contentType

Return Value

void

at line 86
static void asJson()

No description

Return Value

void

at line 86
static void asForm()

No description

Return Value

void

at line 86
static void attach(array|string $name, resource|string $contents = '\'\'', ?string $filename = 'null', array $headers = '[]')

No description

Parameters

array|string $name
resource|string $contents
?string $filename
array $headers

Return Value

void

at line 86
static void asMultipart()

No description

Return Value

void

at line 86
static void bodyFormat(string $format)

No description

Parameters

string $format

Return Value

void

at line 86
static void withQueryParameters(array $parameters)

No description

Parameters

array $parameters

Return Value

void

at line 86
static void contentType(string $contentType)

No description

Parameters

string $contentType

Return Value

void

at line 86
static void acceptJson()

No description

Return Value

void

at line 86
static void accept(string $contentType)

No description

Parameters

string $contentType

Return Value

void

at line 86
static void withHeaders(array $headers)

No description

Parameters

array $headers

Return Value

void

at line 86
static void withHeader(string $name, mixed $value)

No description

Parameters

string $name
mixed $value

Return Value

void

at line 86
static void replaceHeaders(array $headers)

No description

Parameters

array $headers

Return Value

void

at line 86
static void withBasicAuth(string $username, string $password)

No description

Parameters

string $username
string $password

Return Value

void

at line 86
static void withDigestAuth(string $username, string $password)

No description

Parameters

string $username
string $password

Return Value

void

at line 86
static void withToken(string $token, string $type = '\'Bearer\'')

No description

Parameters

string $token
string $type

Return Value

void

at line 86
static void withUserAgent(bool|string $userAgent)

No description

Parameters

bool|string $userAgent

Return Value

void

at line 86
static void withUrlParameters(array $parameters = '[]')

No description

Parameters

array $parameters

Return Value

void

at line 86
static void withCookie(SetCookie $cookie)

No description

Parameters

SetCookie $cookie

Return Value

void

at line 86
static void withCookies(array $cookies, string $domain)

No description

Parameters

array $cookies
string $domain

Return Value

void

at line 86
static void maxRedirects(int $max)

No description

Parameters

int $max

Return Value

void

at line 86
static void withoutRedirecting()

No description

Return Value

void

at line 86
static void withoutVerifying()

No description

Return Value

void

at line 86
static void sink(StreamInterface|string $to)

No description

Parameters

StreamInterface|string $to

Return Value

void

at line 86
static void timeout(float|int $seconds)

No description

Parameters

float|int $seconds

Return Value

void

at line 86
static void connectTimeout(float|int $seconds)

No description

Parameters

float|int $seconds

Return Value

void

at line 86
static void retry(array|int $times, Closure|int $sleepMilliseconds = '0', ?callable $when = 'null', bool $throw = 'true')

No description

Parameters

array|int $times
Closure|int $sleepMilliseconds
?callable $when
bool $throw

Return Value

void

at line 86
static void withOptions(array $options)

No description

Parameters

array $options

Return Value

void

at line 86
static void withMiddleware(callable $middleware)

No description

Parameters

callable $middleware

Return Value

void

at line 86
static void withRequestMiddleware(callable $middleware)

No description

Parameters

callable $middleware

Return Value

void

at line 86
static void withResponseMiddleware(callable $middleware)

No description

Parameters

callable $middleware

Return Value

void

at line 86
static void withAttributes(array $attributes)

No description

Parameters

array $attributes

Return Value

void

at line 86
static void withoutTelescope()

No description

Return Value

void

at line 86
static void withTelescopeTags(array $tags)

No description

Parameters

array $tags

Return Value

void

at line 86
static void beforeSending(callable $callback)

No description

Parameters

callable $callback

Return Value

void

at line 86
static void afterResponse(callable $callback)

No description

Parameters

callable $callback

Return Value

void

at line 86
static void throw(?callable $callback = 'null')

No description

Parameters

?callable $callback

Return Value

void

at line 86
static void throwIf(bool|callable $condition, ?callable $callback = 'null')

No description

Parameters

bool|callable $condition
?callable $callback

Return Value

void

at line 86
static void throwUnless(bool|callable $condition, ?callable $callback = 'null')

No description

Parameters

bool|callable $condition
?callable $callback

Return Value

void

at line 86
static void dump()

No description

Return Value

void

at line 86
static void dd()

No description

Return Value

void

at line 86
static void stub(Collection $callback)

No description

Parameters

Collection $callback

Return Value

void

at line 86
static void preventStrayRequests(bool $prevent = 'true')

No description

Parameters

bool $prevent

Return Value

void

at line 86
static void allowStrayRequests(array $only)

No description

Parameters

array $only

Return Value

void

at line 86
static void truncateExceptionsAt(int $length)

No description

Parameters

int $length

Return Value

void

at line 86
static void dontTruncateExceptions()

No description

Return Value

void

at line 86
static void setHandler(callable $handler)

No description

Parameters

callable $handler

Return Value

void

at line 86
static void connection(string $connection, ?array $config = 'null')

No description

Parameters

string $connection
?array $config

Return Value

void