1 | <?php |
||
55 | class JustGivingClient |
||
56 | { |
||
57 | /** |
||
58 | * The clients that have been instantiated. |
||
59 | * |
||
60 | * @var array |
||
61 | */ |
||
62 | protected $clients = []; |
||
63 | |||
64 | /** |
||
65 | * The client to execute the HTTP requests. |
||
66 | * |
||
67 | * @var ClientInterface |
||
68 | */ |
||
69 | protected $httpClient; |
||
70 | |||
71 | /** |
||
72 | * The root domain of the API. |
||
73 | * |
||
74 | * @var string |
||
75 | */ |
||
76 | protected $rootDomain; |
||
77 | |||
78 | /** |
||
79 | * The API version to use. |
||
80 | * |
||
81 | * @var int |
||
82 | */ |
||
83 | protected $apiVersion; |
||
84 | /** |
||
85 | * @var AuthValue |
||
86 | */ |
||
87 | private $auth; |
||
88 | |||
89 | /** |
||
90 | * JustGivingClient constructor. |
||
91 | * |
||
92 | * @param AuthValue $auth |
||
93 | * @param ClientInterface $client |
||
94 | * @param array $options |
||
95 | */ |
||
96 | 9 | public function __construct(AuthValue $auth, ClientInterface $client, $options = []) |
|
103 | |||
104 | /** |
||
105 | * Proxy a request onto the HTTP client, using the fully qualified URI. |
||
106 | * |
||
107 | * @param string $method |
||
108 | * @param string $uri |
||
109 | * @param array $options |
||
110 | * @return \Psr\Http\Message\ResponseInterface |
||
111 | */ |
||
112 | 9 | public function request($method, $uri, $options = []) |
|
129 | |||
130 | /** |
||
131 | * Build the full URI using the root URI and API version. |
||
132 | * |
||
133 | * @param string $uri |
||
134 | * @return string |
||
135 | */ |
||
136 | 9 | private function buildUri($uri) |
|
140 | |||
141 | /** |
||
142 | * Merge the per-request headers with the auth headers. |
||
143 | * |
||
144 | * @param array $requestHeaders |
||
145 | * @return array |
||
146 | */ |
||
147 | 9 | private function buildHeaders($requestHeaders) |
|
153 | |||
154 | /** |
||
155 | * Allow API classes to be called as properties. Return a singleton client class. |
||
156 | * |
||
157 | * @param string $property |
||
158 | * @return mixed |
||
159 | * @throws \Exception |
||
160 | */ |
||
161 | 9 | public function __get($property) |
|
175 | } |
||
176 |