Browse code

Added README.md appinfo/info.xml appinfo/signature.json lib/Controller/AuthorApiController.php and the providers directory

DoubleBastionAdmin authored on 20/08/2022 16:33:00
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,291 @@
1
+<?php
2
+
3
+namespace Telnyx;
4
+
5
+/**
6
+ * Class Telnyx
7
+ *
8
+ * @package Telnyx
9
+ */
10
+class Telnyx
11
+{
12
+    // @var string The Telnyx API key to be used for requests.
13
+    public static $apiKey;
14
+
15
+    // @var string The Telnyx Public key to be used for webhooks.
16
+    public static $publicKey;
17
+
18
+    // @var string The Telnyx client_id to be used for Connect requests.
19
+    public static $clientId;
20
+
21
+    // @var string The base URL for the Telnyx API.
22
+    public static $apiBase = 'https://api.telnyx.com';
23
+
24
+    // @var string|null The version of the Telnyx API to use for requests.
25
+    public static $apiVersion = null;
26
+
27
+    // @var string|null The account ID for connected accounts requests.
28
+    public static $accountId = null;
29
+
30
+    // @var string Path to the CA bundle used to verify SSL certificates
31
+    public static $caBundlePath = null;
32
+
33
+    // @var boolean Defaults to true.
34
+    public static $verifySslCerts = true;
35
+
36
+    // @var array The application's information (name, version, URL)
37
+    public static $appInfo = null;
38
+
39
+    // @var Util\LoggerInterface|null The logger to which the library will
40
+    //   produce messages.
41
+    public static $logger = null;
42
+
43
+    // @var int Maximum number of request retries
44
+    public static $maxNetworkRetries = 0;
45
+
46
+    // @var boolean Whether client telemetry is enabled. Defaults to false.
47
+    public static $enableTelemetry = false;
48
+
49
+    // @var float Maximum delay between retries, in seconds
50
+    private static $maxNetworkRetryDelay = 2.0;
51
+
52
+    /** @var float Maximum delay between retries, in seconds, that will be respected from the Telnyx API */
53
+    private static $maxRetryAfter = 60.0;
54
+
55
+    // @var float Initial delay between retries, in seconds
56
+    private static $initialNetworkRetryDelay = 0.5;
57
+
58
+    const VERSION = '2.7.0';
59
+
60
+    /**
61
+     * @return string The API key used for requests.
62
+     */
63
+    public static function getApiKey()
64
+    {
65
+        return self::$apiKey;
66
+    }
67
+
68
+    /**
69
+     * @return string The client_id used for Connect requests.
70
+     */
71
+    public static function getClientId()
72
+    {
73
+        return self::$clientId;
74
+    }
75
+
76
+    /**
77
+     * @return Util\LoggerInterface The logger to which the library will
78
+     *   produce messages.
79
+     */
80
+    public static function getLogger()
81
+    {
82
+        if (self::$logger == null) {
83
+            return new Util\DefaultLogger();
84
+        }
85
+        return self::$logger;
86
+    }
87
+
88
+    /**
89
+     * @param Util\LoggerInterface $logger The logger to which the library
90
+     *   will produce messages.
91
+     */
92
+    public static function setLogger($logger)
93
+    {
94
+        self::$logger = $logger;
95
+    }
96
+
97
+    /**
98
+     * Sets the API key to be used for requests.
99
+     *
100
+     * @param string $apiKey
101
+     */
102
+    public static function setApiKey($apiKey)
103
+    {
104
+        self::$apiKey = $apiKey;
105
+    }
106
+
107
+    /**
108
+     * Sets the Public key to be used for webhooks.
109
+     *
110
+     * @param string $apiKey
111
+     */
112
+    public static function setPublicKey($publicKey)
113
+    {
114
+        self::$publicKey = $publicKey;
115
+    }
116
+
117
+    /**
118
+     * @return string The Public key used for webhooks.
119
+     */
120
+    public static function getPublicKey()
121
+    {
122
+        return self::$publicKey;
123
+    }
124
+
125
+    /**
126
+     * Sets the client_id to be used for Connect requests.
127
+     *
128
+     * @param string $clientId
129
+     */
130
+    public static function setClientId($clientId)
131
+    {
132
+        self::$clientId = $clientId;
133
+    }
134
+
135
+    /**
136
+     * @return string The API version used for requests. null if we're using the
137
+     *    latest version.
138
+     */
139
+    public static function getApiVersion()
140
+    {
141
+        return self::$apiVersion;
142
+    }
143
+
144
+    /**
145
+     * @param string $apiVersion The API version to use for requests.
146
+     */
147
+    public static function setApiVersion($apiVersion)
148
+    {
149
+        self::$apiVersion = $apiVersion;
150
+    }
151
+
152
+    /**
153
+     * @return string
154
+     */
155
+    private static function getDefaultCABundlePath()
156
+    {
157
+        return realpath(dirname(__FILE__) . '/../data/ca-certificates.crt');
158
+    }
159
+
160
+    /**
161
+     * @return string
162
+     */
163
+    public static function getCABundlePath()
164
+    {
165
+        return self::$caBundlePath ?: self::getDefaultCABundlePath();
166
+    }
167
+
168
+    /**
169
+     * @param string $caBundlePath
170
+     */
171
+    public static function setCABundlePath($caBundlePath)
172
+    {
173
+        self::$caBundlePath = $caBundlePath;
174
+    }
175
+
176
+    /**
177
+     * @return boolean
178
+     */
179
+    public static function getVerifySslCerts()
180
+    {
181
+        return self::$verifySslCerts;
182
+    }
183
+
184
+    /**
185
+     * @param boolean $verify
186
+     */
187
+    public static function setVerifySslCerts($verify)
188
+    {
189
+        self::$verifySslCerts = $verify;
190
+    }
191
+
192
+    /**
193
+     * @return string | null The Telnyx account ID for connected account
194
+     *   requests.
195
+     */
196
+    public static function getAccountId()
197
+    {
198
+        return self::$accountId;
199
+    }
200
+
201
+    /**
202
+     * @param string $accountId The Telnyx account ID to set for connected
203
+     *   account requests.
204
+     */
205
+    public static function setAccountId($accountId)
206
+    {
207
+        self::$accountId = $accountId;
208
+    }
209
+
210
+    /**
211
+     * @return array | null The application's information
212
+     */
213
+    public static function getAppInfo()
214
+    {
215
+        return self::$appInfo;
216
+    }
217
+
218
+    /**
219
+     * @param string $appName The application's name
220
+     * @param string $appVersion The application's version
221
+     * @param string $appUrl The application's URL
222
+     */
223
+    public static function setAppInfo($appName, $appVersion = null, $appUrl = null, $appPartnerId = null)
224
+    {
225
+        self::$appInfo = self::$appInfo ?: [];
226
+        self::$appInfo['name'] = $appName;
227
+        self::$appInfo['partner_id'] = $appPartnerId;
228
+        self::$appInfo['url'] = $appUrl;
229
+        self::$appInfo['version'] = $appVersion;
230
+    }
231
+
232
+    /**
233
+     * @return int Maximum number of request retries
234
+     */
235
+    public static function getMaxNetworkRetries()
236
+    {
237
+        return self::$maxNetworkRetries;
238
+    }
239
+
240
+    /**
241
+     * @param int $maxNetworkRetries Maximum number of request retries
242
+     */
243
+    public static function setMaxNetworkRetries($maxNetworkRetries)
244
+    {
245
+        self::$maxNetworkRetries = $maxNetworkRetries;
246
+    }
247
+
248
+    /**
249
+     * @return float Maximum delay between retries, in seconds
250
+     */
251
+    public static function getMaxNetworkRetryDelay()
252
+    {
253
+        return self::$maxNetworkRetryDelay;
254
+    }
255
+
256
+    /**
257
+     * @return float Maximum delay between retries, in seconds, that will be respected from the Stripe API
258
+     */
259
+    public static function getMaxRetryAfter()
260
+    {
261
+        return self::$maxRetryAfter;
262
+    }
263
+
264
+    /**
265
+     * @return float Initial delay between retries, in seconds
266
+     */
267
+    public static function getInitialNetworkRetryDelay()
268
+    {
269
+        return self::$initialNetworkRetryDelay;
270
+    }
271
+
272
+    /**
273
+     * @return bool Whether client telemetry is enabled
274
+     */
275
+    public static function getEnableTelemetry()
276
+    {
277
+        return self::$enableTelemetry;
278
+    }
279
+
280
+    /**
281
+     * @param bool $enableTelemetry Enables client telemetry.
282
+     *
283
+     * Client telemetry enables timing and request metrics to be sent back to Telnyx as an HTTP Header
284
+     * with the current request. This enables Telnyx to do latency and metrics analysis without adding extra
285
+     * overhead (such as extra network calls) on the client.
286
+     */
287
+    public static function setEnableTelemetry($enableTelemetry)
288
+    {
289
+        self::$enableTelemetry = $enableTelemetry;
290
+    }
291
+}