@@ -89,24 +89,30 @@ public function createRepository(string $owner, string $repositoryName, bool $pr
8989 }
9090
9191 /**
92- * List repositories for GitHub App
92+ * Search repositories for GitHub App
93+ * @param string $owner Name of user or org
9394 * @param int $page page number
9495 * @param int $per_page number of results per page
96+ * @param string $search Query to be searched to filter repo names
9597 * @return array<mixed>
9698 *
9799 * @throws Exception
98100 */
99- public function listRepositories ( $ page , $ per_page ): array
101+ public function searchRepositories ( string $ owner , int $ page , int $ per_page, string $ search = '' ): array
100102 {
101- $ url = '/installation /repositories?page= ' . $ page . ' &per_page= ' . $ per_page ;
103+ $ url = '/search /repositories ' ;
102104
103- $ response = $ this ->call (self ::METHOD_GET , $ url , ['Authorization ' => "Bearer $ this ->accessToken " ]);
105+ $ response = $ this ->call (self ::METHOD_GET , $ url , ['Authorization ' => "Bearer $ this ->accessToken " ], [
106+ 'q ' => "$ {search} user: $ {owner} fork:true " ,
107+ 'per_page ' => $ per_page ,
108+ 'sort ' => 'updated '
109+ ]);
104110
105- if (!isset ($ response ['body ' ]['repositories ' ])) {
111+ if (!isset ($ response ['body ' ]['items ' ])) {
106112 throw new Exception ("Repositories list missing in the response. " );
107113 }
108114
109- return $ response ['body ' ]['repositories ' ];
115+ return $ response ['body ' ]['items ' ];
110116 }
111117
112118 /**
0 commit comments