1 | <?php |
||
14 | class Facade |
||
15 | { |
||
16 | /** |
||
17 | * @var CredentialsInterface |
||
18 | */ |
||
19 | private static $credentials; |
||
20 | /** |
||
21 | * @var TransportInterface |
||
22 | */ |
||
23 | private static $transport; |
||
24 | /** |
||
25 | * @var PublicAPIClient |
||
26 | */ |
||
27 | private static $client; |
||
28 | /** |
||
29 | * @var LoggerInterface|null |
||
30 | */ |
||
31 | private static $logger; |
||
32 | |||
33 | /** |
||
34 | * @var string|null |
||
35 | */ |
||
36 | private static $url = null; |
||
37 | |||
38 | /** |
||
39 | * Set logger |
||
40 | * |
||
41 | * @param LoggerInterface $logger |
||
42 | */ |
||
43 | public static function setLogger(LoggerInterface $logger) |
||
47 | |||
48 | /** |
||
49 | * Sets (or replaces) credentials |
||
50 | * |
||
51 | * @param CredentialsInterface $credentials |
||
52 | */ |
||
53 | public static function setCredentials(CredentialsInterface $credentials) |
||
57 | |||
58 | /** |
||
59 | * Sets (or replaces) transport |
||
60 | * |
||
61 | * @param TransportInterface $transport |
||
62 | */ |
||
63 | public static function setTransport(TransportInterface $transport) |
||
67 | |||
68 | /** |
||
69 | * Set custom Covery url |
||
70 | * |
||
71 | * @param string $url |
||
72 | */ |
||
73 | public static function setOverrideUrl($url) |
||
77 | |||
78 | /** |
||
79 | * Utility method to take client |
||
80 | * |
||
81 | * @return PublicAPIClient |
||
82 | * @throws Exception |
||
83 | */ |
||
84 | private static function getClient() |
||
96 | |||
97 | /** |
||
98 | * Sends request to Covery and returns access level, associated with |
||
99 | * used credentials |
||
100 | * |
||
101 | * This method can be used for Covery health check and availability |
||
102 | * On any problem (network, credentials, server side) this method |
||
103 | * will throw an exception |
||
104 | * |
||
105 | * @return mixed |
||
106 | * @throws Exception |
||
107 | */ |
||
108 | public static function ping() |
||
112 | |||
113 | /** |
||
114 | * Sends envelope to Covery and returns it's ID on Covery side |
||
115 | * Before sending, validation is performed |
||
116 | * |
||
117 | * @param EnvelopeInterface $envelope |
||
118 | * @return int |
||
119 | * @throws Exception |
||
120 | */ |
||
121 | public static function sendEvent(EnvelopeInterface $envelope) |
||
125 | |||
126 | /** |
||
127 | * Sends envelope to Covery for analysis |
||
128 | * |
||
129 | * @param EnvelopeInterface $envelope |
||
130 | * @return Result |
||
131 | * @throws Exception |
||
132 | */ |
||
133 | public static function makeDecision(EnvelopeInterface $envelope) |
||
137 | } |
||
138 |