@@ -78,27 +78,35 @@ public function __construct($config)
7878 */
7979 public function call ($ command , $ params = [])
8080 {
81- $ this ->lastError = null ;
81+ $ this ->lastError = null ;
8282 $ this ->lastStatus = null ;
8383 $ this ->lastResult = null ;
8484 if ($ this ->token && !array_key_exists ('ssid ' , $ params )) {
8585 $ params ['ssid ' ] = $ this ->token ;
8686 }
8787 $ responseRaw = $ this ->soaper ->__call ($ command , ['data ' => $ params ]);
88- if ($ responseRaw ['status ' ] == 'error ' ) {
89-
90- $ this ->logError ($ responseRaw ['error ' ]);
91- }
92-
93- if (isset ($ responseRaw ['status ' ])){
88+
89+ if (isset ($ responseRaw ['status ' ])) {
9490 $ this ->lastStatus = $ responseRaw ['status ' ];
91+ if ($ this ->lastStatus == 'error ' ) {
92+ $ this ->logError ($ responseRaw ['error ' ]);
93+ }
94+ }
95+
96+ if (array_key_exists ('data ' , $ responseRaw )) {
97+ $ this ->lastResult = $ responseRaw ['data ' ];
98+ } else {
99+ $ this ->lastResult = $ this ->lastStatus ;
95100 }
96-
97- $ this ->lastResult = array_key_exists ('data ' , $ responseRaw ) ? $ responseRaw ['data ' ] : array_key_exists ('status ' , $ responseRaw ) ? $ responseRaw ['status ' ] : null ;
98-
101+
99102 return $ this ->lastResult ;
100103 }
101104
105+ /**
106+ * log Error
107+ *
108+ * @param array $errorData
109+ */
102110 public function logError ($ errorData )
103111 {
104112 $ this ->lastError = $ errorData ;
@@ -125,4 +133,30 @@ public function login()
125133 }
126134 return $ result ;
127135 }
136+
137+ /**
138+ * Check if domain is available or not
139+ *
140+ * @link https://subreg.cz/manual/?cmd=Check_Domain Command: Check_Domain
141+ *
142+ * @param string $domain
143+ *
144+ * @return array
145+ */
146+ public function checkDomain ($ domain )
147+ {
148+ return $ this ->call ('Check_Domain ' , ['domain ' => $ domain ]);
149+ }
150+
151+ /**
152+ * Get all domains from your account
153+ *
154+ * @link https://subreg.cz/manual/?cmd=Domains_List Command: Domains_List
155+ *
156+ * @return array
157+ */
158+ public function domainsList ()
159+ {
160+ return $ this ->call ('Domains_List ' );
161+ }
128162}
0 commit comments