mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for webhooks
This commit is contained in:
parent
ba8cc3e44d
commit
5f9784dcf8
@ -39,6 +39,8 @@ class StoreWebhookRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if(!isset($input['rest_method']))
|
||||
$input['rest_method'] = 'post';
|
||||
// if(isset($input['headers']) && count($input['headers']) == 0)
|
||||
// $input['headers'] = null;
|
||||
|
||||
|
@ -44,6 +44,9 @@ class UpdateWebhookRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
if(!isset($input['rest_method']))
|
||||
$input['rest_method'] = 'post';
|
||||
|
||||
// if(isset($input['headers']) && count($input['headers']) == 0)
|
||||
// $input['headers'] = null;
|
||||
|
||||
|
@ -59,7 +59,7 @@ class ClientObserver
|
||||
->exists();
|
||||
|
||||
if ($subscriptions)
|
||||
WebhookHandler::dispatch($event, $client, $client->company)->delay(0);
|
||||
WebhookHandler::dispatch($event, $client, $client->company, 'client')->delay(0);
|
||||
|
||||
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ class InvoiceObserver
|
||||
->exists();
|
||||
|
||||
if ($subscriptions)
|
||||
WebhookHandler::dispatch($event, $invoice, $invoice->company)->delay(0);
|
||||
WebhookHandler::dispatch($event, $invoice, $invoice->company, 'client')->delay(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -49,33 +49,6 @@ class WebhookAPITest extends TestCase
|
||||
$this->withoutExceptionHandling();
|
||||
}
|
||||
|
||||
// public function testClientWebhooks()
|
||||
// {
|
||||
// // client archived = 37
|
||||
// $data = [
|
||||
// 'target_url' => 'http://hook.com',
|
||||
// 'event_id' => 37,
|
||||
// 'rest_method' => 'post',
|
||||
// 'format' => 'JSON',
|
||||
// ];
|
||||
|
||||
// $response = $this->withHeaders([
|
||||
// 'X-API-SECRET' => config('ninja.api_secret'),
|
||||
// 'X-API-TOKEN' => $this->token,
|
||||
// ])->post('/api/v1/webhooks', $data);
|
||||
|
||||
// $repo = new ClientRepository(new ClientContactRepository());
|
||||
|
||||
// $repo->archive($this->client);
|
||||
|
||||
// \Illuminate\Support\Facades\Queue::after(function (WebhookHandler $event) {
|
||||
// $this->assertTrue($event->job->isReleased());
|
||||
// });
|
||||
|
||||
// \Illuminate\Support\Facades\Queue::assertPushed(WebhookHandler::class);
|
||||
|
||||
// }
|
||||
|
||||
public function testWebhookGetFilter()
|
||||
{
|
||||
$response = $this->withHeaders([
|
||||
@ -98,6 +71,20 @@ class WebhookAPITest extends TestCase
|
||||
|
||||
public function testWebhookPostRoute()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'target_url' => 'http://hook.com',
|
||||
'event_id' => 1,
|
||||
'format' => 'JSON',
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->post('/api/v1/webhooks', $data);
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
$data = [
|
||||
'target_url' => 'http://hook.com',
|
||||
'event_id' => 1,
|
||||
@ -116,6 +103,20 @@ class WebhookAPITest extends TestCase
|
||||
|
||||
$this->assertEquals(1, $arr['data']['event_id']);
|
||||
|
||||
$data = [
|
||||
'target_url' => 'http://hook.com',
|
||||
'event_id' => 2,
|
||||
'format' => 'JSON',
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->put('/api/v1/webhooks/'.$arr['data']['id'], $data);
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
|
||||
$data = [
|
||||
'target_url' => 'http://hook.com',
|
||||
'event_id' => 2,
|
||||
|
Loading…
x
Reference in New Issue
Block a user