SoloRequest
abstract class SoloRequest extends Request
Traits
Properties
| protected Authenticator|null | $authenticator | The authenticator used in requests. |
from AuthenticatesRequests |
| protected BodyRepository|null | $bodyRepository | The request body repository. |
from HasBody |
| protected null|Response> | $response | The default response class. |
from HasCustomResponses |
| protected MockClient|null | $mockClient | The operation-owned mock client. |
from HasMockClient |
| protected list<array<string, mixed>> | $cookies | The request cookies and their attributes. |
from HasCookies |
| protected IntegerRepository|null | $delayRepository | The request delay. |
from HasDelay |
| protected ArrayRepository|null | $headerRepository | The request headers. |
from HasHeaders |
| protected MiddlewarePipeline|null | $middlewarePipeline | The request middleware pipeline. |
from HasMiddleware |
| protected ArrayRepository|null | $optionRepository | The request options. |
from HasOptions |
| protected ArrayRepository|null | $queryRepository | The request query parameters. |
from HasQuery |
| protected string|null | $queryString | The already-encoded query string override. |
from HasQuery |
| protected RetryPolicy|null | $retryPolicy | The request retry policy. |
from HasRetryPolicy |
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected Method | $method | The HTTP method used by the request. |
from Request |
| protected string|null | $url | The caller-supplied absolute URL override. |
from Request |
| protected Connector|null | $connector | The connector used by the standalone request. |
Methods
Authenticate the request with a token.
Authenticate the request with basic authentication.
Authenticate the request with digest authentication.
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Handle the final PSR request before it is sent.
Set the raw request body.
Attach a multipart value to the request.
Copy the body repository for a pending request.
Debug the final application-owned request.
Debug the response before ordinary response middleware.
Specify a cookie and its attributes for the request.
Specify cookies that should be included with the request.
Indicate the type of content that should be returned by the server.
Indicate that TLS certificates should not be verified.
Specify where the response body should be stored.
Specify the connection timeout in seconds.
Get the raw query string override, without a leading question mark.
Replace the base URL and endpoint query string.
Specify the number of times the request should be attempted.
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Create a new instance with the given arguments.
Determine if the response should throw a request exception.
Resolve whether this request may use an absolute endpoint.
Determine if the matching cache entry should be invalidated.
Resolve the request's rate limiter store.
Resolve the request's stable cooldown key.
Create the connector used by the standalone request.
Details
in
CreatesDtoFromResponse at line 17
mixed
createDtoFromResponse(Response $response)
Create a data object from the response.
in
AuthenticatesRequests at line 23
protected Authenticator|null
defaultAuth()
Resolve the default authenticator.
in
AuthenticatesRequests at line 31
Authenticator|null
authenticator()
Get the authenticator.
in
AuthenticatesRequests at line 41
AuthenticatesRequests
authenticate(Authenticator $authenticator)
Authenticate the request with an authenticator.
in
AuthenticatesRequests at line 53
AuthenticatesRequests
withToken(string $token, string $type = 'Bearer')
Authenticate the request with a token.
in
AuthenticatesRequests at line 63
AuthenticatesRequests
withBasicAuth(string $username, string $password)
Authenticate the request with basic authentication.
in
AuthenticatesRequests at line 73
AuthenticatesRequests
withDigestAuth(string $username, string $password)
Authenticate the request with digest authentication.
in
Bootable at line 14
void
boot(PendingRequest $pendingRequest)
Configure a pending request for this resource.
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.
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.
in
HandlesPsrRequest at line 15
RequestInterface
handlePsrRequest(RequestInterface $request, PendingRequest $pendingRequest)
Handle the final PSR request before it is sent.
in
HasBody at line 31
HasBody
withBody(mixed $content, string|null $contentType = 'application/json')
Set the raw request body.
in
HasBody at line 89
HasBody
attach(string $name, mixed $contents = '', string|null $filename = null, array $headers = [])
Attach a multipart value to the request.
in
HasBody at line 129
mixed
body()
Get the resolved request body value.
in
HasBody at line 137
bool
hasBody()
Determine if the request has a body repository.
in
HasBody at line 147
final BodyRepository|null
copyBodyRepository()
| internal |
Copy the body repository for a pending request.
in
HasBody at line 157
protected BodyRepository|null
defaultBodyRepository()
Resolve the default body repository.
in
HasBody at line 165
protected BodyRepository|null
bodyRepository()
Get the request body repository.
in
HasCustomResponses at line 23
string|null
resolveResponseClass(Response $response)
Resolve the custom response class.
in
HasDebugging at line 22
HasDebugging
debugRequest(callable|null $onRequest = null, bool $die = false)
Debug the final application-owned request.
in
HasDebugging at line 50
HasDebugging
debugResponse(callable|null $onResponse = null, bool $die = false)
Debug the response before ordinary response middleware.
in
HasDebugging at line 81
HasDebugging
debug(bool $die = false)
Debug both the request and response.
Raw debugging output may contain credentials or other sensitive values.
in
HasMockClient at line 21
HasMockClient
withMockClient(MockClient $mockClient)
Use a mock client for this request.
in
HasMockClient at line 31
MockClient|null
mockClient()
Get the mock client.
in
HasMockClient at line 39
bool
hasMockClient()
Determine if the request has a mock client.
in
HasCookies at line 25
HasCookies
withCookie(SetCookie $cookie)
Specify a cookie and its attributes for the request.
in
HasCookies at line 46
HasCookies
withCookies(array $cookies, string $domain)
Specify cookies that should be included with the request.
in
HasCookies at line 60
array
cookies()
Get the request cookies and their attributes.
in
HasDelay at line 22
HasDelay
delay(int $milliseconds)
Delay the request by the given milliseconds.
in
HasDelay at line 36
int|null
delayMilliseconds()
Get the request delay in milliseconds.
in
HasDelay at line 44
protected int|null
defaultDelay()
Resolve the default request delay.
in
HasDelay at line 52
protected IntegerRepository
delayRepository()
Get the request delay repository.
in
HasHeaders at line 21
array
headers()
Get the request headers.
in
HasHeaders at line 29
bool
hasHeader(string $name)
Determine if the request contains the given header.
in
HasHeaders at line 46
HasHeaders
withHeaders(array $headers)
Add headers to the request.
in
HasHeaders at line 58
HasHeaders
withHeader(string $name, mixed $value)
Add a header to the request.
in
HasHeaders at line 69
HasHeaders
replaceHeaders(array $headers)
Replace matching headers on the request.
in
HasHeaders at line 97
HasHeaders
contentType(string $contentType)
Specify the request content type.
in
HasHeaders at line 107
HasHeaders
acceptJson()
Indicate that JSON should be returned by the server.
in
HasHeaders at line 117
HasHeaders
accept(string $contentType)
Indicate the type of content that should be returned by the server.
in
HasHeaders at line 127
HasHeaders
withUserAgent(bool|string $userAgent)
Specify the request user agent.
in
HasHeaders at line 137
protected array
defaultHeaders()
Resolve the default request headers.
in
HasHeaders at line 145
protected ArrayRepository
headerRepository()
Get the request header repository.
in
HasMiddleware at line 19
MiddlewarePipeline
middleware()
Get the request middleware pipeline.
in
HasOptions at line 23
array
options()
Get the request options.
in
HasOptions at line 34
HasOptions
withOptions(array $options)
Add options to the request.
in
HasOptions at line 46
HasOptions
maxRedirects(int $max)
Specify the maximum number of redirects to allow.
in
HasOptions at line 64
HasOptions
withoutRedirecting()
Indicate that redirects should not be followed.
in
HasOptions at line 74
HasOptions
withoutVerifying()
Indicate that TLS certificates should not be verified.
in
HasOptions at line 85
HasOptions
sink(resource|StreamInterface|string $to)
Specify where the response body should be stored.
in
HasOptions at line 95
HasOptions
timeout(float|int $seconds)
Specify the request timeout in seconds.
in
HasOptions at line 105
HasOptions
connectTimeout(float|int $seconds)
Specify the connection timeout in seconds.
in
HasOptions at line 116
HasOptions
withTelescopeTags(array $tags)
Add Telescope tags to the request.
in
HasOptions at line 126
HasOptions
withoutTelescope()
Disable Telescope recording for the request.
in
HasOptions at line 136
protected array
defaultOptions()
Resolve the default request options.
in
HasOptions at line 144
protected ArrayRepository
optionRepository()
Get the request option repository.
in
HasQuery at line 24
string|null
queryString()
Get the raw query string override, without a leading question mark.
in
HasQuery at line 32
HasQuery
withQueryString(string $query)
Replace the base URL and endpoint query string.
in
HasQuery at line 44
array
queryParameters()
Get the request query parameters.
in
HasQuery at line 55
HasQuery
withQueryParameters(array $parameters)
Add query parameters to the request.
in
HasQuery at line 67
protected array
defaultQuery()
Resolve the default request query parameters.
in
HasQuery at line 75
protected string|null
defaultQueryString()
Resolve the default raw query string override.
in
HasQuery at line 83
protected ArrayRepository
queryRepository()
Get the request query repository.
in
HasRetryPolicy at line 23
HasRetryPolicy
retry(array|int $times, Closure|int $sleepMilliseconds = 0, callable|null $when = null, bool $throw = true)
Specify the number of times the request should be attempted.
in
HasRetryPolicy at line 37
RetryPolicy
retryPolicy()
Get the request retry policy.
in
Macroable at line 28
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 41
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 68
static void
flushMacros()
Flush the existing macros.
Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 103
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
in
Makeable at line 12
static Makeable
make(mixed ...$arguments)
Create a new instance with the given arguments.
in
ManagesExceptions at line 15
bool|null
hasRequestFailed(Response $response)
Determine if the request failed.
in
ManagesExceptions at line 23
RequestException|null
getRequestException(Response $response)
Resolve the request exception.
in
ManagesExceptions at line 31
bool
shouldThrowRequestException(Response $response)
Determine if the response should throw a request exception.
in
Request at line 58
static static
newInstance()
Create a fresh request for container resolution.
in
Request at line 66
Method
method()
Get the HTTP method used by the request.
in
Request at line 78
abstract string
resolveEndpoint()
Resolve the request endpoint.
in
Request at line 83
string|null
url()
Get the absolute URL override.
in
Request at line 91
Request
withUrl(string $url)
Replace the connector base URL and request endpoint.
at line 42
bool|null
allowsBaseUrlOverride()
Resolve whether this request may use an absolute endpoint.
in
Request at line 111
bool
usesCachingControls()
| internal |
Determine if this request defines cache controls.
in
Request at line 119
bool
cachingEnabled()
Determine if caching is enabled for this request.
in
Request at line 129
bool
shouldInvalidateCache()
| internal |
Determine if the matching cache entry should be invalidated.
in
Request at line 139
string|null
resolveCacheKey(PendingRequest $pendingRequest)
| internal |
Resolve the request's custom cache key.
in
Request at line 150
array|null
resolveCacheableMethods()
| internal |
Resolve the request's cacheable HTTP methods.
in
Request at line 160
bool
usesRateLimits()
| internal |
Determine if this request defines rate limits.
in
Request at line 171
array
resolveRateLimitPolicies(PendingRequest $pendingRequest)
| internal |
Resolve the request's admission policies.
in
Request at line 181
UnitEnum|string|null
resolveRateLimitStoreName()
| internal |
Resolve the request's rate limiter store.
in
Request at line 191
bool
shouldWaitForRateLimits()
| internal |
Determine if request rate limits should be awaited.
in
Request at line 201
string
resolveRateLimitCooldownKeyFor(PendingRequest $pendingRequest)
| internal |
Resolve the request's stable cooldown key.
in
Request at line 211
int|null
resolveRateLimitCooldownFor(Response $response)
| internal |
Resolve the request cooldown imposed by a response.
in
Request at line 219
void
__clone()
Clone the request's initialized mutable state.
in
Request at line 232
static void
flushState()
Flush all static state.
at line 24
Connector
connector()
Get the connector used by the standalone request.
at line 34
Response
send(MockClient|null $mockClient = null)
Send the standalone request.
at line 50
protected Connector
resolveConnector()
Create the connector used by the standalone request.