Auth0-PHP

HttpRequest
in package

Class HttpRequest.

Table of Contents

MAX_REQUEST_RETRIES  = 10
MAX_REQUEST_RETRY_DELAY  = 1000
MAX_REQUEST_RETRY_JITTER  = 100
MIN_REQUEST_RETRY_DELAY  = 100
$basePath  : string
$body  : string
Request body.
$configuration  : SdkConfiguration
$context  : int
$count  : int
The number of requests this instance has made.
$domain  : string|null
$files  : array<string|int, mixed>
Files to send with a multipart request.
$formParams  : array<string|int, mixed>
Form parameters to send with the request.
$headers  : array<string|int, mixed>
$lastRequest  : RequestInterface|null
Stored instance of last send request.
$lastResponse  : ResponseInterface|null
Stored instance of last received response.
$method  : string
$mockedResponses  : array<string|int, mixed>|null
$params  : array<string|int, mixed>
URL parameters for the request.
$path  : array<string|int, mixed>
Path to request.
$waits  : array<string|int, mixed>
The milliseconds slept between each request retry.
__construct()  : mixed
HttpRequest constructor.
addFile()  : self
Add a file to be sent with the request.
addPath()  : self
Add paths to the request URL.
call()  : ResponseInterface
Build the URL and make the request. Returns a ResponseInterface.
getLastRequest()  : RequestInterface|null
Return a RequestInterface representation of the last sent request.
getLastResponse()  : ResponseInterface|null
Return a ResponseInterface representation of the last received response.
getParams()  : string
Build the query string from current request parameters.
getRequestCount()  : int
Return the number of requests made from this instance.
getRequestDelays()  : array<string|int, int>
The milliseconds slept between request retries.
getUrl()  : string
Get the path and URL parameters of this request.
withBody()  : self
Set the body of the request.
withFields()  : self
Add field response filtering parameters using $key => $value array.
withFormParam()  : self
Add a form value to be sent with the request.
withFormParams()  : self
Add one or more form values to be sent with the request.
withHeader()  : self
Add a header to the request.
withHeaders()  : self
Set multiple headers for the request.
withOptions()  : self
Add request parameters using RequestOptions object, representing common scenarios like pagination and field filtering.
withPagination()  : self
Add pagination parameters using $key => $value array.
withParam()  : self
Add a URL parameter to the request.
withParams()  : self
Add URL parameters using $key => $value array.
buildMultiPart()  : array<string|int, mixed>
Build a multi-part request.
prepareBoolParam()  : mixed|string
Translate a boolean value to a string for use in a URL or form parameter.
sleep()  : self
Issue a usleep() for $milliseconds, and log the delay.

Constants

MAX_REQUEST_RETRIES

public mixed MAX_REQUEST_RETRIES = 10

MAX_REQUEST_RETRY_DELAY

public mixed MAX_REQUEST_RETRY_DELAY = 1000

MAX_REQUEST_RETRY_JITTER

public mixed MAX_REQUEST_RETRY_JITTER = 100

MIN_REQUEST_RETRY_DELAY

public mixed MIN_REQUEST_RETRY_DELAY = 100

Properties

$count

The number of requests this instance has made.

private int $count = 0

$files

Files to send with a multipart request.

private array<string|int, mixed> $files = []

$formParams

Form parameters to send with the request.

private array<string|int, mixed> $formParams = []

$headers

private array<string|int, mixed> $headers = []

$lastRequest

Stored instance of last send request.

private RequestInterface|null $lastRequest = null

$lastResponse

Stored instance of last received response.

private ResponseInterface|null $lastResponse = null

$mockedResponses

private array<string|int, mixed>|null $mockedResponses = null

$params

URL parameters for the request.

private array<string|int, mixed> $params = []

$path

Path to request.

private array<string|int, mixed> $path = []

$waits

The milliseconds slept between each request retry.

private array<string|int, mixed> $waits = [0]

Methods

__construct()

HttpRequest constructor.

public __construct(SdkConfiguration $configuration, int $context, string $method[, string $basePath = '/' ][, array<string|int, int|string> $headers = [] ][, string|null $domain = null ][, array<string|int, object>|null &$mockedResponses = null ]) : mixed
Parameters
$configuration : SdkConfiguration

Required. Base configuration options for the SDK. See the SdkConfiguration class constructor for options.

$context : int

Required. The context the client is being created under, either HttpClient::CONTEXT_GENERIC_CLIENT, HttpClient::CONTEXT_AUTHENTICATION_CLIENT or HttpClient::CONTEXT_MANAGEMENT_CLIENT.

$method : string

Required. Type of HTTP request method to use, e.g. 'GET' or 'POST'.

$basePath : string = '/'

Optional. The base URI path from which additional pathing and parameters should be appended.

$headers : array<string|int, int|string> = []

Optional. Additional headers to send with the HTTP request.

$domain : string|null = null

Optional. The domain portion of the URI in which to send this request.

$mockedResponses : array<string|int, object>|null = null

Optional. Only intended for unit testing purposes.

Return values
mixed

addFile()

Add a file to be sent with the request.

public addFile(string $field, string|null $file_path) : self
Parameters
$field : string

field name in the multipart request

$file_path : string|null

path to the file to send

Return values
self

addPath()

Add paths to the request URL.

public addPath(string ...$params) : self
Parameters
$params : string

String paths to append to the request.

Return values
self

call()

Build the URL and make the request. Returns a ResponseInterface.

public call() : ResponseInterface
Tags
throws
NetworkException

when there is an HTTP client error during the request, such as the host being unreachable

Return values
ResponseInterface

getLastRequest()

Return a RequestInterface representation of the last sent request.

public getLastRequest() : RequestInterface|null
Return values
RequestInterface|null

getLastResponse()

Return a ResponseInterface representation of the last received response.

public getLastResponse() : ResponseInterface|null
Return values
ResponseInterface|null

getParams()

Build the query string from current request parameters.

public getParams() : string
Return values
string

getRequestCount()

Return the number of requests made from this instance.

public getRequestCount() : int
Return values
int

getRequestDelays()

The milliseconds slept between request retries.

public getRequestDelays() : array<string|int, int>
Return values
array<string|int, int>

getUrl()

Get the path and URL parameters of this request.

public getUrl() : string
Return values
string

withBody()

Set the body of the request.

public withBody(mixed $body[, bool $jsonEncode = true ]) : self
Parameters
$body : mixed

body content to send

$jsonEncode : bool = true

Optional. Defaults to true. Encode the $body as JSON prior to sending request.

Return values
self

withFields()

Add field response filtering parameters using $key => $value array.

public withFields(FilteredRequest|null $fields) : self
Parameters
$fields : FilteredRequest|null

request fields be included or excluded from the API response using a FilteredRequest object

Return values
self

withFormParam()

Add a form value to be sent with the request.

public withFormParam(string $key, bool|int|string|null $value) : self
Parameters
$key : string

form parameter key

$value : bool|int|string|null

form parameter value

Return values
self

withFormParams()

Add one or more form values to be sent with the request.

public withFormParams([array<string|int, bool|int|string>|null $params = null ]) : self
Parameters
$params : array<string|int, bool|int|string>|null = null

form parameters to use with the request

Return values
self

withHeader()

Add a header to the request.

public withHeader(string $name, string $value) : self
Parameters
$name : string

key name for header to add to request

$value : string

value for header to add to request

Return values
self

withHeaders()

Set multiple headers for the request.

public withHeaders(array<string, int|string> $headers) : self
Parameters
$headers : array<string, int|string>

array of headers to set

Return values
self

withOptions()

Add request parameters using RequestOptions object, representing common scenarios like pagination and field filtering.

public withOptions(RequestOptions|null $options) : self
Parameters
$options : RequestOptions|null

request options to include

Return values
self

withPagination()

Add pagination parameters using $key => $value array.

public withPagination(PaginatedRequest|null $paginated) : self
Parameters
$paginated : PaginatedRequest|null

request paged results using a PaginatedRequest object

Return values
self

withParam()

Add a URL parameter to the request.

public withParam(string $key, bool|int|string|null $value) : self
Parameters
$key : string

URL parameter key

$value : bool|int|string|null

URL parameter value

Return values
self

withParams()

Add URL parameters using $key => $value array.

public withParams(array<string|int, int|string|null>|null $parameters) : self
Parameters
$parameters : array<string|int, int|string|null>|null

URL parameters to add

Return values
self

buildMultiPart()

Build a multi-part request.

private buildMultiPart() : array<string|int, mixed>
Return values
array<string|int, mixed>

prepareBoolParam()

Translate a boolean value to a string for use in a URL or form parameter.

private prepareBoolParam(mixed $value) : mixed|string
Parameters
$value : mixed

parameter value to check

Return values
mixed|string

sleep()

Issue a usleep() for $milliseconds, and log the delay.

private sleep(int $milliseconds) : self
Parameters
$milliseconds : int

how long, in milliseconds, to trigger a usleep() for

Tags
codeCoverageIgnore
Return values
self

Search results