class YfyRequestBuilder

Class YfyRequestBuilder

Properties

protected string $method
protected string $endpoint
protected array $headers
protected array $basicAuth
protected array $pathParams
protected array $queryParams
protected array $formParams
protected array $json
protected array $files
protected int $connectTimeout
protected int $timeout
protected bool $stream
protected YfyContext $yfyContext

Methods

__construct(YfyContext $yfyContext = null)

YfyRequestBuilder constructor.

$this
withMethod(string $method)

设置请求方法

$this
withEndpoint(string $endpoint)

设置请求路径模板

$this
withHeaders(array $headers)

设置请求header数组

$this
addHeader(string $key, string $value)

增加一个header

$this
withBasicAuth(string $username, string $password)

设置basic auth参数

$this
withPathParams(array $pathParams)

设置路径参数

$this
addPathParam(string $param)

增加一个路径参数

$this
withQueryParams(array $queryParams)

设置query参数数组

$this
addQueryParam(string $key, string $value)

增加一个query参数

$this
withFormParams(array $formParams)

设置表单参数

$this
addFormParam(string $key, string $value)

增加一个表单参数

$this
withJson(array $json)

设置json参数

$this
withFiles(array $files)

设置通过multipart方式上传的文件

$this
addFile(YfyFile $yfyFile)

增加一个通过multipart方式上传的文件

$this
withConnectTimeout(int $connectTimeout)

设置连接超时时间

$this
withTimeout(int $timeout)

设置请求超时时间

$this
returnStream(bool $stream)

设置是否以流形式返回

$this
withYfyContext(YfyContext $yfyContext)

设置请求上下文

build()

构造request

factory()

创建一个工厂实例

Details

at line 75
__construct(YfyContext $yfyContext = null)

YfyRequestBuilder constructor.

Parameters

YfyContext $yfyContext 请求上下文

at line 87
$this withMethod(string $method)

设置请求方法

Parameters

string $method 请求方法

Return Value

$this

at line 98
$this withEndpoint(string $endpoint)

设置请求路径模板

Parameters

string $endpoint 请求路径模板

Return Value

$this

at line 109
$this withHeaders(array $headers)

设置请求header数组

Parameters

array $headers 请求header数组

Return Value

$this

at line 121
$this addHeader(string $key, string $value)

增加一个header

Parameters

string $key header的key
string $value header的value

Return Value

$this

at line 133
$this withBasicAuth(string $username, string $password)

设置basic auth参数

Parameters

string $username basic auth中的用户名
string $password basic auth中的密码

Return Value

$this

at line 144
$this withPathParams(array $pathParams)

设置路径参数

Parameters

array $pathParams 路径参数

Return Value

$this

at line 155
$this addPathParam(string $param)

增加一个路径参数

Parameters

string $param 路径参数

Return Value

$this

at line 166
$this withQueryParams(array $queryParams)

设置query参数数组

Parameters

array $queryParams query参数数组

Return Value

$this

at line 178
$this addQueryParam(string $key, string $value)

增加一个query参数

Parameters

string $key query参数的key
string $value query参数的value

Return Value

$this

at line 189
$this withFormParams(array $formParams)

设置表单参数

Parameters

array $formParams 表单参数

Return Value

$this

at line 201
$this addFormParam(string $key, string $value)

增加一个表单参数

Parameters

string $key 表单参数的key
string $value 表单参数的value

Return Value

$this

at line 212
$this withJson(array $json)

设置json参数

Parameters

array $json json参数

Return Value

$this

at line 223
$this withFiles(array $files)

设置通过multipart方式上传的文件

Parameters

array $files

Return Value

$this

at line 234
$this addFile(YfyFile $yfyFile)

增加一个通过multipart方式上传的文件

Parameters

YfyFile $yfyFile 上传文件的封装

Return Value

$this

at line 245
$this withConnectTimeout(int $connectTimeout)

设置连接超时时间

Parameters

int $connectTimeout 连接超时时间

Return Value

$this

at line 256
$this withTimeout(int $timeout)

设置请求超时时间

Parameters

int $timeout 请求超时时间

Return Value

$this

at line 267
$this returnStream(bool $stream)

设置是否以流形式返回

Parameters

bool $stream 是否以流形式返回

Return Value

$this

at line 279
$this withYfyContext(YfyContext $yfyContext)

设置请求上下文

Parameters

YfyContext $yfyContext 请求上下文

Return Value

$this

at line 312
YfyRequest build()

构造request

Return Value

YfyRequest

at line 339
static YfyRequestBuilder factory()

创建一个工厂实例

Return Value

YfyRequestBuilder