@@ -119,7 +119,9 @@ public function getUser(): array
119119 */
120120 public function listRepositoriesForGitHubApp (): array
121121 {
122- $ response = $ this ->call (self ::METHOD_GET , '/installation/repositories ' , ["Authorization " => "Bearer $ this ->accessToken " ]);
122+ $ url = '/installation/repositories ' ;
123+
124+ $ response = $ this ->call (self ::METHOD_GET , $ url , ["Authorization " => "Bearer $ this ->accessToken " ]);
123125
124126 return $ response ['body ' ]['repositories ' ];
125127 }
@@ -132,7 +134,10 @@ public function listRepositoriesForGitHubApp(): array
132134 */
133135 public function addComment ($ repoName , $ pullRequestNumber )
134136 {
135- $ this ->call (self ::METHOD_POST , '/repos/ ' . $ this ->user . '/ ' . $ repoName . '/issues/ ' . $ pullRequestNumber . '/comments ' , ["Authorization " => "Bearer $ this ->accessToken " ], ["body " => "hello from Utopia! " ]);
137+ $ url = '/repos/ ' . $ this ->user . '/ ' . $ repoName . '/issues/ ' . $ pullRequestNumber . '/comments ' ;
138+
139+ $ this ->call (self ::METHOD_POST , $ url , ["Authorization " => "Bearer $ this ->accessToken " ], ["body " => "hello from Utopia! " ]);
140+
136141 return ;
137142 }
138143
@@ -144,7 +149,34 @@ public function addComment($repoName, $pullRequestNumber)
144149 */
145150 public function updateComment ($ repoName , $ commentId )
146151 {
147- $ this ->call (self ::METHOD_PATCH , '/repos/ ' . $ this ->user . '/ ' . $ repoName . '/issues/comments/ ' . $ commentId , ["Authorization " => "Bearer $ this ->accessToken " ], ["body " => "update from Utopia! " ]);
152+ $ url = '/repos/ ' . $ this ->user . '/ ' . $ repoName . '/issues/comments/ ' . $ commentId ;
153+
154+ $ this ->call (self ::METHOD_PATCH , $ url , ["Authorization " => "Bearer $ this ->accessToken " ], ["body " => "update from Utopia! " ]);
155+
148156 return ;
149157 }
158+
159+ /**
160+ * Downloads a ZIP archive of a repository.
161+ *
162+ * @param string $repo The name of the repository.
163+ * @param string $ref The name of the commit, branch, or tag to download.
164+ * @param string $path The path of the file or directory to download. Optional.
165+ * @return string The contents of the ZIP archive as a string.
166+ */
167+ public function downloadRepositoryZip (string $ repoName , string $ ref , string $ path = '' ): string
168+ {
169+ // Build the URL for the API request
170+ $ url = "/repos/ " . $ this ->user . "/ {$ repoName }/zipball/ {$ ref }" ;
171+
172+ // Add the path parameter to the URL query parameters, if specified
173+ if (!empty ($ path )) {
174+ $ url .= "?path= {$ path }" ;
175+ }
176+
177+ $ response = $ this ->call (self ::METHOD_GET , $ url , ["Authorization " => "Bearer $ this ->accessToken " ]);
178+
179+ // Return the contents of the ZIP archive
180+ return $ response ['body ' ];
181+ }
150182}
0 commit comments