File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,17 @@ public static function createFromGlobals()
4747 return new self ($ serverRequest );
4848 }
4949
50+ /**
51+ * Create a matching reply to the inbound message. Currently only supports text replies.
52+ *
53+ * @param string $body
54+ * @return Text
55+ */
56+ public function createReply ($ body )
57+ {
58+ return new Text ($ this ->getFrom (), $ this ->getTo (), $ body );
59+ }
60+
5061 public function getRequestData ($ sent = true )
5162 {
5263 $ request = $ this ->getRequest ();
Original file line number Diff line number Diff line change @@ -109,6 +109,20 @@ public function testResponseArrayAccess($response)
109109 $ this ->assertEquals ('US-VIRTUAL-BANDWIDTH ' , $ message ['network ' ]);
110110 }
111111
112+ public function testCanCreateReply ()
113+ {
114+ $ message = new InboundMessage ($ this ->getServerRequest ());
115+
116+ $ reply = $ message ->createReply ('this is a reply ' );
117+ $ this ->assertInstanceOf ('Nexmo\Message\Message ' , $ reply );
118+
119+ $ params = $ reply ->getRequestData (false );
120+
121+ $ this ->assertEquals ('14845552121 ' , $ params ['to ' ]);
122+ $ this ->assertEquals ('16105553939 ' , $ params ['from ' ]);
123+ $ this ->assertEquals ('this is a reply ' , $ params ['text ' ]);
124+ }
125+
112126 public function getResponses ()
113127 {
114128 return [
You can’t perform that action at this time.
0 commit comments