PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 260805
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v260805
260917 260913 260909 260829 260814 260805 110710 110731 110812 110815 110912 110913 110915 110926 110927 111002 111003 111011 111017 111029 111105 111206 111216 111220 120213 All 189 releases
s2member / src / includes / externals / aweber / exceptions.php

exceptions.php in s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions 260805, at src/includes/externals/aweber/exceptions.php

132 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // @codingStandardsIgnoreFile
3
4 class AWeberException extends Exception { }
5
6 /**
7 * Thrown when the API returns an error. (HTTP status >= 400)
8 *
9 *
10 * @uses AWeberException
11 * @package
12 * @version $id$
13 */
14 class AWeberAPIException extends AWeberException {
15
16 public $type;
17 public $status;
18 public $message;
19 public $documentation_url;
20 public $url;
21
22 public function __construct($error, $url) {
23 // record specific details of the API exception for processing
24 $this->url = $url;
25 $this->type = $error['type'];
26 $this->status = array_key_exists('status', $error) ? $error['status'] : '';
27 $this->message = $error['message'];
28 $this->documentation_url = $error['documentation_url'];
29
30 parent::__construct($this->message);
31 }
32 }
33
34 /**
35 * Thrown when attempting to use a resource that is not implemented.
36 *
37 * @uses AWeberException
38 * @package
39 * @version $id$
40 */
41 class AWeberResourceNotImplemented extends AWeberException {
42
43 public function __construct($object, $value) {
44 $this->object = $object;
45 $this->value = $value;
46 parent::__construct("Resource \"{$value}\" is not implemented on this resource.");
47 }
48 }
49
50 /**
51 * AWeberMethodNotImplemented
52 *
53 * Thrown when attempting to call a method that is not implemented for a resource
54 * / collection. Differs from standard method not defined errors, as this will
55 * be thrown when the method is infact implemented on the base class, but the
56 * current resource type does not provide access to that method (ie calling
57 * getByMessageNumber on a web_forms collection).
58 *
59 * @uses AWeberException
60 * @package
61 * @version $id$
62 */
63 class AWeberMethodNotImplemented extends AWeberException {
64
65 public function __construct($object) {
66 $this->object = $object;
67 parent::__construct("This method is not implemented by the current resource.");
68
69 }
70 }
71
72 /**
73 * AWeberOAuthException
74 *
75 * OAuth exception, as generated by an API JSON error response
76 * @uses AWeberException
77 * @package
78 * @version $id$
79 */
80 class AWeberOAuthException extends AWeberException {
81
82 public function __construct($type, $message) {
83 $this->type = $type;
84 $this->message = $message;
85 parent::__construct("{$type}: {$message}");
86 }
87 }
88
89 /**
90 * AWeberOAuthDataMissing
91 *
92 * Used when a specific piece or pieces of data was not found in the
93 * response. This differs from the exception that might be thrown as
94 * an AWeberOAuthException when parameters are not provided because
95 * it is not the servers' expectations that were not met, but rather
96 * the expecations of the client were not met by the server.
97 *
98 * @uses AWeberException
99 * @package
100 * @version $id$
101 */
102 class AWeberOAuthDataMissing extends AWeberException {
103
104 public function __construct($missing) {
105 if (!is_array($missing)) $missing = array($missing);
106 $this->missing = $missing;
107 $required = join(', ', $this->missing);
108 parent::__construct("OAuthDataMissing: Response was expected to contain: {$required}");
109
110 }
111 }
112
113 /**
114 * AWeberResponseError
115 *
116 * This is raised when the server returns a non-JSON response. This
117 * should only occur when there is a server or some type of connectivity
118 * issue.
119 *
120 * @uses AWeberException
121 * @package
122 * @version $id$
123 */
124 class AWeberResponseError extends AWeberException {
125
126 public function __construct($uri) {
127 $this->uri = $uri;
128 parent::__construct("Request for {$uri} did not respond properly.");
129 }
130
131 }
132