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