55use Psr \Http \Message \StreamInterface ;
66use SupportPal \ApiClient \Exception \HttpResponseException ;
77use SupportPal \ApiClient \Exception \InvalidArgumentException ;
8- use SupportPal \ApiClient \Exception \MissingIdentifierException ;
98use SupportPal \ApiClient \Http \TicketClient ;
109use SupportPal \ApiClient \Model \Collection ;
1110use SupportPal \ApiClient \Model \Ticket \Attachment ;
@@ -23,7 +22,7 @@ public function getAttachments(array $queryParameters = []): Collection
2322 {
2423 $ response = $ this ->getApiClient ()->getAttachments ($ queryParameters );
2524 $ body = $ this ->decodeBody ($ response );
26- $ models = array_map ([$ this , 'createAttachment ' ], $ body ['data ' ]);
25+ $ models = array_map ([$ this , 'createAttachmentModel ' ], $ body ['data ' ]);
2726
2827 return $ this ->createCollection ($ body ['count ' ], $ models );
2928 }
@@ -35,26 +34,21 @@ public function getAttachment(int $attachmentId): Attachment
3534 {
3635 $ response = $ this ->getApiClient ()->getAttachment ($ attachmentId );
3736
38- return $ this ->createAttachment ($ this ->decodeBody ($ response )['data ' ]);
37+ return $ this ->createAttachmentModel ($ this ->decodeBody ($ response )['data ' ]);
3938 }
4039
4140 /**
4241 * @throws HttpResponseException
43- * @throws MissingIdentifierException
4442 */
45- public function downloadAttachment (Attachment $ attachment ): StreamInterface
43+ public function downloadAttachment (int $ id ): StreamInterface
4644 {
47- if (! isset ($ attachment ->id )) {
48- throw new MissingIdentifierException ('missing attachment identifier ' );
49- }
50-
51- return $ this ->getApiClient ()->downloadAttachment ($ attachment ->id )->getBody ();
45+ return $ this ->getApiClient ()->downloadAttachment ($ id )->getBody ();
5246 }
5347
5448 /**
5549 * @param array<mixed> $data
5650 */
57- private function createAttachment (array $ data ): Attachment
51+ private function createAttachmentModel (array $ data ): Attachment
5852 {
5953 return new Attachment ($ data );
6054 }
0 commit comments