Skip to content

Commit 8426d55

Browse files
committed
added message object returned after whatsapp send message
1 parent fdb1970 commit 8426d55

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

src/Plugins/WhatsApp/Message.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ public function getType()
9090
return $this->type;
9191
}
9292

93+
/**
94+
* @return null|Context
95+
*/
9396
public function getContext() {
9497
if ($this->context) {
9598
return Context::create($this->context);
@@ -98,6 +101,9 @@ public function getContext() {
98101
return null;
99102
}
100103

104+
/**
105+
* @return null|Text
106+
*/
101107
public function getText() {
102108
if ($this->text) {
103109
return Text::create($this->text);
@@ -106,6 +112,9 @@ public function getText() {
106112
return null;
107113
}
108114

115+
/**
116+
* @return null|Location
117+
*/
109118
public function getLocation() {
110119
if ($this->location) {
111120
return Location::create($this->location);
@@ -133,6 +142,9 @@ public function getErrors() {
133142
return null;
134143
}
135144

145+
/**
146+
* @return null|Image
147+
*/
136148
public function getImage() {
137149
if ($this->image) {
138150
return Image::create($this->image);
@@ -141,6 +153,9 @@ public function getImage() {
141153
return null;
142154
}
143155

156+
/**
157+
* @return null|Document
158+
*/
144159
public function getDocument() {
145160
if ($this->document) {
146161
return Document::create($this->document);
@@ -149,6 +164,9 @@ public function getDocument() {
149164
return null;
150165
}
151166

167+
/**
168+
* @return null|Voice
169+
*/
152170
public function getVoice() {
153171
if ($this->voice) {
154172
return Voice::create($this->voice);
@@ -157,6 +175,9 @@ public function getVoice() {
157175
return null;
158176
}
159177

178+
/**
179+
* @return null|Sticker
180+
*/
160181
public function getSticker() {
161182
if ($this->sticker) {
162183
return Sticker::create($this->sticker);
@@ -165,6 +186,9 @@ public function getSticker() {
165186
return null;
166187
}
167188

189+
/**
190+
* @return null|System
191+
*/
168192
public function getSystem() {
169193
if ($this->system) {
170194
return System::create($this->system);

src/Plugins/WhatsApp/Traits/SendsMessages.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111

1212
use Andre\Bionic\AbstractMessage;
13+
use Andre\Bionic\Plugins\WhatsApp\Message;
1314

1415
trait SendsMessages
1516
{
@@ -49,20 +50,22 @@ public function markRead($message_id) {
4950
* send message
5051
*
5152
* @param $data
52-
* @return \Psr\Http\Message\ResponseInterface
53+
* @return Message
5354
*/
5455
protected function send(array $data)
5556
{
5657
$this->checkForPhoneNumberId();
5758

5859
$this->checkForAccessToken();
5960

60-
return $this->httpClient->post($this->messagingFullUrl(), [
61+
$response = $this->httpClient->post($this->messagingFullUrl(), [
6162
'json' => array_merge($data, [
6263
"messaging_product" => "whatsapp",
6364
"recipient_type" => "individual",
6465
])
6566
]);
67+
68+
return Message::create(json_decode($response->getBody()->getContents(), true));
6669
}
6770

6871
/**

0 commit comments

Comments
 (0)