-
-
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.
2.x: Split responsability of Request class
- Loading branch information
Showing
19 changed files
with
242 additions
and
301 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace Netflie\WhatsAppCloudApi\Request; | ||
|
||
use Netflie\WhatsAppCloudApi\Message\Message; | ||
use Netflie\WhatsAppCloudApi\Request; | ||
|
||
abstract class MessageRequest extends Request | ||
{ | ||
/** | ||
* @var Message WhatsApp Message to be sent. | ||
*/ | ||
protected Message $message; | ||
|
||
/** | ||
* @var string WhatsApp Number Id from messages will sent. | ||
*/ | ||
protected string $from_phone_number_id; | ||
|
||
public function __construct(Message $message, string $access_token, string $from_phone_number_id, ?int $timeout = null) | ||
{ | ||
$this->message = $message; | ||
$this->from_phone_number_id = $from_phone_number_id; | ||
|
||
parent::__construct($access_token, $timeout); | ||
} | ||
|
||
/** | ||
* Returns the raw body of the request. | ||
* | ||
* @return array | ||
*/ | ||
abstract public function body(): array; | ||
|
||
/** | ||
* Return WhatsApp Number Id for this request. | ||
* | ||
* @return string | ||
*/ | ||
public function fromPhoneNumberId(): string | ||
{ | ||
return $this->from_phone_number_id; | ||
} | ||
|
||
/** | ||
* WhatsApp node path. | ||
* | ||
* @return string | ||
*/ | ||
public function nodePath(): string | ||
{ | ||
return $this->from_phone_number_id . '/messages'; | ||
} | ||
} |
15 changes: 7 additions & 8 deletions
15
src/Request/RequestAudioMessage.php → ...st/MessageRequest/RequestAudioMessage.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
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
15 changes: 7 additions & 8 deletions
15
src/Request/RequestDocumentMessage.php → ...MessageRequest/RequestDocumentMessage.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
15 changes: 7 additions & 8 deletions
15
src/Request/RequestImageMessage.php → ...st/MessageRequest/RequestImageMessage.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
15 changes: 7 additions & 8 deletions
15
src/Request/RequestLocationMessage.php → ...MessageRequest/RequestLocationMessage.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
Oops, something went wrong.