|
12 | 12 |
|
13 | 13 | class SecureNative |
14 | 14 | { |
15 | | - private static $apiKey; |
16 | | - private static $options; |
17 | | - private static $eventManager; |
18 | | - private static $middleware; |
| 15 | + private static $apiKey; |
| 16 | + private static $options; |
| 17 | + private static $eventManager; |
| 18 | + private static $middleware; |
19 | 19 |
|
20 | | - public static function init($apiKey, SecureNativeOptions $secureNativeOptions) |
21 | | - { |
22 | | - if ($apiKey == '') { |
23 | | - throw new Exception('You must pass your SecureNative api key'); |
24 | | - } |
| 20 | + public static function init($apiKey, SecureNativeOptions $secureNativeOptions) |
| 21 | + { |
| 22 | + if ($apiKey == '') { |
| 23 | + throw new Exception('You must pass your SecureNative api key'); |
| 24 | + } |
25 | 25 |
|
26 | | - self::$apiKey = $apiKey; |
27 | | - self::$options = $secureNativeOptions; |
28 | | - self::$eventManager = new EventManager($apiKey, self::$options); |
29 | | - self::$middleware = new Middleware($apiKey); |
30 | | - } |
| 26 | + self::$apiKey = $apiKey; |
| 27 | + self::$options = $secureNativeOptions; |
| 28 | + self::$eventManager = new EventManager($apiKey, self::$options); |
| 29 | + self::$middleware = new Middleware($apiKey); |
| 30 | + } |
| 31 | + |
| 32 | + public static function track(Array $attributes) |
| 33 | + { |
| 34 | + $opts = new EventOptions(json_encode($attributes)); |
| 35 | + if (count($opts->params) > MAX_CUSTOM_PARAMS) { |
| 36 | + throw new Exception(sprintf('You can only specify maximum of %d params', MAX_CUSTOM_PARAMS)); |
| 37 | + } |
31 | 38 |
|
32 | | - public static function track(Array $attributes) |
33 | | - { |
34 | | - $opts = new EventOptions(json_encode($attributes)); |
35 | | - if (count($opts->params) > MAX_CUSTOM_PARAMS) { |
36 | | - throw new Exception(sprintf('You can only specify maximum of %d params', MAX_CUSTOM_PARAMS)); |
| 39 | + $requestUrl = sprintf('%s/track', self::$options->getApiUrl()); |
| 40 | + $event = self::$eventManager->buildEvent($opts); |
| 41 | + self::$eventManager->sendAsync($event, $requestUrl); |
37 | 42 | } |
38 | 43 |
|
39 | | - $requestUrl = sprintf('%s/track', self::$options->getApiUrl()); |
40 | | - $event = self::$eventManager->buildEvent($opts); |
41 | | - self::$eventManager->sendAsync($event, $requestUrl); |
42 | | - } |
| 44 | + public static function verify(Array $attributes) |
| 45 | + { |
| 46 | + $opts = new EventOptions(json_encode($attributes)); |
| 47 | + $requestUrl = sprintf('%s/verify', self::$options->getApiUrl()); |
| 48 | + $event = self::$eventManager->buildEvent($opts); |
| 49 | + $result = self::$eventManager->sendSync($event, $requestUrl); |
| 50 | + |
| 51 | + if ($result == null) { |
| 52 | + return new VerifyResult(); |
| 53 | + } |
43 | 54 |
|
44 | | - public static function verify(Array $attributes) |
45 | | - { |
46 | | - $opts = new EventOptions(json_encode($attributes)); |
47 | | - $requestUrl = sprintf('%s/verify', self::$options->getApiUrl()); |
48 | | - $event = self::$eventManager->buildEvent($opts); |
49 | | - $result = self::$eventManager->sendSync($event, $requestUrl); |
50 | | - |
51 | | - if($result == null){ |
52 | | - return new VerifyResult(); |
| 55 | + return $result; |
53 | 56 | } |
54 | 57 |
|
55 | | - return $result; |
56 | | - } |
| 58 | + public static function flow($flowId, Array $attributes) |
| 59 | + { |
| 60 | + $opts = new EventOptions(json_encode($attributes)); |
| 61 | + $requestUrl = sprintf('%s/flow/%s', self::$options->getApiUrl(), $flowId); |
| 62 | + $event = self::$eventManager->buildEvent($opts); |
| 63 | + return self::$eventManager->sendSync($event, $requestUrl); |
| 64 | + } |
57 | 65 |
|
58 | | - public static function flow($flowId, Array $attributes) |
59 | | - { |
60 | | - $opts = new EventOptions(json_encode($attributes)); |
61 | | - $requestUrl = sprintf('%s/flow/%s', self::$options->getApiUrl(), $flowId); |
62 | | - $event = self::$eventManager->buildEvent($opts); |
63 | | - return self::$eventManager->sendSync($event, $requestUrl); |
64 | | - } |
| 66 | + public static function getMiddleware() |
| 67 | + { |
| 68 | + return self::$middleware; |
| 69 | + } |
65 | 70 | } |
0 commit comments