File tree 2 files changed +25
-0
lines changed
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()
47
47
return new self ($ serverRequest );
48
48
}
49
49
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
+
50
61
public function getRequestData ($ sent = true )
51
62
{
52
63
$ request = $ this ->getRequest ();
Original file line number Diff line number Diff line change @@ -109,6 +109,20 @@ public function testResponseArrayAccess($response)
109
109
$ this ->assertEquals ('US-VIRTUAL-BANDWIDTH ' , $ message ['network ' ]);
110
110
}
111
111
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
+
112
126
public function getResponses ()
113
127
{
114
128
return [
You can’t perform that action at this time.
0 commit comments