Auth0-PHP

HttpRequest
in package

FinalYes

Table of Contents

Constants

MAX_REQUEST_RETRIES  : int = 10
MAX_REQUEST_RETRY_DELAY  : int = 1000
MAX_REQUEST_RETRY_JITTER  : int = 100
MIN_REQUEST_RETRY_DELAY  : int = 100

Properties

$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, mixed>
Files to send with a multipart request.
$formParams  : array<string, 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, null|int|string>
URL parameters for the request.
$path  : array<string|int, string>
Path to request.
$waits  : array<string|int, int>
The milliseconds slept between each request retry.

Methods

__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()  : StreamInterface, boundary: string}
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 int MAX_REQUEST_RETRIES = 10

MAX_REQUEST_RETRY_DELAY

public int MAX_REQUEST_RETRY_DELAY = 1000

MAX_REQUEST_RETRY_JITTER

public int MAX_REQUEST_RETRY_JITTER = 100

MIN_REQUEST_RETRY_DELAY

public int MIN_REQUEST_RETRY_DELAY = 100

Properties

$count

The number of requests this instance has made.

private int $count = 0

$domain read-only

private string|null $domain = null

$files

Files to send with a multipart request.

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

$formParams

Form parameters to send with the request.

private array<string, 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, null|int|string> $params = []

$path

Path to request.

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

$waits

The milliseconds slept between each request retry.

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

Methods

__construct()

HttpRequest constructor.

public __construct(SdkConfiguration $configuration, int $context, string $method[, string $basePath = '/' ][, array<string|int, int|string> $headers = [] ][, null|string $domain = null ][, null|array<string|int, object> &$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 : null|string = null

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

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

Optional. Only intended for unit testing purposes.

addFile()

Add a file to be sent with the request.

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

field name in the multipart request

$file_path : null|string

path to the file to send

Return values
self

addPath()

Add paths to the request URL.

public addPath([array<int, null|string> $params = [] ]) : self
Parameters
$params : array<int, null|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(null|FilteredRequest $fields) : self
Parameters
$fields : null|FilteredRequest

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, null|bool|int|string $value) : self
Parameters
$key : string

form parameter key

$value : null|bool|int|string

form parameter value

Return values
self

withFormParams()

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

public withFormParams([null|array<string|int, bool|int|string> $params = null ]) : self
Parameters
$params : null|array<string|int, bool|int|string> = 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(null|RequestOptions $options) : self
Parameters
$options : null|RequestOptions

request options to include

Return values
self

withPagination()

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

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

request paged results using a PaginatedRequest object

Return values
self

withParam()

Add a URL parameter to the request.

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

URL parameter key

$value : null|bool|int|string

URL parameter value

Return values
self

withParams()

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

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

URL parameters to add

Return values
self

buildMultiPart()

Build a multi-part request.

private buildMultiPart() : StreamInterface, boundary: string}
Return values
StreamInterface, boundary: string}

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
On this page

Search results