@@ -19,7 +19,7 @@ class Client extends \Ease\Molecule
1919 * ClientLibrary version
2020 * @var string
2121 */
22- static public $ frameworkVersion = '0.1 ' ;
22+ static public $ libVersion = '0.3 ' ;
2323
2424 /**
2525 * Object Configuration
@@ -74,6 +74,20 @@ public function __construct($config)
7474 $ this ->login ();
7575 }
7676
77+ /**
78+ * Add Info about used user, server and libraries
79+ *
80+ * @param string $additions Additional note text
81+ *
82+ * @return boolean was logged ?
83+ */
84+ public function logBanner ($ additions = null )
85+ {
86+ return $ this ->addStatusMessage ('API ' .str_replace (':// ' ,
87+ ':// ' .$ this ->config ['login ' ].'@ ' , $ this ->config ['uri ' ]).' php-subreg v ' .self ::$ libVersion .' EasePHP Framework v ' .\Ease \Atom::$ frameworkVersion .' ' .$ additions ,
88+ 'debug ' );
89+ }
90+
7791 /**
7892 * API Call
7993 *
@@ -92,19 +106,24 @@ public function call($command, $params = [])
92106 }
93107 $ responseRaw = $ this ->soaper ->__call ($ command , ['data ' => $ params ]);
94108
109+
95110 if (isset ($ responseRaw ['status ' ])) {
96111 $ this ->lastStatus = $ responseRaw ['status ' ];
97- if ($ this ->lastStatus == 'error ' ) {
98- $ this ->logError ($ responseRaw ['error ' ]);
112+ switch ($ responseRaw ['status ' ]) {
113+ case 'ok ' :
114+ if (array_key_exists ('data ' , $ responseRaw )) {
115+ $ this ->lastResult = $ responseRaw ['data ' ];
116+ } else {
117+ $ this ->lastResult = $ this ->lastStatus ;
118+ }
119+ break ;
120+ case 'error ' :
121+ $ this ->logError ($ responseRaw ['error ' ]);
122+ $ this ->lastResult = ['error ' => $ responseRaw ['error ' ]];
123+ break ;
99124 }
100125 }
101126
102- if (array_key_exists ('data ' , $ responseRaw )) {
103- $ this ->lastResult = $ responseRaw ['data ' ];
104- } else {
105- $ this ->lastResult = $ this ->lastStatus ;
106- }
107-
108127 return $ this ->lastResult ;
109128 }
110129
@@ -222,4 +241,16 @@ public function domainsList()
222241 {
223242 return $ this ->call ('Domains_List ' );
224243 }
244+
245+ /**
246+ * Get pricelist from your account
247+ *
248+ * @link https://subreg.cz/manual/?cmd=Pricelist Command: Pricelist
249+ *
250+ * @return array
251+ */
252+ public function pricelist ()
253+ {
254+ return $ this ->call ('Pricelist ' );
255+ }
225256}
0 commit comments