-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52bf370
commit d92f1e1
Showing
6 changed files
with
209 additions
and
0 deletions.
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,52 @@ | ||
<?php | ||
|
||
namespace Netflie\WhatsAppCloudApi\Message; | ||
|
||
final class SingleProductMessage extends Message | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected string $type = 'product'; | ||
|
||
private int $catalog_id; | ||
|
||
private string $product_retailer_id; | ||
|
||
private ?string $body; | ||
|
||
private ?string $footer; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function __construct(string $to, int $catalog_id, string $product_retailer_id, ?string $body, ?string $footer, ?string $reply_to) | ||
{ | ||
$this->catalog_id = $catalog_id; | ||
$this->product_retailer_id = $product_retailer_id; | ||
$this->body = $body; | ||
$this->footer = $footer; | ||
|
||
parent::__construct($to, $reply_to); | ||
} | ||
|
||
public function catalog_id(): int | ||
{ | ||
return $this->catalog_id; | ||
} | ||
|
||
public function product_retailer_id(): string | ||
{ | ||
return $this->product_retailer_id; | ||
} | ||
|
||
public function body(): ?string | ||
{ | ||
return $this->body; | ||
} | ||
|
||
public function footer(): ?string | ||
{ | ||
return $this->footer; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/Request/MessageRequest/RequestSingleProductMessage.php
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 RequestSingleProductMessage 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(), | ||
'action' => [ | ||
'catalog_id' => $this->message->catalog_id(), | ||
'product_retailer_id' => $this->message->product_retailer_id(), | ||
], | ||
], | ||
]; | ||
|
||
if ($this->message->body()) { | ||
$body['interactive']['body'] = ['text' => $this->message->body()]; | ||
} | ||
|
||
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