@@ -46,14 +46,14 @@ public function project(int $projectId)
4646 return $ this ->request ('GET ' , '/projects/ ' .$ projectId );
4747 }
4848
49- public function createBuild (int $ projectId , $ zipFilename , $ githubAccessToken = null )
49+ public function createBuild (int $ projectId , $ zipFile , $ githubAccessToken = null )
5050 {
5151 $ options = [
5252 'multipart ' => [
5353 [
5454 'name ' => 'uploaded_source_file ' ,
55- 'filename ' => basename ($ zipFilename ),
56- 'contents ' => Utils::tryFopen ($ zipFilename , 'r ' ),
55+ 'filename ' => basename ($ zipFile ),
56+ 'contents ' => Utils::tryFopen ($ zipFile , 'r ' ),
5757 ],
5858 ],
5959 ];
@@ -67,7 +67,7 @@ public function createBuild(int $projectId, $zipFilename, $githubAccessToken = n
6767
6868 return $ this ->request (
6969 'POST ' ,
70- '/projects/ ' .$ projectId .'/build ' ,
70+ '/projects/ ' .$ projectId .'/builds ' ,
7171 $ options
7272 );
7373 }
@@ -99,15 +99,17 @@ public function downloadLog(int $projectId, int $buildId, $file)
9999
100100 private function request (string $ method , $ relApiUri = '' , array $ options = [])
101101 {
102- $ options = array_merge ($ this ->jsonHeaders (), $ options );
102+ $ options = array_merge ($ this ->headers (), $ options );
103103
104104 $ res = (new GuzzleClient ())->request (
105- ' GET ' ,
105+ $ method ,
106106 self ::API_BASE_URI .$ relApiUri ,
107107 $ options ,
108108 );
109109
110- if (200 === $ res ->getStatusCode ()) {
110+ $ statusCode = $ res ->getStatusCode ();
111+
112+ if (200 === $ statusCode || 201 === $ statusCode ) {
111113 if (\in_array ('application/json ' , $ res ->getHeader ('Content-Type ' ), true )) {
112114 return json_decode ($ res ->getBody ());
113115 }
@@ -118,11 +120,10 @@ private function request(string $method, $relApiUri = '', array $options = [])
118120 throw new Exception ($ res ->getReasonPhrase (), $ res ->getStatusCode ());
119121 }
120122
121- private function jsonHeaders ()
123+ private function headers ()
122124 {
123125 return [
124126 'headers ' => [
125- 'Content-Type ' => 'application/json ' ,
126127 'Accept ' => 'application/json, text/plain, */* ' ,
127128 'Authorization ' => 'Bearer ' .$ this ->personalAccessToken ,
128129 ],
0 commit comments