77use Aternos \ModrinthApi \Api \ProjectsApi ;
88use Aternos \ModrinthApi \Api \TagsApi ;
99use Aternos \ModrinthApi \Api \TeamsApi ;
10+ use Aternos \ModrinthApi \Api \ThreadsApi ;
1011use Aternos \ModrinthApi \Api \UsersApi ;
1112use Aternos \ModrinthApi \Api \VersionFilesApi ;
1213use Aternos \ModrinthApi \Api \VersionsApi ;
1920use Aternos \ModrinthApi \Client \Tags \License ;
2021use Aternos \ModrinthApi \Client \Tags \Loader ;
2122use Aternos \ModrinthApi \Client \Tags \ProjectType ;
23+ use Aternos \ModrinthApi \Client \Threads \Report ;
24+ use Aternos \ModrinthApi \Client \Threads \ReportItemType ;
25+ use Aternos \ModrinthApi \Client \Threads \Thread ;
26+ use Aternos \ModrinthApi \Client \Threads \ThreadMessageType ;
2227use Aternos \ModrinthApi \Configuration ;
2328use Aternos \ModrinthApi \Model \CategoryTag ;
29+ use Aternos \ModrinthApi \Model \CreatableReport ;
2430use Aternos \ModrinthApi \Model \DonationPlatformTag ;
2531use Aternos \ModrinthApi \Model \ForgeUpdates ;
2632use Aternos \ModrinthApi \Model \GameVersionTag ;
3036use Aternos \ModrinthApi \Model \InvalidInputError ;
3137use Aternos \ModrinthApi \Model \LicenseTag ;
3238use Aternos \ModrinthApi \Model \LoaderTag ;
39+ use Aternos \ModrinthApi \Model \ModifyReportRequest ;
3340use Aternos \ModrinthApi \Model \Notification as NotificationModel ;
3441use Aternos \ModrinthApi \Model \Project as ProjectModel ;
42+ use Aternos \ModrinthApi \Model \Report as ReportModel ;
3543use Aternos \ModrinthApi \Model \Statistics ;
3644use Aternos \ModrinthApi \Model \TeamMember as TeamMemberModel ;
45+ use Aternos \ModrinthApi \Model \ThreadMessageBody ;
3746use Aternos \ModrinthApi \Model \User as UserModel ;
3847use Aternos \ModrinthApi \Model \UserPayoutHistory ;
3948use Aternos \ModrinthApi \Model \Version as VersionModel ;
49+ use Aternos \ModrinthApi \Model \Thread as ThreadModel ;
50+
4051
4152/**
4253 * Class ModrinthAPIClient
@@ -66,6 +77,8 @@ class ModrinthAPIClient
6677
6778 protected NotificationsApi $ notifications ;
6879
80+ protected ThreadsApi $ threads ;
81+
6982 /**
7083 * ModrinthAPIClient constructor.
7184 * @param string|null $apiToken API token used for authentication
@@ -95,6 +108,7 @@ public function setConfiguration(Configuration $configuration): static
95108 $ this ->tags = new TagsApi (null , $ this ->configuration );
96109 $ this ->misc = new MiscApi (null , $ this ->configuration );
97110 $ this ->notifications = new NotificationsApi (null , $ this ->configuration );
111+ $ this ->threads = new ThreadsApi (null , $ this ->configuration );
98112
99113 return $ this ;
100114 }
@@ -673,4 +687,144 @@ public function readNotifications(array $ids): void
673687 {
674688 $ this ->notifications ->readNotifications (json_encode ($ ids ));
675689 }
690+
691+ /**
692+ * Report a project, user, or version (requires authentication)
693+ * @param string $reportType The type of the report being sent
694+ * @param string $itemId The ID of the item (project, version, or user) being reported
695+ * @param ReportItemType $itemType The type of the item being reported
696+ * @param string $body
697+ * @return Report
698+ * @throws ApiException
699+ */
700+ public function submitReport (string $ reportType , string $ itemId , ReportItemType $ itemType , string $ body ): Report
701+ {
702+ $ report = new CreatableReport ();
703+ $ report ->setReportType ($ reportType );
704+ $ report ->setItemId ($ itemId );
705+ $ report ->setItemType ($ itemType ->value );
706+ $ report ->setBody ($ body );
707+
708+ return new Report ($ this , $ this ->threads ->submitReport ($ report ));
709+ }
710+
711+ /**
712+ * Get your open reports (requires authentication)
713+ * @return Report[]
714+ * @throws ApiException
715+ */
716+ public function getOpenReports (): array
717+ {
718+ return array_map (function (ReportModel $ report ): Report {
719+ return new Report ($ this , $ report );
720+ }, $ this ->threads ->getOpenReports ());
721+ }
722+
723+ /**
724+ * Get a report by ID (requires authentication)
725+ * @param string $id report ID
726+ * @return Report
727+ * @throws ApiException
728+ */
729+ public function getReport (string $ id ): Report
730+ {
731+ return new Report ($ this , $ this ->threads ->getReport ($ id ));
732+ }
733+
734+ /**
735+ * @param string $id
736+ * @param string|null $body
737+ * @param boolean|null $closed
738+ * @return void
739+ * @throws ApiException
740+ */
741+ public function modifyReport (string $ id , ?string $ body , ?bool $ closed ): void
742+ {
743+ $ report = new ModifyReportRequest ();
744+ $ report ->setBody ($ body );
745+ $ report ->setClosed ($ closed );
746+
747+ $ this ->threads ->modifyReport ($ id , $ report );
748+ }
749+
750+ /**
751+ * Get multiple reports by ID (requires authentication)
752+ * @param string[] $ids
753+ * @return Report[]
754+ * @throws ApiException
755+ */
756+ public function getReports (array $ ids ): array
757+ {
758+ return array_map (function (ReportModel $ report ): Report {
759+ return new Report ($ this , $ report );
760+ }, $ this ->threads ->getReports (json_encode ($ ids )));
761+ }
762+
763+ /**
764+ * Get a thread (requires authentication)
765+ * @param string $id
766+ * @return Thread
767+ * @throws ApiException
768+ */
769+ public function getThread (string $ id ): Thread
770+ {
771+ return new Thread ($ this , $ this ->threads ->getThread ($ id ));
772+ }
773+
774+ /**
775+ * Get multiple threads by ID (requires authentication)
776+ * @param string[] $ids
777+ * @return Thread[]
778+ * @throws ApiException
779+ */
780+ public function getThreads (array $ ids ): array
781+ {
782+ return array_map (function (ThreadModel $ thread ): Thread {
783+ return new Thread ($ this , $ thread );
784+ }, $ this ->threads ->getThreads (json_encode ($ ids )));
785+ }
786+
787+ /**
788+ * Send a message to a thread (requires authentication)
789+ * @param string $threadId
790+ * @param ThreadMessageType $messageType
791+ * @param string|null $body
792+ * @param bool|null $private
793+ * @param string|null $replyingTo
794+ * @param string|null $oldStatus
795+ * @param string|null $newStatus
796+ * @return Thread
797+ * @throws ApiException
798+ */
799+ public function sendThreadMessage (
800+ string $ threadId ,
801+ ThreadMessageType $ messageType ,
802+ ?string $ body = null ,
803+ ?bool $ private = null ,
804+ ?string $ replyingTo = null ,
805+ ?string $ oldStatus = null ,
806+ ?string $ newStatus = null ,
807+ ): Thread
808+ {
809+ $ message = new ThreadMessageBody ();
810+ $ message ->setType ($ messageType ->value );
811+ $ message ->setBody ($ body );
812+ $ message ->setPrivate ($ private );
813+ $ message ->setReplyingTo ($ replyingTo );
814+ $ message ->setOldStatus ($ oldStatus );
815+ $ message ->setNewStatus ($ newStatus );
816+ return new Thread ($ this , $ this ->threads ->sendThreadMessage ($ threadId , $ message ));
817+ }
818+
819+ /**
820+ * Delete a thread message (requires authentication)
821+ * @param string $threadId
822+ * @param string $messageId
823+ * @return void
824+ * @throws ApiException
825+ */
826+ public function deleteThreadMessage (string $ threadId , string $ messageId ): void
827+ {
828+ $ this ->threads ->deleteThreadMessage ($ threadId , $ messageId );
829+ }
676830}
0 commit comments