AbstractWhatsAppNotifcation
extends AbstractNotification
in package
Uses
NotificationParamParseTrait
Tags
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
$parameters
The relation between a message template parameter position and a notification parameter.
public
array<string|int, mixed>
$parameters
Tags
$api read-only
Instance for communicating with the WhatsApp API.
protected
WhatsAppApiRepository
$api
Tags
$assoc
The array of association between a message template and a notification.
protected
array<string|int, mixed>
$assoc
= []
Tags
$eventsInstance read-only
Events instance for handling operations related to others platforms.
protected
WhatsAppNotificationsEvents
$eventsInstance
A operation may be sending the message to Chatwoot.
Tags
$parser read-only
Instance of the class that maps the $this->assoc into the WhatsApp API request body.
protected
MessageTemplateParser
$parser
Tags
Methods
__construct()
public
__construct() : mixed
formatInvoiceValue()
public
static formatInvoiceValue(int $invoiceId, float $value) : string
Parameters
- $invoiceId : int
- $value : float
Return values
stringgetClientEmailByClientId()
public
static getClientEmailByClientId(int $clientId) : string
Parameters
- $clientId : int
Return values
stringgetClientFirstNameByClientId()
public
static getClientFirstNameByClientId(int $id) : string
Parameters
- $id : int
Return values
stringgetClientFirstTwoNamesByClientId()
public
static getClientFirstTwoNamesByClientId(int $id) : string
Parameters
- $id : int
Return values
stringgetClientFullNameByClientId()
public
static getClientFullNameByClientId(int $id) : string
Parameters
- $id : int
Return values
stringgetClientIdByInvoiceId()
public
getClientIdByInvoiceId(int $invoiceId) : int
Parameters
- $invoiceId : int
Return values
intgetClientIdByOrderId()
public
getClientIdByOrderId(int $orderId) : int
Parameters
- $orderId : int
Return values
intgetClientIdByTicketId()
public
getClientIdByTicketId(int $ticketId) : int|null
Parameters
- $ticketId : int
Return values
int|nullgetClientWhatsAppNumber()
public
static getClientWhatsAppNumber(int $clientId) : string|null
Parameters
- $clientId : int
Return values
string|nullgetCurrencySeparatorsFromFormatId()
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
stringgetInvoiceBalance()
Uses localAPI GetInvoice to get the invoice balance.
public
static getInvoiceBalance(int $invoiceId[, bool $formatFriendly = true ]) : float|null
Parameters
- $invoiceId : int
- $formatFriendly : bool = true
Tags
Return values
float|nullgetInvoiceCurrency()
Gets the info from the tblcurrencies database table.
public
static getInvoiceCurrency(int $invoiceId) : stdClass
Parameters
- $invoiceId : int
Return values
stdClassgetInvoiceDueDateByInvoiceId()
public
static getInvoiceDueDateByInvoiceId(int $invoiceId) : string
Parameters
- $invoiceId : int
Return values
stringgetInvoiceItems()
public
getInvoiceItems(int $invoiceId) : array<string|int, mixed>
Parameters
- $invoiceId : int
Tags
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
stringgetInvoiceItemsDescriptionsByInvoiceId()
public
static getInvoiceItemsDescriptionsByInvoiceId(int $invoiceId) : array<string|int, mixed>
Parameters
- $invoiceId : int
Tags
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|nullgetInvoiceSubtotal()
public
static getInvoiceSubtotal(int $invoiceId[, bool $formatFriendly = true ]) : null|string|float
Parameters
- $invoiceId : int
- $formatFriendly : bool = true
Return values
null|string|floatgetInvoiceTotal()
public
static getInvoiceTotal(int $invoiceId[, bool $formatFriendly = true ]) : null|string|float
Parameters
- $invoiceId : int
- $formatFriendly : bool = true
Return values
null|string|floatgetItemsRelatedToInvoice()
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
Return values
stringgetOrderIdByInvoiceId()
public
static getOrderIdByInvoiceId(int $invoiceId) : int|null
Parameters
- $invoiceId : int
Return values
int|nullgetOrderItemsDescripByOrderId()
Line items "type" and "domain".
public
static getOrderItemsDescripByOrderId(int $orderId) : string
Parameters
- $orderId : int
Tags
Return values
stringgetServiceProductNameByProductId()
public
static getServiceProductNameByProductId(int $productId) : string
Parameters
- $productId : int
Return values
stringgetSetting()
public
getSetting(string $name) : string
Parameters
- $name : string
Return values
stringgetSettings()
public
getSettings() : array<string|int, mixed>
Return values
array<string|int, mixed>getTicket()
public
getTicket(int $ticketId, string $column) : string
Parameters
- $ticketId : int
- $column : string
Return values
stringgetTicketEmail()
public
getTicketEmail(int $ticketId) : string
Parameters
- $ticketId : int
Return values
stringgetTicketMask()
public
getTicketMask(int $ticketId) : string
Parameters
- $ticketId : int
Return values
stringgetTicketNameColumn()
public
getTicketNameColumn(int $ticketId) : string
Parameters
- $ticketId : int
Return values
stringgetTicketSubject()
public
getTicketSubject(int $ticketId) : string
Parameters
- $ticketId : int
Return values
stringgetTicketWhatsAppCfValue()
public
getTicketWhatsAppCfValue(int $ticketId) : int|null
Parameters
- $ticketId : int
Return values
int|nullinit()
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
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
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
setClientId()
protected
setClientId(int $clientId) : void
Parameters
- $clientId : int