/** * @param Webhook $webhook * @param string $domain * @param int $webhookId * @param null|string $accessToken * @return Webhook */ public function editWebhook(Webhook $webhook, $domain, $webhookId, $accessToken = null) { $data = ['target_url' => $webhook->getTargetUrl(), 'secret_key' => $webhook->getSecretKey(), 'events' => $webhook->getEvents()]; $projectFilter = $webhook->getProjectFilter(); if (isset($projectFilter)) { $data['project_filter'] = ['name' => $projectFilter->getName()]; } return $this->patchJson($accessToken, $data, '/workspaces/:domain/webhooks/:webhook_id', ['domain' => $domain, 'webhook_id' => $webhookId])->getAsWebhook(); }
public function testAddWebhook2() { $webhook = new Webhook(); $webhook->setTargetUrl('http://onet.pl'); $webhook->setEvents([Webhook::EVENT_RELEASE_FAILED]); $resp = Utils::getBuddy()->getApiWebhooks()->addWebhook($webhook, Utils::getWorkspaceDomain()); $this->assertInstanceOf('Buddy\\Objects\\Webhook', $resp); $this->assertEquals($webhook->getTargetUrl(), $resp->getTargetUrl()); $this->assertEquals($webhook->getSecretKey(), $resp->getSecretKey()); $this->assertEquals($webhook->getProjectFilter(), $resp->getProjectFilter()); $events = $resp->getEvents(); $this->assertInternalType('array', $events); $this->assertEquals(1, count($events)); $this->assertEquals(Webhook::EVENT_RELEASE_FAILED, $events[0]); }
public function editWebhook() { try { $buddy = new Buddy(['accessToken' => 'yourAccessToken']); $webhook = new Webhook(); $webhook->setEvents([Webhook::EVENT_PUSH, Webhook::EVENT_RELEASE_FAILED, Webhook::EVENT_RELEASE_SUCCESSFUL]); $resp = $buddy->getApiWebhooks()->editWebhook($webhook, 'domain', 1); var_dump($resp); exit; } catch (BuddyResponseException $e) { echo $e->getMessage(); exit; } catch (BuddySDKException $e) { echo $e->getMessage(); exit; } }
/** * @return Webhook */ public static function addWebhook() { $webhook = new Webhook(); $webhook->setTargetUrl('http://onet.pl'); $webhook->setEvents([Webhook::EVENT_RELEASE_FAILED]); return Utils::getBuddy()->getApiWebhooks()->addWebhook($webhook, Utils::getWorkspaceDomain()); }