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