@@ -145,7 +145,7 @@ public function caseById(int $id): CaseFile
145145 return $ this ->createItemResult ($ response , CaseFile::class);
146146 }
147147
148- public function caseCreate (array $ caseData ): CaseFile
148+ public function caseCreate (CaseFile $ caseFile ): CaseFile
149149 {
150150 $ linkName = self ::REL_CREATE_CASE ;
151151 $ url = $ this ->getRequestUrl ($ linkName );
@@ -165,11 +165,10 @@ public function caseCreate(array $caseData): CaseFile
165165 }
166166
167167 $ response = $ this ->request (Request::METHOD_POST , $ location , [
168- 'json ' => $ caseData ,
168+ 'json ' => $ caseFile -> apiSerialize () ,
169169 ]);
170170
171171 if (Response::HTTP_CREATED !== $ response ->getStatusCode ()) {
172- // @TODO Log stuff.
173172 $ message = 'Cannot create case ' ;
174173 throw $ this ->createRuntimeException ($ message , response: $ response );
175174 }
@@ -181,8 +180,8 @@ public function caseFileUpdate(CaseFile $caseFile, CaseFile $updatedCaseFile): b
181180 {
182181 $ url = $ caseFile ->links ->getUrl ('self ' );
183182 $ diff = new JsonDiff (
184- $ caseFile ->jsonSerialize (),
185- $ updatedCaseFile ->jsonSerialize (),
183+ $ caseFile ->apiSerialize (),
184+ $ updatedCaseFile ->apiSerialize (),
186185 options: JsonDiff::SKIP_TEST_OPS ,
187186 );
188187 $ response = $ this ->request (Request::METHOD_PATCH , $ url , [
@@ -241,7 +240,7 @@ public function matterByMatterNumber(string $matterNumber): Matter
241240 return $ this ->createItemResult ($ response , Matter::class);
242241 }
243242
244- public function matterCreate (array $ matterData , ?CaseFile $ case = null ): Matter
243+ public function matterCreate (Matter $ matter , ?CaseFile $ case = null ): Matter
245244 {
246245 $ linkName = self ::REL_CREATE_MATTER ;
247246 $ url = null !== $ case ? $ case ->links ->getUrl ($ linkName ) : $ this ->getRequestUrl ($ linkName );
@@ -265,7 +264,7 @@ public function matterCreate(array $matterData, ?CaseFile $case = null): Matter
265264 }
266265
267266 $ response = $ this ->request (Request::METHOD_POST , $ location , [
268- 'json ' => $ matterData ,
267+ 'json ' => $ matter -> apiSerialize () ,
269268 ]);
270269
271270 if (Response::HTTP_CREATED !== $ response ->getStatusCode ()) {
@@ -310,7 +309,7 @@ public function documentById(int $id): Document
310309 return $ this ->createItemResult ($ response , Document::class);
311310 }
312311
313- public function documentCreate (array $ documentData , string $ filename , Matter $ matter ): Document
312+ public function documentCreate (Document $ document , string $ filename , Matter $ matter ): Document
314313 {
315314 $ linkName = self ::REL_CREATE_DOCUMENT ;
316315 $ url = $ matter ->links ->getUrl ($ linkName );
@@ -337,7 +336,7 @@ public function documentCreate(array $documentData, string $filename, Matter $ma
337336
338337 try {
339338 $ response = $ this ->request (Request::METHOD_POST , $ location , [
340- 'body ' => $ documentData
339+ 'body ' => $ document -> apiSerialize ()
341340 + [
342341 'File ' => $ fileHandle ,
343342 ],
@@ -442,6 +441,9 @@ protected function getAccessToken(): array
442441 });
443442 }
444443
444+ /**
445+ * @param array<array-key, mixed> $options
446+ */
445447 protected function request (string $ method , string $ path , array $ options = []): ResponseInterface
446448 {
447449 if (Request::METHOD_PATCH === $ method && array_key_exists ('json ' , $ options )) {
@@ -512,6 +514,9 @@ protected function configureOptions(OptionsResolver $resolver): void
512514 ->setAllowedTypes ('cache_item_lifetime ' , 'int ' );
513515 }
514516
517+ /**
518+ * @param array<string, string|int> $values
519+ */
515520 protected function getRequestUrl (string $ rel , array $ values = []): string
516521 {
517522 $ index = $ this ->getServiceIndex ();
@@ -524,6 +529,9 @@ protected function getRequestUrl(string $rel, array $values = []): string
524529 return $ this ->replacePlaceholders ($ url , $ values );
525530 }
526531
532+ /**
533+ * @param array<string, string|int> $values
534+ */
527535 protected function getSearchRequestUrl (string $ rel , array $ values ): string
528536 {
529537 $ url = $ this ->getRequestUrl ($ rel , []);
@@ -553,6 +561,9 @@ protected function getSearchRequestUrl(string $rel, array $values): string
553561 return $ this ->replacePlaceholders ($ url , $ values );
554562 }
555563
564+ /**
565+ * @param array<string, string|int> $values
566+ */
556567 protected function replacePlaceholders (string $ url , array $ values ): string
557568 {
558569 // Replace URL placeholders ('{…}')
@@ -611,6 +622,7 @@ protected function createItemResult(ResponseInterface $response, string $class):
611622 return $ class ::fromSimpleXMLElement ($ item );
612623 }
613624
625+ // @phpstan-ignore missingType.iterableValue
614626 public function log ($ level , \Stringable |string $ message , array $ context = []): void
615627 {
616628 if (null !== $ this ->logger ) {
@@ -682,8 +694,8 @@ public function getLinkCollection(AbstractF2Item $item, string $rel): Collection
682694
683695 private function computeDiff (AbstractF2Item $ old , AbstractF2Item $ new ): JsonDiff
684696 {
685- $ oldValues = $ old:: filterForJsonPatch ( $ old -> jsonSerialize () );
686- $ newValues = $ new:: filterForJsonPatch ( $ new -> jsonSerialize () );
697+ $ oldValues = $ old-> apiSerialize ( );
698+ $ newValues = $ new-> apiSerialize ( );
687699
688700 return new JsonDiff ($ oldValues , $ newValues , options: JsonDiff::SKIP_TEST_OPS );
689701 }
0 commit comments