The Payload class implement PayloadInterface, which in turn inherits from two interfaces: SetPayloadInterface and GetPayloadInterface
WebhookClient::send requires only an object of the GetPayloadInterface type as an argument, which means that you can omit the entire Payload class and define your own templates, which will, like the Payload class, return all components required for Payload in the GetPayloadInterface::toArray method
The Payload class, thanks to the SetPayloadInterface implementation, offers the following methods:
setUsername
- to set webhook bot namesetAvatarUrl
- set webhook bot avatarsetMessage
- to set a text messagesetEmbed
- to add embedsetTts
- to set or unset TTS
All setters implement the Fluent Interface pattern.
$payload = new Payload();
$payload->addEmbed($embed) // @see Embed.md
;
$payload = new Payload();
$payload->setAvatarUrl("Webhook Bot Avatar URL")
->setUsername("Webhook Bot Name")
;
$payload = new Payload();
$payload->setMessage("Some message")
->addEmbed($embed) // @see Embed.md
;
$payload = new Payload();
$payload->setAvatarUrl("Webhook Bot Avatar URL")
->setUsername("Webhook Bot Name")
->setMessage("Some message")
->setTts(false) // or true.. if you want it
->addEmbed($embed) // @see Embed.md
;