QBO Webhooks Listener

<back to all web services

QboWebhooksRequest

The following routes are available for this service:
POST/qbowebhook
<?php namespace dtos;

use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};


enum QBOEntityName : int
{
    case Customer = 20;
    case Department = 21;
    case Vendor = 21;
    case Deposit = 22;
    case Invoice = 23;
    case Bill = 24;
    case Item = 24;
    case JournalCode = 25;
    case PurchaseOrder = 25;
    case JournalEntry = 26;
    case Estimate = 26;
    case RefundReceipt = 26;
    case Employee = 27;
    case SalesReceipt = 27;
    case TaxAgency = 28;
    case Term = 29;
    case TimeActivity = 30;
    case Account = 30;
    case Transfer = 31;
    case VendorCredit = 31;
    case CreditMemo = 32;
    case Purchase = 33;
    case Currency = 33;
    case Payment = 35;
    case PaymentMethod = 36;
    case BillPayment = 36;
    case Preferences = 37;
    case Budget = 37;
    case Class = 38;
}

enum QBOOperation : string
{
    case Update = 'Update';
    case Create = 'Create';
    case Merge = 'Merge';
    case Delete = 'Delete';
    case Emailed = 'Emailed';
    case Void = 'Void';
}

class QBOEntity implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="name")
        /** @var QBOEntityName|null */
        public ?QBOEntityName $name=null,

        // @DataMember(Name="id")
        /** @var string|null */
        public ?string $id=null,

        // @DataMember(Name="operation")
        /** @var QBOOperation|null */
        public ?QBOOperation $operation=null,

        // @DataMember(Name="lastUpdated")
        /** @var DateTime */
        public DateTime $lastUpdated=new DateTime(),

        // @DataMember(Name="deletedId")
        /** @var string|null */
        public ?string $deletedId=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['name'])) $this->name = JsonConverters::from('QBOEntityName', $o['name']);
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['operation'])) $this->operation = JsonConverters::from('QBOOperation', $o['operation']);
        if (isset($o['lastUpdated'])) $this->lastUpdated = JsonConverters::from('DateTime', $o['lastUpdated']);
        if (isset($o['deletedId'])) $this->deletedId = $o['deletedId'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->name)) $o['name'] = JsonConverters::to('QBOEntityName', $this->name);
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->operation)) $o['operation'] = JsonConverters::to('QBOOperation', $this->operation);
        if (isset($this->lastUpdated)) $o['lastUpdated'] = JsonConverters::to('DateTime', $this->lastUpdated);
        if (isset($this->deletedId)) $o['deletedId'] = $this->deletedId;
        return empty($o) ? new class(){} : $o;
    }
}

class QBODataChangeEvent implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="entities")
        /** @var array<QBOEntity>|null */
        public ?array $entities=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['entities'])) $this->entities = JsonConverters::fromArray('QBOEntity', $o['entities']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->entities)) $o['entities'] = JsonConverters::toArray('QBOEntity', $this->entities);
        return empty($o) ? new class(){} : $o;
    }
}

class QBOEventNotification implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="realmId")
        /** @var string|null */
        public ?string $realmId=null,

        // @DataMember(Name="dataChangeEvent")
        /** @var QBODataChangeEvent|null */
        public ?QBODataChangeEvent $dataChangeEvent=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['realmId'])) $this->realmId = $o['realmId'];
        if (isset($o['dataChangeEvent'])) $this->dataChangeEvent = JsonConverters::from('QBODataChangeEvent', $o['dataChangeEvent']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->realmId)) $o['realmId'] = $this->realmId;
        if (isset($this->dataChangeEvent)) $o['dataChangeEvent'] = JsonConverters::to('QBODataChangeEvent', $this->dataChangeEvent);
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract
class QboWebhooksRequest implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="eventNotifications")
        /** @var array<QBOEventNotification>|null */
        public ?array $eventNotifications=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['eventNotifications'])) $this->eventNotifications = JsonConverters::fromArray('QBOEventNotification', $o['eventNotifications']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->eventNotifications)) $o['eventNotifications'] = JsonConverters::toArray('QBOEventNotification', $this->eventNotifications);
        return empty($o) ? new class(){} : $o;
    }
}

PHP QboWebhooksRequest DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other

HTTP + OTHER

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /qbowebhook HTTP/1.1 
Host: wh.entersecurity.com 
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length

{"eventNotifications":[{"realmId":"String","dataChangeEvent":{"entities":[{"name":"Customer","id":"String","operation":"Update","lastUpdated":"\/Date(-62135596800000-0000)\/","deletedId":"String"}]}}]}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

(string)