| 1 | <?php |
||
| 7 | class Client |
||
| 8 | { |
||
| 9 | |||
| 10 | protected $projectUrl; |
||
| 11 | |||
| 12 | protected $projectId; |
||
| 13 | |||
| 14 | protected $privateKey; |
||
| 15 | |||
| 16 | protected $status; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @param $projectUrl |
||
| 20 | * @param $projectId |
||
| 21 | * @param $privateKey |
||
| 22 | */ |
||
| 23 | 3 | public function __construct($projectUrl, $projectId, $privateKey) |
|
| 29 | |||
| 30 | /** |
||
| 31 | * @param string $branch |
||
| 32 | * |
||
| 33 | * @return mixed |
||
| 34 | * @throws \Exception |
||
| 35 | */ |
||
| 36 | 3 | public function getStatus($branch = 'master') |
|
| 55 | |||
| 56 | /** |
||
| 57 | * @param $response |
||
| 58 | * |
||
| 59 | * @return array|null |
||
| 60 | */ |
||
| 61 | 2 | protected function setStatus($response) |
|
| 62 | { |
||
| 63 | 2 | $this->status = 'success'; |
|
| 64 | |||
| 65 | 2 | foreach($response as $buildStatus) { |
|
| 66 | 2 | if($buildStatus->allow_failure === false && $buildStatus->status == 'failed') { |
|
| 67 | 1 | $this->status = 'failed'; |
|
| 68 | 1 | } |
|
| 69 | 2 | } |
|
| 70 | 2 | } |
|
| 71 | |||
| 72 | /** |
||
| 73 | * @param $branch |
||
| 74 | * @return mixed |
||
| 75 | * @throws \Exception |
||
| 76 | */ |
||
| 77 | 3 | protected function getLatestCommitSha($branch) |
|
| 91 | |||
| 92 | } |