PluginProbe ʕ •ᴥ•ʔ
ShareThis Dashboard for Google Analytics / 2.1.2
ShareThis Dashboard for Google Analytics v2.1.2
3.3.2 trunk 1.0.7 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.5 2.3.5 2.3.6 2.3.7 2.3.8 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 3.0.0 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.3.0 3.3.1
googleanalytics / lib / Ga_Lib_Api_Client.php
googleanalytics / lib Last commit date
cert 9 years ago Ga_Lib_Api_Client.php 9 years ago Ga_Lib_Api_Request.php 9 years ago Ga_Lib_Api_Response.php 9 years ago Ga_Lib_Google_Api_Client.php 9 years ago Ga_Lib_Sharethis_Api_Client.php 9 years ago
Ga_Lib_Api_Client.php
75 lines
1 <?php
2
3 abstract class Ga_Lib_Api_Client {
4
5 /**
6 * Keeps error messages.
7 * @var array
8 */
9 protected $errors = array();
10
11 /**
12 * Returns errors array.
13 * @return array
14 */
15 public function get_errors() {
16 return $this->errors;
17 }
18
19 /**
20 * Calls private API method from context client.
21 *
22 * @param $callback
23 * @param $args
24 *
25 * @return Ga_Lib_Api_Response
26 */
27 abstract function call_api_method( $callback, $args );
28
29 /**
30 * Calls api methods.
31 *
32 * @param string $callback
33 * @param mixed $args
34 *
35 * @return mixed
36 */
37 public function call( $callback, $args = null ) {
38 try {
39 return $this->call_api_method( $callback, $args );
40 } catch ( Ga_Lib_Api_Client_Exception $e ) {
41 $this->add_error( $e );
42
43 return new Ga_Lib_Api_Response( Ga_Lib_Api_Response::$empty_response );
44 } catch ( Ga_Lib_Api_Request_Exception $e ) {
45 $this->add_error( $e );
46
47 return new Ga_Lib_Api_Response( Ga_Lib_Api_Response::$empty_response );
48 } catch ( Exception $e ) {
49 $this->add_error( $e );
50
51 return new Ga_Lib_Api_Response( Ga_Lib_Api_Response::$empty_response );
52 }
53 }
54
55 /**
56 * Prepares error data.
57 *
58 * @param Exception $e
59 *
60 */
61 protected function add_error( Exception $e ) {
62 $this->errors[ $e->getCode() ] = array( 'class' => get_class( $e ), 'message' => $e->getMessage() );
63 do_action( 'st_support_save_error', $e );
64 }
65
66 public function add_own_error( $code, $message, $class = '' ) {
67 $this->errors[ $code ] = array( 'class' => $class, 'message' => $message );
68 }
69
70 }
71
72 class Ga_Lib_Api_Client_Exception extends Exception {
73
74 }
75