testmonitor /
devops-client
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace TestMonitor\DevOps\Actions; |
||||||
| 4 | |||||||
| 5 | use TestMonitor\DevOps\Resources\Webhook; |
||||||
| 6 | use TestMonitor\DevOps\Transforms\TransformsWebhooks; |
||||||
| 7 | |||||||
| 8 | trait ManagesWebhooks |
||||||
| 9 | { |
||||||
| 10 | use TransformsWebhooks; |
||||||
| 11 | |||||||
| 12 | /** |
||||||
| 13 | * Get a list of webhooks. |
||||||
| 14 | * |
||||||
| 15 | * @param string $eventType |
||||||
| 16 | * |
||||||
| 17 | * @throws \TestMonitor\DevOps\Exceptions\InvalidDataException |
||||||
| 18 | * |
||||||
| 19 | * @return \TestMonitor\DevOps\Resources\Webhook[] |
||||||
| 20 | */ |
||||||
| 21 | 5 | public function webhooks($eventType = '') |
|||||
| 22 | { |
||||||
| 23 | 5 | $response = $this->get('_apis/hooks/subscriptions', [ |
|||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 24 | 5 | 'query' => array_filter([ |
|||||
| 25 | 5 | 'eventType' => $eventType, |
|||||
| 26 | 5 | 'consumerId' => 'webHooks', |
|||||
| 27 | 5 | ]), |
|||||
| 28 | 5 | ]); |
|||||
| 29 | |||||||
| 30 | 1 | return $this->fromDevOpsWebhooks($response['value']); |
|||||
| 31 | } |
||||||
| 32 | |||||||
| 33 | /** |
||||||
| 34 | * Create a new webhook. |
||||||
| 35 | * |
||||||
| 36 | * @param \TestMonitor\DevOps\Resources\Webhook $webhook |
||||||
| 37 | * |
||||||
| 38 | * @throws \TestMonitor\DevOps\Exceptions\InvalidDataException |
||||||
| 39 | * |
||||||
| 40 | * @return \TestMonitor\DevOps\Resources\Webhook |
||||||
| 41 | */ |
||||||
| 42 | 2 | public function createWebhook(Webhook $webhook): Webhook |
|||||
| 43 | { |
||||||
| 44 | 2 | $response = $this->post( |
|||||
|
0 ignored issues
–
show
It seems like
post() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 45 | 2 | '_apis/hooks/subscriptions', |
|||||
| 46 | 2 | [ |
|||||
| 47 | 2 | 'json' => $this->toDevOpsWebhook($webhook), |
|||||
| 48 | 2 | ] |
|||||
| 49 | 2 | ); |
|||||
| 50 | |||||||
| 51 | 1 | return $this->fromDevOpsWebhook($response); |
|||||
| 52 | } |
||||||
| 53 | |||||||
| 54 | /** |
||||||
| 55 | * Delete a webhook. |
||||||
| 56 | * |
||||||
| 57 | * @param int $id |
||||||
| 58 | * |
||||||
| 59 | * @throws \TestMonitor\DevOps\Exceptions\InvalidDataException |
||||||
| 60 | * |
||||||
| 61 | * @return bool |
||||||
| 62 | */ |
||||||
| 63 | 2 | public function deleteWebhook($id): bool |
|||||
| 64 | { |
||||||
| 65 | 2 | $response = $this->delete("_apis/hooks/subscriptions/{$id}"); |
|||||
|
0 ignored issues
–
show
The method
delete() does not exist on TestMonitor\DevOps\Actions\ManagesWebhooks. Did you maybe mean deleteWebhook()?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
|
|||||||
| 66 | |||||||
| 67 | 1 | return empty($response); |
|||||
| 68 | } |
||||||
| 69 | } |
||||||
| 70 |