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,222 @@
1
+Telnyx PHP SDK
2
+--------------
3
+
4
+[![Build Status](https://travis-ci.org/team-telnyx/telnyx-php.svg?branch=master)](https://travis-ci.org/team-telnyx/telnyx-php)
5
+[![Latest Stable Version](https://poser.pugx.org/telnyx/telnyx-php/v/stable.svg)](https://packagist.org/packages/telnyx/telnyx-php)
6
+[![Total Downloads](https://poser.pugx.org/telnyx/telnyx-php/downloads.svg)](https://packagist.org/packages/telnyx/telnyx-php)
7
+[![License](https://poser.pugx.org/telnyx/telnyx-php/license.svg)](https://packagist.org/packages/telnyx/telnyx-php)
8
+[![Build](https://travis-ci.org/team-telnyx/telnyx-php.svg?branch=master)](https://travis-ci.org/team-telnyx/telnyx-php)
9
+[![Code Coverage](https://coveralls.io/repos/github/team-telnyx/telnyx-php/badge.svg?branch=master)](https://coveralls.io/github/team-telnyx/telnyx-php?branch=master)
10
+
11
+You can sign up for a Telnyx account at https://telnyx.com.
12
+
13
+
14
+Installation
15
+------------
16
+
17
+This library supports PHP 5.6 and above.
18
+
19
+Installation of this module uses composer. For composer documentation, please refer to
20
+[getcomposer.org](http://getcomposer.org/).
21
+
22
+```bash
23
+$ composer require team-telnyx/telnyx-php
24
+```
25
+
26
+
27
+Dependencies
28
+------------
29
+
30
+Some PHP extensions are required:
31
+
32
+- [`curl`](https://secure.php.net/manual/en/book.curl.php), although you can use your own non-cURL client if you prefer
33
+- [`json`](https://secure.php.net/manual/en/book.json.php)
34
+- [`mbstring`](https://secure.php.net/manual/en/book.mbstring.php) (Multibyte String)
35
+
36
+Composer will handle these dependencies. If you install manually, you'll want to make sure that these extensions are available.
37
+
38
+
39
+Getting Started
40
+---------------
41
+
42
+Basic example:
43
+
44
+```php
45
+use Telnyx;
46
+
47
+Telnyx\Telnyx::setApiKey('sk_test_BQokikJOvBiI2HlWgH4olfQ2');
48
+$order = Telnyx\NumberOrder::create(['phone_number' => '+18665552368']);
49
+echo $order;
50
+```
51
+
52
+
53
+Documentation
54
+-------------
55
+
56
+Please see https://developers.telnyx.com/docs/api/v2/overview for up-to-date documentation.
57
+
58
+
59
+Custom Request Timeouts
60
+-----------------------
61
+
62
+To modify request timeouts (connect or total, in seconds) you'll need to tell the API client to use a CurlClient other than its default. You'll set the timeouts in that CurlClient.
63
+
64
+```php
65
+use Telnyx;
66
+
67
+// set up your tweaked Curl client
68
+$curl = new Telnyx\HttpClient\CurlClient();
69
+$curl->setTimeout(10); // default is Telnyx\HttpClient\CurlClient::DEFAULT_TIMEOUT
70
+$curl->setConnectTimeout(5); // default is Telnyx\HttpClient\CurlClient::DEFAULT_CONNECT_TIMEOUT
71
+
72
+echo $curl->getTimeout(); // 10
73
+echo $curl->getConnectTimeout(); // 5
74
+
75
+// tell Telnyx to use the tweaked client
76
+Telnyx\ApiRequestor::setHttpClient($curl);
77
+
78
+// use the Telnyx API client as you normally would
79
+```
80
+
81
+
82
+Custom cURL Options (proxies)
83
+-----------------------------
84
+
85
+Need to set a proxy for your requests? Pass in the requisite `CURLOPT_*` array to the CurlClient constructor, using the same syntax as `curl_stopt_array()`. This will set the default cURL options for each HTTP request made by the SDK, though many more common options (e.g. timeouts; see above on how to set those) will be overridden by the client even if set here.
86
+
87
+```php
88
+// set up your tweaked Curl client
89
+$curl = new \Telnyx\HttpClient\CurlClient([CURLOPT_PROXY => 'proxy.local:80']);
90
+// tell Telnyx to use the tweaked client
91
+\Telnyx\ApiRequestor::setHttpClient($curl);
92
+```
93
+
94
+Alternately, a callable can be passed to the CurlClient constructor that returns the above array based on request inputs. See `testDefaultOptions()` in `tests/CurlClientTest.php` for an example of this behavior. Note that the callable is called at the beginning of every API request, before the request is sent.
95
+
96
+
97
+Configuring a Logger
98
+--------------------
99
+
100
+The library does minimal logging, but it can be configured
101
+with a [`PSR-3` compatible logger][psr3] so that messages
102
+end up there instead of `error_log`:
103
+
104
+```php
105
+\Telnyx\Telnyx::setLogger($logger);
106
+```
107
+
108
+
109
+Accessing Response Data
110
+-----------------------
111
+
112
+You can access the data from the last API response on any object via `getLastResponse()`.
113
+
114
+```php
115
+$order = \Telnyx\NumberOrder::create(['phone_number' => '+18665552368']);
116
+echo $order->getLastResponse()->headers['Request-Id'];
117
+```
118
+
119
+
120
+SSL / TLS Compatibility issues
121
+------------------------------
122
+
123
+Telnyx's API now requires that all connections use TLS 1.2. Some systems (most notably some older CentOS and RHEL versions) are capable of using TLS 1.2 but will use TLS 1.0 or 1.1 by default.
124
+
125
+The recommended course of action is to upgrade your cURL and OpenSSL packages so that TLS 1.2 is used by default, but if that is not possible, you might be able to solve the issue by setting the `CURLOPT_SSLVERSION` option to either `CURL_SSLVERSION_TLSv1` or `CURL_SSLVERSION_TLSv1_2`:
126
+
127
+```php
128
+$curl = new \Telnyx\HttpClient\CurlClient([CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1]);
129
+\Telnyx\ApiRequestor::setHttpClient($curl);
130
+```
131
+
132
+
133
+Per-request Configuration
134
+-------------------------
135
+
136
+For apps that need to use multiple keys during the lifetime of a process it's also possible to set a
137
+per-request key and/or account:
138
+
139
+```php
140
+\Telnyx\NumberOrder::all([], [
141
+    'api_key' => 'sk_test_...'
142
+]);
143
+
144
+\Telnyx\NumberOrder::retrieve("ch_18atAXCdGbJFKhCuBAa4532Z", [
145
+    'api_key' => 'sk_test_...'
146
+]);
147
+```
148
+
149
+
150
+Automatic Retries
151
+-----------------
152
+
153
+The library can be configured to automatically retry requests that fail due to
154
+an intermittent network problem:
155
+
156
+```php
157
+\Telnyx\Telnyx::setMaxNetworkRetries(2);
158
+```
159
+
160
+Idempotency keys are added to requests to guarantee that
161
+retries are safe.
162
+
163
+
164
+Development
165
+-----------
166
+
167
+Unit tests rely on a mock server so all unit tests are ran through 
168
+docker.  To run all unit tests execute:
169
+
170
+```
171
+docker-compose run --rm php composer test
172
+```
173
+
174
+Running unit tests with code coverage requires you build the docker
175
+composer with XDEBUG=1
176
+
177
+```
178
+docker-compose build --build-arg XDEBUG=1
179
+```
180
+
181
+then run the unit tests as 
182
+
183
+```
184
+docker-compose run --rm php composer test-coverage
185
+```
186
+
187
+
188
+Plugin Developers
189
+-----------------
190
+
191
+Are you writing a plugin that integrates Telnyx and embeds our library? Then please use the `setAppInfo` function to identify your plugin. For example:
192
+
193
+```php
194
+use Telnyx;
195
+
196
+Telnyx\Telnyx::setAppInfo("MyCustomPlugin", "1.2.3", "https://customplugin.yoursite.com");
197
+```
198
+
199
+The method should be called once before any request is sent to the API. The second and third parameters are optional.
200
+
201
+
202
+SSL / TLS Configuration Option
203
+------------------------------
204
+
205
+See the "SSL / TLS compatibility issues" paragraph above for full context. If you want to 
206
+ensure that your plugin can be used on all systems, you should add a configuration option 
207
+to let your users choose between different values for 
208
+`CURLOPT_SSLVERSION`: none (default), `CURL_SSLVERSION_TLSv1` and `CURL_SSLVERSION_TLSv1_2`.
209
+
210
+
211
+Acknowledgments
212
+---------------
213
+
214
+The contributors and maintainers of Telnyx PHP would like to extend their deep gratitude 
215
+to the authors of [Stripe PHP][stripe-php], upon which this project is based. Thank you 
216
+for developing such elegant, usable, and extensible code and for sharing it with the community.
217
+
218
+[stripe-php]: https://github.com/stripe/stripe-php
219
+[composer]: https://getcomposer.org/
220
+[curl]: http://curl.haxx.se/docs/caextract.html
221
+[psr3]: http://www.php-fig.org/psr/psr-3/
222
+