1: <?php declare(strict_types=1);
2:
3: namespace Salient\Sync\Http;
4:
5: use Salient\Contract\Core\Pipeline\PipelineInterface;
6: use Salient\Contract\Core\ArrayMapperFlag;
7: use Salient\Contract\Core\ListConformity;
8: use Salient\Contract\Curler\CurlerInterface;
9: use Salient\Contract\Curler\CurlerPagerInterface;
10: use Salient\Contract\Http\HttpHeadersInterface;
11: use Salient\Contract\Http\HttpRequestMethod;
12: use Salient\Contract\Sync\FilterPolicy;
13: use Salient\Contract\Sync\SyncContextInterface;
14: use Salient\Contract\Sync\SyncEntityInterface;
15: use Salient\Contract\Sync\SyncEntitySource;
16: use Salient\Contract\Sync\SyncOperation as OP;
17: use Salient\Core\AbstractBuilder;
18: use Salient\Sync\Support\SyncPipelineArgument;
19: use Salient\Sync\AbstractSyncDefinition;
20: use Closure;
21:
22: /**
23: * A fluent HttpSyncDefinition factory
24: *
25: * @method $this operations(array<OP::*> $value) Supported sync operations
26: * @method $this path(string[]|string|null $value) Path or paths to the endpoint servicing the entity, e.g. "/v1/user" (see {@see HttpSyncDefinition::$Path})
27: * @method $this query(mixed[]|null $value) Query parameters applied to the sync operation URL (see {@see HttpSyncDefinition::$Query})
28: * @method $this headers(?HttpHeadersInterface $value) HTTP headers applied to the sync operation request (see {@see HttpSyncDefinition::$Headers})
29: * @method $this pager(?CurlerPagerInterface $value) Pagination handler for the endpoint servicing the entity (see {@see HttpSyncDefinition::$Pager})
30: * @method $this alwaysPaginate(bool $value = true) Use the pager to process requests even if no pagination is required (default: false)
31: * @method $this callback((callable(HttpSyncDefinition<TEntity,TProvider>, OP::*, SyncContextInterface, mixed...): HttpSyncDefinition<TEntity,TProvider>)|null $value) Callback applied to the definition before each sync operation (see {@see HttpSyncDefinition::$Callback})
32: * @method $this conformity(ListConformity::* $value) Conformity level of data returned by the provider for this entity (see {@see AbstractSyncDefinition::$Conformity})
33: * @method $this filterPolicy(FilterPolicy::*|null $value) Action to take when filters are not claimed by the provider (see {@see AbstractSyncDefinition::$FilterPolicy})
34: * @method $this expiry(int<-1,max>|null $value) Seconds before cached responses expire (see {@see HttpSyncDefinition::$Expiry})
35: * @method $this methodMap(array<OP::*,HttpRequestMethod::*> $value) Array that maps sync operations to HTTP request methods (see {@see HttpSyncDefinition::$MethodMap})
36: * @method $this curlerCallback((callable(CurlerInterface, HttpSyncDefinition<TEntity,TProvider>, OP::*, SyncContextInterface, mixed...): CurlerInterface)|null $value) Callback applied to the Curler instance created to perform each sync operation (see {@see HttpSyncDefinition::$CurlerCallback})
37: * @method $this syncOneEntityPerRequest(bool $value = true) Perform CREATE_LIST, UPDATE_LIST and DELETE_LIST operations on one entity per HTTP request (default: false)
38: * @method $this overrides(array<int-mask-of<OP::*>,Closure(HttpSyncDefinition<TEntity,TProvider>, OP::*, SyncContextInterface, mixed...): (iterable<TEntity>|TEntity)> $value) Array that maps sync operations to closures that override other implementations (see {@see AbstractSyncDefinition::$Overrides})
39: * @method $this keyMap(array<array-key,array-key|array-key[]>|null $value) Array that maps keys to properties for entity data returned by the provider (see {@see AbstractSyncDefinition::$KeyMap})
40: * @method $this keyMapFlags(int-mask-of<ArrayMapperFlag::*> $value) Array mapper flags used if a key map is provided
41: * @method $this readFromList(bool $value = true) Perform READ operations by iterating over entities returned by READ_LIST (default: false; see {@see AbstractSyncDefinition::$ReadFromList})
42: * @method $this returnEntitiesFrom(SyncEntitySource::*|null $value) Source of entity data for the return value of a successful CREATE, UPDATE or DELETE operation
43: * @method $this args(mixed[]|null $value) Arguments passed to each sync operation
44: *
45: * @template TEntity of SyncEntityInterface
46: * @template TProvider of HttpSyncProvider
47: *
48: * @extends AbstractBuilder<HttpSyncDefinition<TEntity,TProvider>>
49: *
50: * @generated
51: */
52: final class HttpSyncDefinitionBuilder extends AbstractBuilder
53: {
54: /**
55: * @internal
56: */
57: protected static function getService(): string
58: {
59: return HttpSyncDefinition::class;
60: }
61:
62: /**
63: * The entity being serviced
64: *
65: * @template T of SyncEntityInterface
66: *
67: * @param class-string<T> $value
68: * @return static<T,TProvider>
69: */
70: public function entity(string $value)
71: {
72: /** @var static<T,TProvider> */
73: return $this->withValueB(__FUNCTION__, $value);
74: }
75:
76: /**
77: * The provider servicing the entity
78: *
79: * @template T of HttpSyncProvider
80: *
81: * @param T $value
82: * @return static<TEntity,T>
83: */
84: public function provider(HttpSyncProvider $value)
85: {
86: /** @var static<TEntity,T> */
87: return $this->withValueB(__FUNCTION__, $value);
88: }
89:
90: /**
91: * Pipeline that maps provider data to a serialized entity, or `null` if mapping is not required
92: *
93: * @template T of SyncEntityInterface
94: *
95: * @param PipelineInterface<mixed[],T,SyncPipelineArgument>|null $value
96: * @return static<T,TProvider>
97: */
98: public function pipelineFromBackend(?PipelineInterface $value)
99: {
100: /** @var static<T,TProvider> */
101: return $this->withValueB(__FUNCTION__, $value);
102: }
103:
104: /**
105: * Pipeline that maps a serialized entity to provider data, or `null` if mapping is not required
106: *
107: * @template T of SyncEntityInterface
108: *
109: * @param PipelineInterface<T,mixed[],SyncPipelineArgument>|null $value
110: * @return static<T,TProvider>
111: */
112: public function pipelineToBackend(?PipelineInterface $value)
113: {
114: /** @var static<T,TProvider> */
115: return $this->withValueB(__FUNCTION__, $value);
116: }
117: }
118: