| @@ 43-60 (lines=18) @@ | ||
| 40 | * @since 1.0 |
|
| 41 | * @throws \DomainException |
|
| 42 | */ |
|
| 43 | public function create($user, $repo, $title, $base, $head, $body = '') |
|
| 44 | { |
|
| 45 | // Build the request path. |
|
| 46 | $path = '/repos/' . $user . '/' . $repo . '/pulls'; |
|
| 47 | ||
| 48 | // Build the request data. |
|
| 49 | $data = json_encode( |
|
| 50 | array( |
|
| 51 | 'title' => $title, |
|
| 52 | 'base' => $base, |
|
| 53 | 'head' => $head, |
|
| 54 | 'body' => $body |
|
| 55 | ) |
|
| 56 | ); |
|
| 57 | ||
| 58 | // Send the request. |
|
| 59 | return $this->processResponse($this->client->post($this->fetchUrl($path), $data), 201); |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * Method to create a pull request from an existing issue. |
|
| @@ 37-57 (lines=21) @@ | ||
| 34 | * |
|
| 35 | * @return object |
|
| 36 | */ |
|
| 37 | public function create($user, $repo, $pullId, $body, $commitId, $filePath, $position) |
|
| 38 | { |
|
| 39 | // Build the request path. |
|
| 40 | $path = '/repos/' . $user . '/' . $repo . '/pulls/' . (int) $pullId . '/comments'; |
|
| 41 | ||
| 42 | // Build the request data. |
|
| 43 | $data = json_encode( |
|
| 44 | array( |
|
| 45 | 'body' => $body, |
|
| 46 | 'commit_id' => $commitId, |
|
| 47 | 'path' => $filePath, |
|
| 48 | 'position' => $position |
|
| 49 | ) |
|
| 50 | ); |
|
| 51 | ||
| 52 | // Send the request. |
|
| 53 | return $this->processResponse( |
|
| 54 | $this->client->post($this->fetchUrl($path), $data), |
|
| 55 | 201 |
|
| 56 | ); |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * Method to create a comment in reply to another comment. |
|
| @@ 158-177 (lines=20) @@ | ||
| 155 | * |
|
| 156 | * @since 1.0 |
|
| 157 | */ |
|
| 158 | public function create($user, $repo, $sha, $comment, $line, $filepath, $position) |
|
| 159 | { |
|
| 160 | // Build the request path. |
|
| 161 | $path = '/repos/' . $user . '/' . $repo . '/commits/' . $sha . '/comments'; |
|
| 162 | ||
| 163 | $data = json_encode( |
|
| 164 | array( |
|
| 165 | 'body' => $comment, |
|
| 166 | 'path' => $filepath, |
|
| 167 | 'position' => (int) $position, |
|
| 168 | 'line' => (int) $line |
|
| 169 | ) |
|
| 170 | ); |
|
| 171 | ||
| 172 | // Send the request. |
|
| 173 | return $this->processResponse( |
|
| 174 | $this->client->post($this->fetchUrl($path), $data), |
|
| 175 | 201 |
|
| 176 | ); |
|
| 177 | } |
|
| 178 | } |
|
| 179 | ||