2
2
3
3
declare (strict_types=1 );
4
4
5
- namespace App \Libs \ Servers ;
5
+ namespace App \Backends \ Common ;
6
6
7
7
use App \Libs \Entity \StateInterface ;
8
8
use App \Libs \Mappers \ImportInterface as iImport ;
9
9
use App \Libs \QueueRequests ;
10
10
use DateTimeInterface as iDate ;
11
11
use JsonException ;
12
12
use Psr \Http \Message \ServerRequestInterface ;
13
- use Psr \Http \Message \UriInterface ;
14
13
use Psr \Log \LoggerInterface ;
15
14
use SplFileObject ;
16
15
use Symfony \Contracts \HttpClient \Exception \ExceptionInterface ;
17
16
use Symfony \Contracts \HttpClient \ResponseInterface ;
18
17
19
- interface ServerInterface
18
+ interface ClientInterface
20
19
{
21
20
/**
22
- * Initiate server . It should return **NEW OBJECT**
21
+ * Initiate Client with context . It **MUST** return new instance.
23
22
*
24
- * @param string $name Server name
25
- * @param UriInterface $url Server url
26
- * @param null|int|string $token Server Token
27
- * @param null|int|string $userId Server user Id
28
- * @param string|int|null $uuid
29
- * @param array $options array of options.
23
+ * @param Context $context
30
24
*
31
- * @return self
25
+ * @return ClientInterface
32
26
*/
33
- public function setUp (
34
- string $ name ,
35
- UriInterface $ url ,
36
- null | string | int $ token = null ,
37
- null | string | int $ userId = null ,
38
- null | string | int $ uuid = null ,
39
- array $ options = []
40
- ): self ;
27
+ public function withContext ( Context $ context ): ClientInterface ;
28
+
29
+ /**
30
+ * Return client context.
31
+ *
32
+ * @return Context
33
+ */
34
+ public function getContext ( ): Context ;
41
35
42
36
/**
43
37
* Get Backend name.
@@ -51,9 +45,9 @@ public function getName(): string;
51
45
*
52
46
* @param LoggerInterface $logger
53
47
*
54
- * @return ServerInterface
48
+ * @return ClientInterface
55
49
*/
56
- public function setLogger (LoggerInterface $ logger ): ServerInterface ;
50
+ public function setLogger (LoggerInterface $ logger ): ClientInterface ;
57
51
58
52
/**
59
53
* Process The request For attributes extraction.
@@ -66,15 +60,15 @@ public function setLogger(LoggerInterface $logger): ServerInterface;
66
60
public function processRequest (ServerRequestInterface $ request , array $ opts = []): ServerRequestInterface ;
67
61
68
62
/**
69
- * Parse server specific webhook event. for play/un-played event.
63
+ * Parse backend webhook event.
70
64
*
71
65
* @param ServerRequestInterface $request
72
66
* @return StateInterface
73
67
*/
74
68
public function parseWebhook (ServerRequestInterface $ request ): StateInterface ;
75
69
76
70
/**
77
- * Import watch state.
71
+ * Import metadata & play state.
78
72
*
79
73
* @param iImport $mapper
80
74
* @param iDate|null $after
@@ -84,16 +78,18 @@ public function parseWebhook(ServerRequestInterface $request): StateInterface;
84
78
public function pull (iImport $ mapper , iDate |null $ after = null ): array ;
85
79
86
80
/**
87
- * Backup watch state.
81
+ * Backup play state.
88
82
*
89
83
* @param iImport $mapper
84
+ * @param SplFileObject|null $writer
85
+ * @param array $opts
90
86
*
91
87
* @return array<array-key,ResponseInterface>
92
88
*/
93
- public function backup (iImport $ mapper , SplFileObject $ writer , array $ opts = []): array ;
89
+ public function backup (iImport $ mapper , SplFileObject | null $ writer = null , array $ opts = []): array ;
94
90
95
91
/**
96
- * Export watch state to server .
92
+ * Compare play state and export .
97
93
*
98
94
* @param iImport $mapper
99
95
* @param QueueRequests $queue
@@ -104,7 +100,7 @@ public function backup(iImport $mapper, SplFileObject $writer, array $opts = [])
104
100
public function export (iImport $ mapper , QueueRequests $ queue , iDate |null $ after = null ): array ;
105
101
106
102
/**
107
- * Push webhook queued states .
103
+ * Compare webhook queued events and push .
108
104
*
109
105
* @param array<StateInterface> $entities
110
106
* @param QueueRequests $queue
@@ -115,7 +111,7 @@ public function export(iImport $mapper, QueueRequests $queue, iDate|null $after
115
111
public function push (array $ entities , QueueRequests $ queue , iDate |null $ after = null ): array ;
116
112
117
113
/**
118
- * Search server libraries.
114
+ * Search backend libraries.
119
115
*
120
116
* @param string $query
121
117
* @param int $limit
@@ -126,7 +122,7 @@ public function push(array $entities, QueueRequests $queue, iDate|null $after =
126
122
public function search (string $ query , int $ limit = 25 , array $ opts = []): array ;
127
123
128
124
/**
129
- * Server Backend id.
125
+ * Search backend for item id.
130
126
*
131
127
* @param string|int $id
132
128
* @param array $opts
@@ -156,19 +152,16 @@ public function getMetadata(string|int $id, array $opts = []): array;
156
152
public function getLibrary (string |int $ id , array $ opts = []): array ;
157
153
158
154
/**
159
- * Get Server Unique ID .
155
+ * Get backend unique id .
160
156
*
161
- * @param bool $forceRefresh force read uuid from server .
157
+ * @param bool $forceRefresh force reload from backend .
162
158
*
163
159
* @return int|string|null
164
- *
165
- * @throws JsonException May throw if json decoding fails.
166
- * @throws ExceptionInterface May be thrown if there is HTTP request errors.
167
160
*/
168
- public function getServerUUID (bool $ forceRefresh = false ): int |string |null ;
161
+ public function getIdentifier (bool $ forceRefresh = false ): int |string |null ;
169
162
170
163
/**
171
- * Return List of users from server .
164
+ * Return list of backend users .
172
165
*
173
166
* @param array $opts
174
167
*
@@ -180,7 +173,7 @@ public function getServerUUID(bool $forceRefresh = false): int|string|null;
180
173
public function getUsersList (array $ opts = []): array ;
181
174
182
175
/**
183
- * Return list of server libraries.
176
+ * Return list of backend libraries.
184
177
*
185
178
* @param array $opts
186
179
*
0 commit comments