1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-19 16:01:34 +02:00

Added new event listeners for Zapier

* Add updated quote listener
* Add updated invoice listener
* Add deleted invoice listener
This commit is contained in:
Rowdy Klijnsmit 2016-12-05 15:39:27 +01:00
parent de7664f205
commit bb2eea035a
3 changed files with 39 additions and 1 deletions

View File

@ -634,7 +634,13 @@ if (!defined('CONTACT_EMAIL')) {
define('EVENT_CREATE_INVOICE', 2);
define('EVENT_CREATE_QUOTE', 3);
define('EVENT_CREATE_PAYMENT', 4);
define('EVENT_CREATE_VENDOR',5);
define('EVENT_CREATE_VENDOR', 5);
// Added new events
define('EVENT_UPDATE_QUOTE', 6);
define('EVENT_DELETE_QUOTE', 7);
define('EVENT_UPDATE_INVOICE', 8);
define('EVENT_DELETE_INVOICE', 9);
define('REQUESTED_PRO_PLAN', 'REQUESTED_PRO_PLAN');
define('DEMO_ACCOUNT_ID', 'DEMO_ACCOUNT_ID');

View File

@ -1,5 +1,8 @@
<?php namespace App\Listeners;
use App\Events\InvoiceWasDeleted;
use App\Events\InvoiceWasUpdated;
use App\Events\QuoteWasUpdated;
use Utils;
use App\Models\EntityModel;
use App\Events\ClientWasCreated;
@ -79,6 +82,33 @@ class SubscriptionListener
public function createdExpense(ExpenseWasCreated $event)
{
}
/**
* @param QuoteWasUpdated $event
*/
public function updatedQuote(QuoteWasUpdated $event)
{
$transformer = new InvoiceTransformer($event->quote->account);
$this->checkSubscriptions(EVENT_UPDATE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT);
}
/**
* @param InvoiceWasUpdated $event
*/
public function updatedInvoice(InvoiceWasUpdated $event)
{
$transformer = new InvoiceTransformer($event->invoice->account);
$this->checkSubscriptions(EVENT_UPDATE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT);
}
/**
* @param InvoiceWasDeleted $event
*/
public function deletedInvoice(InvoiceWasDeleted $event)
{
$transformer = new InvoiceTransformer($event->invoice->account);
$this->checkSubscriptions(EVENT_DELETE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT);
}
/**

View File

@ -36,6 +36,7 @@ class EventServiceProvider extends ServiceProvider {
'App\Events\InvoiceWasUpdated' => [
'App\Listeners\ActivityListener@updatedInvoice',
'App\Listeners\InvoiceListener@updatedInvoice',
'App\Listeners\SubscriptionListener@updatedInvoice',
],
'App\Events\InvoiceWasArchived' => [
'App\Listeners\ActivityListener@archivedInvoice',
@ -67,6 +68,7 @@ class EventServiceProvider extends ServiceProvider {
],
'App\Events\QuoteWasUpdated' => [
'App\Listeners\ActivityListener@updatedQuote',
'App\Listeners\SubscriptionListener@updatedQuote',
],
'App\Events\QuoteWasArchived' => [
'App\Listeners\ActivityListener@archivedQuote',