1 | <?php |
||
40 | class Gigya |
||
41 | { |
||
42 | const DC_EU = 'eu1'; |
||
43 | const DC_US = 'us1'; |
||
44 | const DC_AU = 'au1'; |
||
45 | |||
46 | const NAMESPACE_AUDIT = 'audit'; |
||
47 | const NAMESPACE_ACCOUNTS = 'accounts'; |
||
48 | const NAMESPACE_ACCOUNTS_TFA = 'accounts.tfa'; |
||
49 | const NAMESPACE_SOCIALIZE = 'socialize'; |
||
50 | const NAMESPACE_COMMENTS = 'comments'; |
||
51 | const NAMESPACE_GAME_MECHANICS = 'gm'; |
||
52 | const NAMESPACE_REPORTS = 'reports'; |
||
53 | const NAMESPACE_DATA_STORE = 'ds'; |
||
54 | const NAMESPACE_IDENTITY_STORAGE = 'ids'; |
||
55 | const NAMESPACE_FIDM = 'fidm'; |
||
56 | const NAMESPACE_FIDM_SAML = 'fidm.saml'; |
||
57 | const NAMESPACE_FIDM_SAML_IDP = 'fidm.saml.idp'; |
||
58 | |||
59 | const CERTIFICATE_FILE = 'cacert.pem'; |
||
60 | |||
61 | const DATE_TIME_FORMAT = 'Y-m-d\TH:i:s.uP'; |
||
62 | |||
63 | /** |
||
64 | * Data Center ID to use. |
||
65 | * |
||
66 | * - us1 - for the US datacenter |
||
67 | * - eu1 - for the European datacenter |
||
68 | * - au1 - for the Australian datacenter |
||
69 | * |
||
70 | * @var string (Default: eu1) |
||
71 | */ |
||
72 | protected $dataCenter; |
||
73 | |||
74 | /** |
||
75 | * Collection of core options to be passed to each api request. |
||
76 | * |
||
77 | * @var array |
||
78 | */ |
||
79 | protected $options = []; |
||
80 | |||
81 | /** |
||
82 | * Configuration to pass to the constructor of guzzle. |
||
83 | * |
||
84 | * @var array |
||
85 | */ |
||
86 | protected $config = []; |
||
87 | |||
88 | /** |
||
89 | * @var ResponseValidatorInterface[] |
||
90 | */ |
||
91 | protected $validators = []; |
||
92 | |||
93 | /** |
||
94 | * @var ResponseFactoryInterface |
||
95 | */ |
||
96 | protected $factory = null; |
||
97 | |||
98 | /** |
||
99 | * @var ClientInterface |
||
100 | */ |
||
101 | private $guzzle; |
||
102 | |||
103 | /** |
||
104 | * @var HandlerStack |
||
105 | */ |
||
106 | private $handlerStack; |
||
107 | |||
108 | /** |
||
109 | * @param string $apiKey |
||
110 | * @param string $secretKey |
||
111 | * @param string|null $dataCenter |
||
112 | * @param string|null $userKey |
||
113 | * @param array $config Gigya configuration: |
||
114 | * - auth <string> (Default: gigya) Type of authentication, gigya |
||
115 | * (HttpsAuthMiddleware) is the default. 'credentials' provides |
||
116 | * `client_id,client_secret` params, 'gigya-oauth2' uses an oauth2 access token |
||
117 | * - uidValidator <bool> (Default: true) Include Uid Signature Validation |
||
118 | * - factory <object> (Default: null) A ResponseFactoryInterface to use, if none is |
||
119 | * provided ResponseFactory will be used |
||
120 | * - guzzle <array> (Default: []) A configuration to pass to guzzle if required |
||
121 | * - options <array> (Default: []) A set of options to pass to each request |
||
122 | */ |
||
123 | 48 | public function __construct($apiKey, $secretKey, $dataCenter = null, $userKey = null, array $config = []) |
|
162 | |||
163 | /** |
||
164 | * Add an option to be passed through to Guzzle for the request. |
||
165 | * |
||
166 | * N.B. This will overwrite any existing options apart from query and verify |
||
167 | * |
||
168 | * @param string $option |
||
169 | * @param mixed $value |
||
170 | * |
||
171 | * @return $this |
||
172 | */ |
||
173 | 48 | public function addOption($option, $value) |
|
179 | |||
180 | /** |
||
181 | * Add a set of options as key value pairs. These will be passed to the Guzzle request. |
||
182 | * |
||
183 | * N.B. This will overwrite any existing options apart from query and verify |
||
184 | * |
||
185 | * @param array $options |
||
186 | * |
||
187 | * @return $this |
||
188 | */ |
||
189 | 5 | public function addOptions(array $options) |
|
197 | |||
198 | /** |
||
199 | * @param ResponseValidatorInterface $validator |
||
200 | * |
||
201 | * @return $this |
||
202 | */ |
||
203 | 10 | public function addValidator(ResponseValidatorInterface $validator) |
|
209 | |||
210 | /** |
||
211 | * @param callable $handler |
||
212 | * |
||
213 | * @return $this |
||
214 | */ |
||
215 | 48 | public function addHandler(callable $handler) |
|
221 | |||
222 | /** |
||
223 | * @param callable $handler |
||
224 | * |
||
225 | * @return $this |
||
226 | */ |
||
227 | 2 | public function removeHandler(callable $handler) |
|
233 | |||
234 | /** |
||
235 | * @param ResponseFactoryInterface $factory |
||
236 | * |
||
237 | * @return $this |
||
238 | */ |
||
239 | 41 | public function setFactory(ResponseFactoryInterface $factory) |
|
245 | |||
246 | /** |
||
247 | * @param string $method |
||
248 | * @param array $arguments |
||
249 | * |
||
250 | * @return Client |
||
251 | */ |
||
252 | 7 | public function __call($method, array $arguments) |
|
260 | |||
261 | /** |
||
262 | * @param string $namespace |
||
263 | * @param string $className |
||
264 | * |
||
265 | * @return Client |
||
266 | */ |
||
267 | 47 | private function endpointFactory($namespace, $className = Client::class) |
|
279 | |||
280 | /** |
||
281 | * @return Accounts |
||
282 | */ |
||
283 | 30 | public function accounts() |
|
287 | |||
288 | /** |
||
289 | * @return Audit |
||
290 | */ |
||
291 | 1 | public function audit() |
|
295 | |||
296 | /** |
||
297 | * @return Socialize |
||
298 | */ |
||
299 | 2 | public function socialize() |
|
303 | |||
304 | /** |
||
305 | * @return Comments |
||
306 | */ |
||
307 | 1 | public function comments() |
|
311 | |||
312 | /** |
||
313 | * @return GameMechanics |
||
314 | */ |
||
315 | 1 | public function gameMechanics() |
|
319 | |||
320 | /** |
||
321 | * @return Reports |
||
322 | */ |
||
323 | 1 | public function reports() |
|
327 | |||
328 | /** |
||
329 | * @return DataStore |
||
330 | */ |
||
331 | 1 | public function dataStore() |
|
335 | |||
336 | /** |
||
337 | * @return IdentityStorage |
||
338 | */ |
||
339 | 1 | public function identityStorage() |
|
343 | |||
344 | /** |
||
345 | * @return Saml |
||
346 | */ |
||
347 | 3 | public function saml() |
|
351 | } |
||
352 |