File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 66
77enum MimeType: string
88{
9+ case FILE_PDF = 'application/pdf ' ;
910 case IMAGE_PNG = 'image/png ' ;
1011 case IMAGE_JPEG = 'image/jpeg ' ;
1112 case IMAGE_HEIC = 'image/heic ' ;
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace GeminiAPI \Resources \Parts ;
6+
7+ use GeminiAPI \Enums \MimeType ;
8+ use JsonSerializable ;
9+
10+ use function json_encode ;
11+
12+ class FilePart implements PartInterface, JsonSerializable
13+ {
14+ public function __construct (
15+ public readonly MimeType $ mimeType ,
16+ public readonly string $ data ,
17+ ) {
18+ }
19+
20+ /**
21+ * @return array{
22+ * inlineData: array{
23+ * mimeType: string,
24+ * data: string,
25+ * },
26+ * }
27+ */
28+ public function jsonSerialize (): array
29+ {
30+ return [
31+ 'inlineData ' => [
32+ 'mimeType ' => $ this ->mimeType ->value ,
33+ 'data ' => $ this ->data ,
34+ ],
35+ ];
36+ }
37+
38+ public function __toString (): string
39+ {
40+ return json_encode ($ this ) ?: '' ;
41+ }
42+ }
You can’t perform that action at this time.
0 commit comments