@@ -20,33 +20,33 @@ public function __construct(Client $client)
2020 public function login ($ username , $ secret , $ events = null )
2121 {
2222 $ events = $ this ->boolParam ($ events );
23- return $ this ->client -> request (new Action ( 'Login ' , array ('UserName ' => $ username , 'Secret ' => $ secret , 'Events ' => $ events) ));
23+ return $ this ->request ('Login ' , array ('UserName ' => $ username , 'Secret ' => $ secret , 'Events ' => $ events ));
2424 }
2525
2626 public function logout ()
2727 {
28- return $ this ->client -> request (new Action ( 'Logout ' ) );
28+ return $ this ->request ('Logout ' );
2929 }
3030
3131 public function agentLogoff ($ agentId , $ soft = false )
3232 {
3333 $ bool = $ soft ? 'true ' : 'false ' ;
34- return $ this ->client -> request (new Action ( 'AgentLogoff ' , array ('Agent ' => $ agentId , 'Soft ' => $ bool) ));
34+ return $ this ->request ('AgentLogoff ' , array ('Agent ' => $ agentId , 'Soft ' => $ bool ));
3535 }
3636
3737 public function ping ()
3838 {
39- return $ this ->client -> request (new Action ( 'Ping ' ) );
39+ return $ this ->request ('Ping ' );
4040 }
4141
4242 public function coreShowChannels ()
4343 {
44- return $ this ->client -> request (new Action ( 'CoreShowChannels ' ) );
44+ return $ this ->request ('CoreShowChannels ' );
4545 }
4646
4747 public function command ($ command )
4848 {
49- return $ this ->client -> request (new Action ( 'Command ' , array ('Command ' => $ command) ));
49+ return $ this ->request ('Command ' , array ('Command ' => $ command ));
5050 }
5151
5252 public function events ($ eventMask )
@@ -59,42 +59,42 @@ public function events($eventMask)
5959 $ eventMask = implode (', ' , $ eventMask );
6060 }
6161
62- return $ this ->client -> request (new Action ( 'Events ' , array ('EventMask ' => $ eventMask) ));
62+ return $ this ->request ('Events ' , array ('EventMask ' => $ eventMask ));
6363 }
6464
6565 public function sipPeers ()
6666 {
67- return $ this ->client -> request (new Action ( 'SIPPeers ' ) );
67+ return $ this ->request ('SIPPeers ' );
6868 }
6969
7070 public function sipShowPeer ($ peerName )
7171 {
72- return $ this ->client -> request (new Action ( 'SIPshowpeer ' , array ('Peer ' => $ peerName) ));
72+ return $ this ->request ('SIPshowpeer ' , array ('Peer ' => $ peerName ));
7373 }
7474
7575 public function listCommands ()
7676 {
77- return $ this ->client -> request (new Action ( 'ListCommands ' ) );
77+ return $ this ->request ('ListCommands ' );
7878 }
7979
8080 public function sendText ($ channel , $ message )
8181 {
82- return $ this ->client -> request (new Action ( 'Sendtext ' , array ('Channel ' => $ channel , 'Message ' => $ message) ));
82+ return $ this ->request ('Sendtext ' , array ('Channel ' => $ channel , 'Message ' => $ message ));
8383 }
8484
8585 public function hangup ($ channel , $ cause )
8686 {
87- return $ this ->client -> request (new Action ( 'Hangup ' , array ('Channel ' => $ channel , 'Cause ' => $ cause) ));
87+ return $ this ->request ('Hangup ' , array ('Channel ' => $ channel , 'Cause ' => $ cause ));
8888 }
8989
9090 public function challenge ($ authType = 'MD5 ' )
9191 {
92- return $ this ->client -> request (new Action ( 'Challenge ' , array ('AuthType ' => $ authType) ));
92+ return $ this ->request ('Challenge ' , array ('AuthType ' => $ authType ));
9393 }
9494
9595 public function getConfig ($ filename , $ category = null )
9696 {
97- return $ this ->client -> request (new Action ( 'GetConfig ' , array ('Filename ' => $ filename , 'Category ' => $ category) ));
97+ return $ this ->request ('GetConfig ' , array ('Filename ' => $ filename , 'Category ' => $ category ));
9898 }
9999
100100 private function boolParam ($ value )
@@ -107,4 +107,9 @@ private function boolParam($value)
107107 }
108108 return null ;
109109 }
110+
111+ private function request ($ name , array $ args = array ())
112+ {
113+ return $ this ->client ->request (new Action ($ name , $ args ));
114+ }
110115}
0 commit comments