@@ -78,27 +78,35 @@ public function __construct($config)
78
78
*/
79
79
public function call ($ command , $ params = [])
80
80
{
81
- $ this ->lastError = null ;
81
+ $ this ->lastError = null ;
82
82
$ this ->lastStatus = null ;
83
83
$ this ->lastResult = null ;
84
84
if ($ this ->token && !array_key_exists ('ssid ' , $ params )) {
85
85
$ params ['ssid ' ] = $ this ->token ;
86
86
}
87
87
$ 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 ' ])) {
94
90
$ 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 ;
95
100
}
96
-
97
- $ this ->lastResult = array_key_exists ('data ' , $ responseRaw ) ? $ responseRaw ['data ' ] : array_key_exists ('status ' , $ responseRaw ) ? $ responseRaw ['status ' ] : null ;
98
-
101
+
99
102
return $ this ->lastResult ;
100
103
}
101
104
105
+ /**
106
+ * log Error
107
+ *
108
+ * @param array $errorData
109
+ */
102
110
public function logError ($ errorData )
103
111
{
104
112
$ this ->lastError = $ errorData ;
@@ -125,4 +133,30 @@ public function login()
125
133
}
126
134
return $ result ;
127
135
}
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
+ }
128
162
}
0 commit comments