-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #191 from derrickobedgiu1/catalog-message
Add Catalog Message
- Loading branch information
Showing
6 changed files
with
187 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Netflie\WhatsAppCloudApi\Message; | ||
|
||
final class CatalogMessage extends Message | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected string $type = 'catalog_message'; | ||
|
||
private string $body; | ||
|
||
private ?string $footer; | ||
|
||
private ?string $thumbnail_product_retailer_id; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function __construct(string $to, string $body, ?string $footer, ?string $thumbnail_product_retailer_id, ?string $reply_to) | ||
{ | ||
$this->body = $body; | ||
$this->footer = $footer; | ||
$this->thumbnail_product_retailer_id = $thumbnail_product_retailer_id; | ||
|
||
parent::__construct($to, $reply_to); | ||
} | ||
|
||
public function body(): string | ||
{ | ||
return $this->body; | ||
} | ||
|
||
public function footer(): ?string | ||
{ | ||
return $this->footer; | ||
} | ||
|
||
public function thumbnail_product_retailer_id(): ?string | ||
{ | ||
return $this->thumbnail_product_retailer_id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Netflie\WhatsAppCloudApi\Request\MessageRequest; | ||
|
||
use Netflie\WhatsAppCloudApi\Request\MessageRequest; | ||
|
||
final class RequestCatalogMessage extends MessageRequest | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function body(): array | ||
{ | ||
$body = [ | ||
'messaging_product' => $this->message->messagingProduct(), | ||
'recipient_type' => $this->message->recipientType(), | ||
'to' => $this->message->to(), | ||
'type' => 'interactive', | ||
'interactive' => [ | ||
'type' => $this->message->type(), | ||
'body' => ['text' => $this->message->body()], | ||
'action' => [ | ||
'name' => 'catalog_message', | ||
], | ||
], | ||
]; | ||
|
||
if ($this->message->thumbnail_product_retailer_id()) { | ||
$body['interactive']['action']['parameters'] = ['thumbnail_product_retailer_id' => $this->message->thumbnail_product_retailer_id()]; | ||
} | ||
|
||
if ($this->message->footer()) { | ||
$body['interactive']['footer'] = ['text' => $this->message->footer()]; | ||
} | ||
|
||
if ($this->message->replyTo()) { | ||
$body['context']['message_id'] = $this->message->replyTo(); | ||
} | ||
|
||
return $body; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters