PluginProbe ʕ •ᴥ•ʔ
ShareThis Dashboard for Google Analytics / 3.1.7
ShareThis Dashboard for Google Analytics v3.1.7
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 / class-ga-lib-api-client.php
googleanalytics / lib Last commit date
analytics-admin 3 years ago class-ga-lib-api-client-exception.php 4 years ago class-ga-lib-api-client.php 4 years ago class-ga-lib-api-request-exception.php 4 years ago class-ga-lib-api-request.php 4 years ago class-ga-lib-api-response.php 4 years ago class-ga-lib-google-api-client-accountsummaries-exception.php 4 years ago class-ga-lib-google-api-client-authcode-exception.php 4 years ago class-ga-lib-google-api-client-data-exception.php 4 years ago class-ga-lib-google-api-client-exception.php 4 years ago class-ga-lib-google-api-client-refreshtoken-exception.php 4 years ago class-ga-lib-google-api-client.php 3 years ago class-ga-lib-sharethis-api-client-alerts-exception.php 4 years ago class-ga-lib-sharethis-api-client-exception.php 4 years ago class-ga-lib-sharethis-api-client-invaliddomain-exception.php 4 years ago class-ga-lib-sharethis-api-client-invite-exception.php 4 years ago class-ga-lib-sharethis-api-client-verify-exception.php 4 years ago class-ga-lib-sharethis-api-client.php 4 years ago
class-ga-lib-api-client.php
95 lines
1 <?php
2 /**
3 * Google API Client.
4 *
5 * @package GoogleAnalytics
6 */
7
8 /**
9 * Google API Client.
10 */
11 abstract class Ga_Lib_Api_Client {
12
13 /**
14 * Keeps error messages.
15 *
16 * @var array
17 */
18 protected $errors = array();
19
20 /**
21 * Returns errors array.
22 *
23 * @return array
24 */
25 public function get_errors() {
26 return $this->errors;
27 }
28
29 /**
30 * Calls private API method from context client.
31 *
32 * @param callable $callback Callable function.
33 * @param array $args Array of arguments.
34 *
35 * @return Ga_Lib_Api_Response
36 */
37 abstract public function call_api_method( $callback, $args );
38
39 /**
40 * Calls api methods.
41 *
42 * @param string $callback Callback method name.
43 * @param mixed $args Arguments.
44 *
45 * @return mixed
46 */
47 public function call( $callback, $args = null ) {
48 try {
49 delete_option( 'googleanalytics_sherethis_error_log' );
50 return $this->call_api_method( $callback, $args );
51 } catch ( Ga_Lib_Api_Client_Exception $e ) {
52 $this->add_error( $e );
53
54 return new Ga_Lib_Api_Response( Ga_Lib_Api_Response::$empty_response );
55 } catch ( Ga_Lib_Api_Request_Exception $e ) {
56 $this->add_error( $e );
57
58 return new Ga_Lib_Api_Response( Ga_Lib_Api_Response::$empty_response );
59 } catch ( Exception $e ) {
60 $this->add_error( $e );
61
62 return new Ga_Lib_Api_Response( Ga_Lib_Api_Response::$empty_response );
63 }
64 }
65
66 /**
67 * Prepares error data.
68 *
69 * @param Exception $e Exception.
70 */
71 protected function add_error( Exception $e ) {
72 $this->errors[ $e->getCode() ] = array(
73 'class' => get_class( $e ),
74 'message' => $e->getMessage(),
75 );
76 do_action( 'st_support_save_error', $e );
77 }
78
79 /**
80 * Add own error.
81 *
82 * @param string $code Code string.
83 * @param string $message Message.
84 * @param string $class Class name.
85 *
86 * @return void
87 */
88 public function add_own_error( $code, $message, $class = '' ) {
89 $this->errors[ $code ] = array(
90 'class' => $class,
91 'message' => $message,
92 );
93 }
94 }
95