1: <?php declare(strict_types=1);
2:
3: namespace Salient\Curler;
4:
5: use Psr\Http\Message\RequestInterface;
6: use Psr\Http\Message\ResponseInterface;
7: use Psr\Http\Message\UriInterface as PsrUriInterface;
8: use Salient\Contract\Cache\CacheInterface;
9: use Salient\Contract\Core\Arrayable;
10: use Salient\Contract\Core\DateFormatterInterface;
11: use Salient\Contract\Curler\CurlerInterface;
12: use Salient\Contract\Curler\CurlerMiddlewareInterface;
13: use Salient\Contract\Curler\CurlerPagerInterface;
14: use Salient\Contract\Http\AccessTokenInterface;
15: use Salient\Contract\Http\FormDataFlag;
16: use Salient\Contract\Http\HttpHeadersInterface;
17: use Salient\Contract\Http\HttpRequestHandlerInterface;
18: use Salient\Contract\Http\HttpResponseInterface;
19: use Salient\Core\AbstractBuilder;
20: use Closure;
21: use Stringable;
22:
23: /**
24: * A fluent Curler factory
25: *
26: * @method $this uri(PsrUriInterface|Stringable|string|null $value) Endpoint URI (cannot have query or fragment components)
27: * @method $this headers(Arrayable<string,string[]|string>|iterable<string,string[]|string>|null $value) Request headers
28: * @method $this accessToken(AccessTokenInterface|null $value) Access token applied to request headers
29: * @method $this accessTokenHeaderName(string $value) Name of access token header (default: `"Authorization"`)
30: * @method $this sensitiveHeaders(string[] $value) Headers treated as sensitive (default: {@see HttpHeaderGroup::SENSITIVE})
31: * @method $this mediaType(string|null $value) Media type applied to request headers
32: * @method $this userAgent(string|null $value) User agent applied to request headers
33: * @method $this expectJson(bool $value = true) Explicitly accept JSON-encoded responses and assume responses with no content type contain JSON (default: true)
34: * @method $this postJson(bool $value = true) Use JSON to encode POST/PUT/PATCH/DELETE data (default: true)
35: * @method $this dateFormatter(DateFormatterInterface|null $value) Date formatter used to format and parse the endpoint's date and time values
36: * @method $this formDataFlags(int-mask-of<FormDataFlag::*> $value) Flags used to encode data for query strings and message bodies (default: {@see FormDataFlag::PRESERVE_NUMERIC_KEYS} `|` {@see FormDataFlag::PRESERVE_STRING_KEYS})
37: * @method $this jsonDecodeFlags(int-mask-of<\JSON_BIGINT_AS_STRING|\JSON_INVALID_UTF8_IGNORE|\JSON_INVALID_UTF8_SUBSTITUTE|\JSON_OBJECT_AS_ARRAY|\JSON_THROW_ON_ERROR> $value) Flags used to decode JSON returned by the endpoint (default: {@see \JSON_OBJECT_AS_ARRAY})
38: * @method $this middleware(array<array{CurlerMiddlewareInterface|HttpRequestHandlerInterface|Closure(RequestInterface $request, Closure(RequestInterface): HttpResponseInterface $next, CurlerInterface $curler): ResponseInterface,1?:string|null}> $value) Middleware applied to the request handler stack
39: * @method $this pager(CurlerPagerInterface|null $value) Pagination handler
40: * @method $this alwaysPaginate(bool $value = true) Use the pager to process requests even if no pagination is required (default: false)
41: * @method $this cacheStore(CacheInterface|null $value) Cache store used for cookie and response caching instead of the {@see Cache} facade's underlying store
42: * @method $this handleCookies(bool $value = true) Enable cookie handling (default: false)
43: * @method $this cookiesCacheKey(string|null $value) Key to cache cookies under (cookie handling is implicitly enabled if given)
44: * @method $this cacheResponses(bool $value = true) Cache responses to GET and HEAD requests (HTTP caching headers are ignored; USE RESPONSIBLY) (default: false)
45: * @method $this cachePostResponses(bool $value = true) Cache responses to repeatable POST requests (ignored if GET and HEAD request caching is disabled) (default: false)
46: * @method $this cacheKeyCallback((callable(RequestInterface $request, CurlerInterface $curler): (string[]|string))|null $value) Override values hashed and combined with request method and URI to create response cache keys (headers not in {@see HttpHeaderGroup::UNSTABLE} are used by default)
47: * @method $this cacheLifetime(int<-1,max> $value) Seconds before cached responses expire when caching is enabled (`0` = cache indefinitely; `-1` = do not cache; default: `3600`)
48: * @method $this refreshCache(bool $value = true) Replace cached responses even if they haven't expired (default: false)
49: * @method $this timeout(int<0,max>|null $value) Connection timeout in seconds (`null` = use underlying default of `300` seconds; default: `null`)
50: * @method $this followRedirects(bool $value = true) Follow "Location" headers (default: false)
51: * @method $this maxRedirects(int<-1,max>|null $value) Limit the number of "Location" headers followed (`-1` = unlimited; `0` = do not follow redirects; `null` = use underlying default of `30`; default: `null`)
52: * @method $this retryAfterTooManyRequests(bool $value = true) Retry throttled requests when the endpoint returns a "Retry-After" header (default: false)
53: * @method $this retryAfterMaxSeconds(int<0,max> $value) Limit the delay between request attempts (`0` = unlimited; default: `300`)
54: * @method $this throwHttpErrors(bool $value = true) Throw exceptions for HTTP errors (default: true)
55: * @method HttpHeadersInterface head(mixed[]|null $query = null) Send a HEAD request to the endpoint
56: * @method mixed get(mixed[]|null $query = null) Send a GET request to the endpoint and return the body of the response
57: * @method mixed post(mixed[]|object|null $data = null, mixed[]|null $query = null) Send a POST request to the endpoint and return the body of the response
58: * @method mixed put(mixed[]|object|null $data = null, mixed[]|null $query = null) Send a PUT request to the endpoint and return the body of the response
59: * @method mixed patch(mixed[]|object|null $data = null, mixed[]|null $query = null) Send a PATCH request to the endpoint and return the body of the response
60: * @method mixed delete(mixed[]|object|null $data = null, mixed[]|null $query = null) Send a DELETE request to the endpoint and return the body of the response
61: * @method iterable<mixed> getP(mixed[]|null $query = null) Send a GET request to the endpoint and iterate over response pages
62: * @method iterable<mixed> postP(mixed[]|object|null $data = null, mixed[]|null $query = null) Send a POST request to the endpoint and iterate over response pages
63: * @method iterable<mixed> putP(mixed[]|object|null $data = null, mixed[]|null $query = null) Send a PUT request to the endpoint and iterate over response pages
64: * @method iterable<mixed> patchP(mixed[]|object|null $data = null, mixed[]|null $query = null) Send a PATCH request to the endpoint and iterate over response pages
65: * @method iterable<mixed> deleteP(mixed[]|object|null $data = null, mixed[]|null $query = null) Send a DELETE request to the endpoint and iterate over response pages
66: * @method mixed postR(string $data, string $mediaType, mixed[]|null $query = null) Send raw data to the endpoint in a POST request and return the body of the response
67: * @method mixed putR(string $data, string $mediaType, mixed[]|null $query = null) Send raw data to the endpoint in a PUT request and return the body of the response
68: * @method mixed patchR(string $data, string $mediaType, mixed[]|null $query = null) Send raw data to the endpoint in a PATCH request and return the body of the response
69: * @method mixed deleteR(string $data, string $mediaType, mixed[]|null $query = null) Send raw data to the endpoint in a DELETE request and return the body of the response
70: *
71: * @api
72: *
73: * @extends AbstractBuilder<Curler>
74: *
75: * @generated
76: */
77: final class CurlerBuilder extends AbstractBuilder
78: {
79: /**
80: * @internal
81: */
82: protected static function getService(): string
83: {
84: return Curler::class;
85: }
86:
87: /**
88: * @internal
89: */
90: protected static function getTerminators(): array
91: {
92: return [
93: 'head',
94: 'get',
95: 'post',
96: 'put',
97: 'patch',
98: 'delete',
99: 'getP',
100: 'postP',
101: 'putP',
102: 'patchP',
103: 'deleteP',
104: 'postR',
105: 'putR',
106: 'patchR',
107: 'deleteR',
108: ];
109: }
110: }
111: