22
33declare (strict_types=1 );
44
5- namespace ItkDev \F2ApiClient \ Client ;
5+ namespace ItkDev \F2ApiClient ;
66
77use ItkDev \F2ApiClient \Exception \ApiException ;
88use ItkDev \F2ApiClient \Exception \RuntimeException ;
@@ -51,6 +51,17 @@ class ApiClient
5151 use LoggerAwareTrait;
5252 use LoggerTrait;
5353
54+ private const string REL_CASE_BY_ID = 'http://cbrain.com/casefile/rel/case-by-id ' ;
55+ private const string REL_CASE_SEARCH = 'http://cbrain.com/casefile/rel/case-search ' ;
56+ private const string REL_CONTENT = 'http://cbrain.com/casefile/rel/content ' ;
57+ private const string REL_CREATE_CASE = 'http://cbrain.com/casefile/rel/create-case ' ;
58+ private const string REL_CREATE_DOCUMENT = 'http://cbrain.com/casefile/rel/create-document ' ;
59+ private const string REL_CREATE_MATTER = 'http://cbrain.com/casefile/rel/create-matter ' ;
60+ private const string REL_DOCUMENT_BY_ID = 'http://cbrain.com/casefile/rel/document-by-id ' ;
61+ private const string REL_MATTER_BY_ID = 'http://cbrain.com/casefile/rel/matter-by-id ' ;
62+ private const string REL_MATTER_BY_MATTER_NUMBER = 'http://cbrain.com/casefile/rel/matter-by-matter-number ' ;
63+ private const string REL_MATTER_SEARCH = 'http://cbrain.com/casefile/rel/matter-search ' ;
64+
5465 /** @var OptionsResolved */
5566 private readonly array $ options ;
5667
@@ -114,15 +125,15 @@ public function caseSearch(string $searchTerms, int $count = 10): array
114125 'count ' => $ count ,
115126 ];
116127
117- $ url = $ this ->getSearchRequestUrl (' http://cbrain.com/casefile/rel/case-search ' , $ query );
128+ $ url = $ this ->getSearchRequestUrl (self :: REL_CASE_SEARCH , $ query );
118129 $ response = $ this ->request (Request::METHOD_GET , $ url );
119130
120131 return $ this ->createSearchResult ($ response );
121132 }
122133
123134 public function caseById (int $ id ): CaseFile
124135 {
125- $ url = $ this ->getRequestUrl (' http://cbrain.com/casefile/rel/case-by-id ' , [
136+ $ url = $ this ->getRequestUrl (self :: REL_CASE_BY_ID , [
126137 'id ' => $ id ,
127138 ]);
128139 $ response = $ this ->request (Request::METHOD_GET , $ url );
@@ -136,7 +147,7 @@ public function caseById(int $id): CaseFile
136147
137148 public function caseCreate (array $ caseData ): CaseFile
138149 {
139- $ linkName = ' http://cbrain.com/casefile/rel/create-case ' ;
150+ $ linkName = self :: REL_CREATE_CASE ;
140151 $ url = $ this ->getRequestUrl ($ linkName );
141152
142153 // The documentation is unclear on this POE stuff. Does it return 303 or 201?
@@ -196,15 +207,15 @@ public function matterSearch(string $searchTerms, int $count = 10): array
196207 'count ' => $ count ,
197208 ];
198209
199- $ url = $ this ->getSearchRequestUrl (' http://cbrain.com/casefile/rel/matter-search ' , $ query );
210+ $ url = $ this ->getSearchRequestUrl (self :: REL_MATTER_SEARCH , $ query );
200211 $ response = $ this ->request (Request::METHOD_GET , $ url );
201212
202213 return $ this ->createSearchResult ($ response );
203214 }
204215
205216 public function matterById (int $ id ): Matter
206217 {
207- $ url = $ this ->getRequestUrl (' http://cbrain.com/casefile/rel/matter-by-id ' , [
218+ $ url = $ this ->getRequestUrl (self :: REL_MATTER_BY_ID , [
208219 'id ' => $ id ,
209220 ]);
210221 $ response = $ this ->request (Request::METHOD_GET , $ url );
@@ -218,7 +229,7 @@ public function matterById(int $id): Matter
218229
219230 public function matterByMatterNumber (string $ matterNumber ): Matter
220231 {
221- $ url = $ this ->getRequestUrl (' http://cbrain.com/casefile/rel/matter-by-matter-number ' , [
232+ $ url = $ this ->getRequestUrl (self :: REL_MATTER_BY_MATTER_NUMBER , [
222233 'matterNumber ' => $ matterNumber ,
223234 ]);
224235 $ response = $ this ->request (Request::METHOD_GET , $ url );
@@ -232,7 +243,7 @@ public function matterByMatterNumber(string $matterNumber): Matter
232243
233244 public function matterCreate (array $ matterData , ?CaseFile $ case = null ): Matter
234245 {
235- $ linkName = ' http://cbrain.com/casefile/rel/create-matter ' ;
246+ $ linkName = self :: REL_CREATE_MATTER ;
236247 $ url = null !== $ case ? $ case ->links ->getUrl ($ linkName ) : $ this ->getRequestUrl ($ linkName );
237248
238249 // The documentation is unclear on this POE stuff. Does it return 303 or 201?
@@ -287,7 +298,7 @@ public function matterUpdate(Matter $matter, Matter $updatedMatter): bool
287298
288299 public function documentById (int $ id ): Document
289300 {
290- $ url = $ this ->getRequestUrl (' http://cbrain.com/casefile/rel/document-by-id ' , [
301+ $ url = $ this ->getRequestUrl (self :: REL_DOCUMENT_BY_ID , [
291302 'id ' => $ id ,
292303 ]);
293304 $ response = $ this ->request (Request::METHOD_GET , $ url );
@@ -301,7 +312,7 @@ public function documentById(int $id): Document
301312
302313 public function documentCreate (array $ documentData , string $ filename , Matter $ matter ): Document
303314 {
304- $ linkName = ' http://cbrain.com/casefile/rel/create-document ' ;
315+ $ linkName = self :: REL_CREATE_DOCUMENT ;
305316 $ url = $ matter ->links ->getUrl ($ linkName );
306317
307318 // The documentation is unclear on this POE stuff. Does it return 303 or 201?
@@ -365,7 +376,7 @@ public function documentUpdate(Document $document, Document $updatedDocument, ?s
365376 throw $ this ->createRuntimeException ($ message );
366377 }
367378
368- $ url = $ document ->links ->getUrl (' http://cbrain.com/casefile/rel/content ' );
379+ $ url = $ document ->links ->getUrl (self :: REL_CONTENT );
369380
370381 try {
371382 $ response = $ this ->request (Request::METHOD_PUT , $ url , [
@@ -388,7 +399,7 @@ public function documentUpdate(Document $document, Document $updatedDocument, ?s
388399
389400 public function getDocumentContent (Document $ document ): ResponseInterface
390401 {
391- $ url = $ document ->links ->getUrl (' http://cbrain.com/casefile/rel/content ' );
402+ $ url = $ document ->links ->getUrl (self :: REL_CONTENT );
392403 $ response = $ this ->request (Request::METHOD_GET , $ url );
393404
394405 if (Response::HTTP_OK !== $ response ->getStatusCode ()) {
0 commit comments