22
33namespace Tartan \IranianSms \Adapter ;
44
5- class MehrAfraz extends AdapterAbstract implements AdapterInterface {
5+ use SoapClient ;
6+ use Tartan \IranianSms \Exception ;
7+
8+ class MehrAfraz extends AdapterAbstract implements AdapterInterface
9+ {
610
711 public $ gateway_url ;
812
@@ -12,65 +16,61 @@ class MehrAfraz extends AdapterAbstract implements AdapterInterface {
1216 ];
1317
1418 public static $ status_real = [
15- 0 => 'SENDING ' ,
16- 1 => 'SERVICE_DELIVERED ' ,
17- 2 => 'DELIVERED ' ,
18- 3 => 'FAILED ' ,
19- 4 => 'BLACKLIST ' ,
20- 5 => 'NOT_EXPERT ' ,
21- 6 => 'CANCELED ' ,
22- 7 => 'UNKNOWN_DESTINATION ' ,
23- 8 => 'BTS_SENT ' ,
19+ 0 => 'SENDING ' ,
20+ 1 => 'SERVICE_DELIVERED ' ,
21+ 2 => 'DELIVERED ' ,
22+ 3 => 'FAILED ' ,
23+ 4 => 'BLACKLIST ' ,
24+ 5 => 'NOT_EXPERT ' ,
25+ 6 => 'CANCELED ' ,
26+ 7 => 'UNKNOWN_DESTINATION ' ,
27+ 8 => 'BTS_SENT ' ,
2428 12 => 'NOT_SENT_OPERATOR ' ,
2529 16 => 'BTS_ERROR ' ,
2630 ];
2731
28- public function __construct () {
29- $ this ->gateway_url = config ('iranian_sms.mehrafraz.gateway ' );
32+ public function __construct ()
33+ {
34+ $ this ->gateway_url = config ('iranian_sms.mehrafraz.gateway ' );
3035 $ this ->credential ['username ' ] = config ('iranian_sms.mehrafraz.username ' );
3136 $ this ->credential ['password ' ] = config ('iranian_sms.mehrafraz.password ' );
3237 }
3338
34- public function send (String $ number ,String $ message ) {
39+ public function send (String $ number , String $ message )
40+ {
3541
3642 $ number = $ this ->filterNumber ($ number );
3743
3844 $ parameters = [
39- 'cUserName ' => $ this ->credential ['username ' ],
40- 'cPassword ' => $ this ->credential ['password ' ],
41- 'cBody ' => $ message ,
42- 'cSmsnumber ' => $ number ,
43- 'cGetid ' => time (),
44- 'nCMessage ' => '1 ' ,
45- 'nTypeSent ' => '1 ' ,
45+ 'cUserName ' => $ this ->credential ['username ' ],
46+ 'cPassword ' => $ this ->credential ['password ' ],
47+ 'cBody ' => $ message ,
48+ 'cSmsnumber ' => $ number ,
49+ 'cGetid ' => time (),
50+ 'nCMessage ' => '1 ' ,
51+ 'nTypeSent ' => '1 ' ,
4652 'm_SchedulDate ' => '' ,
47- 'cDomainname ' => $ this ->credential ['username ' ],
48- 'nSpeedsms ' => '0 ' ,
49- 'nPeriodmin ' => '0 ' ,
50- 'cstarttime ' => '' ,
51- 'cEndTime ' => '' ,
53+ 'cDomainname ' => $ this ->credential ['username ' ],
54+ 'nSpeedsms ' => '0 ' ,
55+ 'nPeriodmin ' => '0 ' ,
56+ 'cstarttime ' => '' ,
57+ 'cEndTime ' => '' ,
5258 ];
5359
54- try {
55- $ soapParams = [];
56- $ soapParams ['xml_encoding ' ] = "UTF-8 " ;
57- $ soapParams ['soap_defencoding ' ] = "UTF-8 " ;
58- $ soapParams ['decode_utf8 ' ] = false ;
59- $ soapParams ['exceptions ' ] = 1 ;
60- $ soapClient = @new \SoapClient ($ this ->gateway_url , $ soapParams );
61- $ result = $ soapClient ->SendSms ($ parameters );
62- } catch (SoapFault $ client ) {
63- //
64- } catch (Exception $ e ) {
65- //
66- }
60+ $ soapParams = [];
61+ $ soapParams ['xml_encoding ' ] = "UTF-8 " ;
62+ $ soapParams ['soap_defencoding ' ] = "UTF-8 " ;
63+ $ soapParams ['decode_utf8 ' ] = false ;
64+ $ soapParams ['exceptions ' ] = 1 ;
65+ $ soapClient = new SoapClient ($ this ->gateway_url , $ soapParams );
66+ $ result = $ soapClient ->SendSms ($ parameters );
6767
6868
6969 if (($ result ->SendSmsResult && $ result ->SendSmsResult > 1000 )) {
7070 return $ result ->SendSmsResult ;
7171 }
7272
73- throw new \ Exception ("SMS cannot be send! " );
73+ throw new Exception ("SMS cannot be send! " );
7474 }
7575
7676}
0 commit comments