WhatsApp and Chatwoot

AbstractWhatsAppNotifcation extends AbstractNotification
in package
Uses NotificationParamParseTrait

AbstractYes
Tags
since
3.0.0

Table of Contents

Properties

$events  : array<string|int, mixed>
Keys of which evets for WhatsApp to run.
$parameters  : array<string|int, mixed>
The relation between a message template parameter position and a notification parameter.
$api  : WhatsAppApiRepository
Instance for communicating with the WhatsApp API.
$assoc  : array<string|int, mixed>
The array of association between a message template and a notification.
$eventsInstance  : WhatsAppNotificationsEvents
Events instance for handling operations related to others platforms.
$parser  : MessageTemplateParser
Instance of the class that maps the $this->assoc into the WhatsApp API request body.

Methods

__construct()  : mixed
formatInvoiceValue()  : string
getClientEmailByClientId()  : string
getClientFirstNameByClientId()  : string
getClientFirstTwoNamesByClientId()  : string
getClientFullNameByClientId()  : string
getClientIdByInvoiceId()  : int
getClientIdByOrderId()  : int
getClientIdByTicketId()  : int|null
getClientWhatsAppNumber()  : string|null
getCurrencySeparatorsFromFormatId()  : array<string|int, mixed>
WHMCS format id are related to the formats as follow:
getHostDomainByHostId()  : string
getInvoiceBalance()  : float|null
Uses localAPI GetInvoice to get the invoice balance.
getInvoiceCurrency()  : stdClass
Gets the info from the tblcurrencies database table.
getInvoiceDueDateByInvoiceId()  : string
getInvoiceItems()  : array<string|int, mixed>
getInvoiceItemsByInvoiceId()  : string
getInvoiceItemsDescriptionsByInvoiceId()  : array<string|int, mixed>
getInvoicePdfUrlByInvocieId()  : string|null
getInvoiceSubtotal()  : null|string|float
getInvoiceTotal()  : null|string|float
getItemsRelatedToInvoice()  : string
Tries to get the items of the invoice first using getOrderItemsDescripByOrderId.
getOrderIdByInvoiceId()  : int|null
getOrderItemsDescripByOrderId()  : string
Line items "type" and "domain".
getServiceProductNameByProductId()  : string
getSetting()  : string
getSettings()  : array<string|int, mixed>
getTicket()  : string
getTicketEmail()  : string
getTicketMask()  : string
getTicketNameColumn()  : string
getTicketSubject()  : string
getTicketWhatsAppCfValue()  : int|null
init()  : void
Responsible for getting all information related to the notification.
saveSettings()  : void
sendMessage()  : array<string|int, mixed>|false
Parses and sends the message.
defineParameters()  : void
Should set the parameters property.
setClientId()  : void

Properties

$events

Keys of which evets for WhatsApp to run.

public array<string|int, mixed> $events = ['cw_private_note']

cw_private_note is removed when the OpenTicket notification is being run for a client not registered.

Tags
since
3.2.0

$parameters

The relation between a message template parameter position and a notification parameter.

public array<string|int, mixed> $parameters
Tags
since
3.0.0

$assoc

The array of association between a message template and a notification.

protected array<string|int, mixed> $assoc = []
Tags
since
3.0.0

Methods

formatInvoiceValue()

public static formatInvoiceValue(int $invoiceId, float $value) : string
Parameters
$invoiceId : int
$value : float
Return values
string

getClientEmailByClientId()

public static getClientEmailByClientId(int $clientId) : string
Parameters
$clientId : int
Return values
string

getClientFirstNameByClientId()

public static getClientFirstNameByClientId(int $id) : string
Parameters
$id : int
Return values
string

getClientFirstTwoNamesByClientId()

public static getClientFirstTwoNamesByClientId(int $id) : string
Parameters
$id : int
Return values
string

getClientFullNameByClientId()

public static getClientFullNameByClientId(int $id) : string
Parameters
$id : int
Return values
string

getClientIdByInvoiceId()

public getClientIdByInvoiceId(int $invoiceId) : int
Parameters
$invoiceId : int
Return values
int

getClientIdByOrderId()

public getClientIdByOrderId(int $orderId) : int
Parameters
$orderId : int
Return values
int

getClientIdByTicketId()

public getClientIdByTicketId(int $ticketId) : int|null
Parameters
$ticketId : int
Return values
int|null

getClientWhatsAppNumber()

public static getClientWhatsAppNumber(int $clientId) : string|null
Parameters
$clientId : int
Return values
string|null

getCurrencySeparatorsFromFormatId()

WHMCS format id are related to the formats as follow:

public static getCurrencySeparatorsFromFormatId(int $formatId) : array<string|int, mixed>

1 - 1234.56 2 - 1,234.56 3 - 1.234,56 4 - 1,234

Parameters
$formatId : int
Return values
array<string|int, mixed>

an array as: [decimal => '', thousands => ''].

getHostDomainByHostId()

public getHostDomainByHostId(int $hostId) : string
Parameters
$hostId : int
Return values
string

getInvoiceCurrency()

Gets the info from the tblcurrencies database table.

public static getInvoiceCurrency(int $invoiceId) : stdClass
Parameters
$invoiceId : int
Return values
stdClass

getInvoiceDueDateByInvoiceId()

public static getInvoiceDueDateByInvoiceId(int $invoiceId) : string
Parameters
$invoiceId : int
Return values
string

getInvoiceItems()

public getInvoiceItems(int $invoiceId) : array<string|int, mixed>
Parameters
$invoiceId : int
Tags
since
2.0.0
Return values
array<string|int, mixed>

An array of items like: ( [id] => [type] => [relid] => [description] => [amount] => [taxed] => [product_id] => ) Some items may not have a product_id since it must be a manually-added product or a taxe.

getInvoiceItemsByInvoiceId()

public static getInvoiceItemsByInvoiceId(int $invoiceId) : string
Parameters
$invoiceId : int
Return values
string

getInvoiceItemsDescriptionsByInvoiceId()

public static getInvoiceItemsDescriptionsByInvoiceId(int $invoiceId) : array<string|int, mixed>
Parameters
$invoiceId : int
Tags
since
3.0.1
Return values
array<string|int, mixed>

[0 => Description 1, 1 => Description 2]

getInvoicePdfUrlByInvocieId()

public static getInvoicePdfUrlByInvocieId(int $id[, bool $returnNullOtherwise = false ]) : string|null
Parameters
$id : int
$returnNullOtherwise : bool = false
Return values
string|null

getInvoiceSubtotal()

public static getInvoiceSubtotal(int $invoiceId[, bool $formatFriendly = true ]) : null|string|float
Parameters
$invoiceId : int
$formatFriendly : bool = true
Return values
null|string|float

getInvoiceTotal()

public static getInvoiceTotal(int $invoiceId[, bool $formatFriendly = true ]) : null|string|float
Parameters
$invoiceId : int
$formatFriendly : bool = true
Return values
null|string|float

getItemsRelatedToInvoice()

Tries to get the items of the invoice first using getOrderItemsDescripByOrderId.

public static getItemsRelatedToInvoice(int $invoiceId) : string

If an empty string is returned, the uses getInvoiceItemsByInvoiceId.

Parameters
$invoiceId : int
Tags
since
3.4.0
Return values
string

getOrderIdByInvoiceId()

public static getOrderIdByInvoiceId(int $invoiceId) : int|null
Parameters
$invoiceId : int
Return values
int|null

getOrderItemsDescripByOrderId()

Line items "type" and "domain".

public static getOrderItemsDescripByOrderId(int $orderId) : string
Parameters
$orderId : int
Tags
since
2.0.0
Return values
string

getServiceProductNameByProductId()

public static getServiceProductNameByProductId(int $productId) : string
Parameters
$productId : int
Return values
string

getTicket()

public getTicket(int $ticketId, string $column) : string
Parameters
$ticketId : int
$column : string
Return values
string

getTicketNameColumn()

public getTicketNameColumn(int $ticketId) : string
Parameters
$ticketId : int
Return values
string

getTicketSubject()

public getTicketSubject(int $ticketId) : string
Parameters
$ticketId : int
Return values
string

getTicketWhatsAppCfValue()

public getTicketWhatsAppCfValue(int $ticketId) : int|null
Parameters
$ticketId : int
Return values
int|null

init()

Responsible for getting all information related to the notification.

public final init() : void

Gets the client WhatsApp number and the association between the notification and message template.

Tags
since
3.0.0

saveSettings()

public saveSettings(array<string|int, mixed> $newValuesPerSetting) : void
Parameters
$newValuesPerSetting : array<string|int, mixed>

sendMessage()

Parses and sends the message.

public final sendMessage([int|null $whatsappNumber = null ]) : array<string|int, mixed>|false

Useful for simple notification that does not require too much customizations.

Parameters
$whatsappNumber : int|null = null
Tags
since
3.0.0
Return values
array<string|int, mixed>|false

the WhatsApp API response.

defineParameters()

Should set the parameters property.

protected defineParameters() : void

The array must follow the structure below:

$this->parameters = [ 'invoice_id' => [ 'label' => 'ID da fatura', 'parser' => fn () => $this->hookParams['invoiceid'], ] ];

Tags
since
3.0.0

        
On this page

Search results