teleleo 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +121 -10
  3. package/api.md +130 -112
  4. package/dist/client.d.ts +3 -1
  5. package/dist/client.d.ts.map +1 -1
  6. package/dist/client.js +5 -2
  7. package/dist/client.js.map +1 -1
  8. package/dist/core.d.ts +14 -3
  9. package/dist/core.d.ts.map +1 -1
  10. package/dist/core.js +19 -6
  11. package/dist/core.js.map +1 -1
  12. package/dist/errors.d.ts +23 -5
  13. package/dist/errors.d.ts.map +1 -1
  14. package/dist/errors.js +23 -5
  15. package/dist/errors.js.map +1 -1
  16. package/dist/resources/call-scenarios.d.ts +15 -3
  17. package/dist/resources/call-scenarios.d.ts.map +1 -1
  18. package/dist/resources/call-scenarios.js +15 -3
  19. package/dist/resources/call-scenarios.js.map +1 -1
  20. package/dist/resources/calls.d.ts +26 -6
  21. package/dist/resources/calls.d.ts.map +1 -1
  22. package/dist/resources/calls.js +29 -5
  23. package/dist/resources/calls.js.map +1 -1
  24. package/dist/resources/contact-groups.d.ts +15 -5
  25. package/dist/resources/contact-groups.d.ts.map +1 -1
  26. package/dist/resources/contact-groups.js +15 -5
  27. package/dist/resources/contact-groups.js.map +1 -1
  28. package/dist/resources/contacts.d.ts +18 -6
  29. package/dist/resources/contacts.d.ts.map +1 -1
  30. package/dist/resources/contacts.js +18 -6
  31. package/dist/resources/contacts.js.map +1 -1
  32. package/dist/resources/dongles.d.ts +87 -15
  33. package/dist/resources/dongles.d.ts.map +1 -1
  34. package/dist/resources/dongles.js +103 -13
  35. package/dist/resources/dongles.js.map +1 -1
  36. package/dist/resources/files.d.ts +14 -6
  37. package/dist/resources/files.d.ts.map +1 -1
  38. package/dist/resources/files.js +14 -6
  39. package/dist/resources/files.js.map +1 -1
  40. package/dist/resources/follow-up-sms-settings.d.ts +14 -4
  41. package/dist/resources/follow-up-sms-settings.d.ts.map +1 -1
  42. package/dist/resources/follow-up-sms-settings.js +14 -4
  43. package/dist/resources/follow-up-sms-settings.js.map +1 -1
  44. package/dist/resources/index.d.ts +7 -2
  45. package/dist/resources/index.d.ts.map +1 -1
  46. package/dist/resources/index.js +3 -1
  47. package/dist/resources/index.js.map +1 -1
  48. package/dist/resources/mailings.d.ts +21 -7
  49. package/dist/resources/mailings.d.ts.map +1 -1
  50. package/dist/resources/mailings.js +21 -7
  51. package/dist/resources/mailings.js.map +1 -1
  52. package/dist/resources/plans.d.ts +20 -0
  53. package/dist/resources/plans.d.ts.map +1 -0
  54. package/dist/resources/plans.js +22 -0
  55. package/dist/resources/plans.js.map +1 -0
  56. package/dist/resources/public-vpn.d.ts +11 -1
  57. package/dist/resources/public-vpn.d.ts.map +1 -1
  58. package/dist/resources/public-vpn.js +11 -1
  59. package/dist/resources/public-vpn.js.map +1 -1
  60. package/dist/resources/redirections.d.ts +15 -5
  61. package/dist/resources/redirections.d.ts.map +1 -1
  62. package/dist/resources/redirections.js +15 -5
  63. package/dist/resources/redirections.js.map +1 -1
  64. package/dist/resources/sip-users.d.ts +6 -2
  65. package/dist/resources/sip-users.d.ts.map +1 -1
  66. package/dist/resources/sip-users.js +6 -2
  67. package/dist/resources/sip-users.js.map +1 -1
  68. package/dist/resources/sms.d.ts +28 -10
  69. package/dist/resources/sms.d.ts.map +1 -1
  70. package/dist/resources/sms.js +28 -10
  71. package/dist/resources/sms.js.map +1 -1
  72. package/dist/resources/socks-proxies.d.ts +13 -3
  73. package/dist/resources/socks-proxies.d.ts.map +1 -1
  74. package/dist/resources/socks-proxies.js +13 -3
  75. package/dist/resources/socks-proxies.js.map +1 -1
  76. package/dist/resources/ussd.d.ts +15 -5
  77. package/dist/resources/ussd.d.ts.map +1 -1
  78. package/dist/resources/ussd.js +15 -5
  79. package/dist/resources/ussd.js.map +1 -1
  80. package/dist/types/enums.d.ts +34 -11
  81. package/dist/types/enums.d.ts.map +1 -1
  82. package/dist/types/enums.js +28 -9
  83. package/dist/types/enums.js.map +1 -1
  84. package/dist/types/models.d.ts +191 -22
  85. package/dist/types/models.d.ts.map +1 -1
  86. package/dist/types/params.d.ts +32 -5
  87. package/dist/types/params.d.ts.map +1 -1
  88. package/dist/version.d.ts +1 -1
  89. package/dist/version.js +1 -1
  90. package/package.json +1 -1
  91. package/src/client.ts +5 -2
  92. package/src/core.ts +46 -11
  93. package/src/errors.ts +23 -5
  94. package/src/resources/call-scenarios.ts +15 -3
  95. package/src/resources/calls.ts +31 -6
  96. package/src/resources/contact-groups.ts +15 -5
  97. package/src/resources/contacts.ts +18 -6
  98. package/src/resources/dongles.ts +117 -13
  99. package/src/resources/files.ts +14 -6
  100. package/src/resources/follow-up-sms-settings.ts +14 -4
  101. package/src/resources/index.ts +8 -1
  102. package/src/resources/mailings.ts +21 -7
  103. package/src/resources/plans.ts +25 -0
  104. package/src/resources/public-vpn.ts +11 -1
  105. package/src/resources/redirections.ts +15 -5
  106. package/src/resources/sip-users.ts +6 -2
  107. package/src/resources/sms.ts +28 -10
  108. package/src/resources/socks-proxies.ts +13 -3
  109. package/src/resources/ussd.ts +15 -5
  110. package/src/types/enums.ts +35 -11
  111. package/src/types/models.ts +199 -21
  112. package/src/types/params.ts +35 -5
  113. package/src/version.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,53 @@
2
2
 
3
3
  The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow [semver](https://semver.org/).
4
4
 
5
+ ## [0.3.0] - 2026-12-02
6
+
7
+ Supports Teleleo API 1.3.0: 87 operations.
8
+
9
+ ### Added
10
+
11
+ - `plans.getCatalog(params?)` (`GET /plan`): the prices of Teleleo in GBP (default) or EUR (`currency`), the subscriptions of the cabinet and the products of the store, with the `PlanCatalog`, `PlanSubscription` and `PlanProduct` types. Prices are decimal strings (`'10.00'`). It needs no API key: `new Teleleo({ apiKey: null })` makes a client without a key, even when `TELELEO_API_KEY` is set, and any other method of that client throws `TeleleoError` before anything is sent.
12
+ - `dongles.updateWifiIsolation(dongleId, { is_enabled })` (`PUT /dongle/{dongle_id}/setting/wifi-isolation`) and `dongles.updateUsbGateway(dongleId, { is_enabled })` (`PUT /dongle/{dongle_id}/setting/usb-gateway`), from modem firmware 5.1.0. `dongle_setting` carries `is_wifi_isolation_enabled` and `is_usb_gateway_enabled`.
13
+ - `is_lifetime` on `Dongle` and `DongleListItem`: the modem has a lifetime subscription.
14
+ - Modems from `dongles.get()` and `dongles.update()` carry `dongle_setting`, `public_vpn_server` and `public_vpn_endpoint`, as in `dongles.list()`.
15
+ - README sections Plans and prices and Subscription, and `examples/plans.ts`.
16
+
17
+ ### Changed
18
+
19
+ - `ClientOptions.apiKey` takes `null`, and `client.apiKey` is `string | null`: it is `null` only for a client made with `apiKey: null`. Without `apiKey` and without `TELELEO_API_KEY` the constructor still throws.
20
+ - The API works only for modems with an active subscription; a trial counts as one. A method that names a modem without one throws `BadRequestError` with `BILLING_ERROR_IDENTIFIER_DONGLE_SUBSCRIPTION_NOT_ACTIVE`, and so does every method but `dongles.list()`, `dongles.get()` and `plans.getCatalog()` when no modem of the organization has one. Lists leave out the objects of modems without a subscription. Reading, rebooting, the Wi-Fi hotspot, switching a function off and deleting need the subscription too. The mailing methods throw this code instead of `MAILING_MANAGEMENT_DONGLE_TARIFF_INVALID`, and `calls.create()` and `sms.update()` throw it (a `BadRequestError`) instead of `NotFoundError` with `DONGLE_ERROR_DONGLE_NOT_FOUND`.
21
+ - The legacy user key spends the request budget of its owner, 1200 requests a minute shared with the cabinet and the app, on most methods. Over it a method throws `RateLimitError` with `RATE_LIMIT_EXCEEDED`, after the client waited for `Retry-After` within `maxRetries`, as for the organization API key.
22
+ - `callback_url` of `sms.send()` and `params.url` of a redirection of type 4 or 5 must be an http or https URL of a public host, otherwise `BadRequestError` with `SMS_ERROR_IDENTIFIER_INVALID_CALLBACK_URL` or `PARAMS_NOT_VALID_EXCEPTION`. An e-mail address of a redirection with a control character in it is refused with `PARAMS_NOT_VALID_EXCEPTION`.
23
+ - `dongles.get()` and `dongles.update()` with the legacy user key of an account that is not active throw `AuthenticationError` with `UNAUTHORIZED_EXCEPTION` instead of `USER_NOT_ACTIVE`.
24
+
25
+ ### Fixed
26
+
27
+ - `withOptions({ apiKey: undefined })` keeps the key of the client. It used to read `TELELEO_API_KEY` again, so a copy could get another key or none.
28
+ - Modems from `dongles.get()` and `dongles.update()` carry the real `sms_outgoing`, `sms_incoming`, `call_outgoing`, `call_incoming` and `is_wifi_extender_processing`; they were always `0` and `false`.
29
+ - `dongles.update()` with an empty `name`, a `name` longer than 255 characters or a `number` longer than 50 throws `BadRequestError` with `REQUEST_VALIDATION_EXCEPTION`, as its doc comment says, instead of `DONGLE_ERROR_ERROR_WHILE_SAVING`. Its doc comment names `DONGLE_ERROR_CALL_SCENARIO_NOT_REMOVED`.
30
+ - A modem is `DongleOnlineStatus.UPDATING`, and sending refused with `DONGLE_FIRMWARE_UPDATING_EXCEPTION`, only while it installs a firmware update, no longer from the moment a new firmware is assigned to it.
31
+
32
+ ## [0.2.0] - 2026-11-30
33
+
34
+ Supports Teleleo API 1.2.0: 84 operations.
35
+
36
+ ### Added
37
+
38
+ - `calls.getTranscript(callId)` (`GET /call/{call_id}/transcript`): the text of a call by side, with the `CallTranscript` and `CallTranscriptSegment` types and the `CallTranscriptStatus` enum. Calls from `calls.list()` carry `transcript` (`CallTranscriptSummary`) when they have one.
39
+ - `dongles.getWifiClients(dongleId)` (`GET /dongle/{dongle_id}/wifi/clients`): the devices on the modem Wi-Fi, from modem firmware 4.5.8. Modems from `dongles.list()` carry `firmware_version`.
40
+ - Organization API key (`tlk_...`) in the docs: the key to use, created in the Teleleo cabinet in the team settings of the organization, with a role, sent in the `auth-key` header. A method the role may not call throws `PermissionDeniedError` with `ORGANIZATION_CAPABILITY_FORBIDDEN`.
41
+ - The doc comment of every method names the capability the role of an organization API key needs and, where the operation depends on it, the lowest modem firmware; `api.md` has a Capability column.
42
+ - Rate limits in the docs and tests: an organization API key over its 600 reads or 120 writes a minute gets 429 `ORGANIZATION_API_KEY_RATE_LIMIT_EXCEEDED`; the client repeats the request after the `Retry-After` seconds within `maxRetries`, then throws `RateLimitError` with that `errorMessage`.
43
+
44
+ ### Changed
45
+
46
+ - Types and method docs follow API 1.2.0: SMS delivery statuses, new error codes, and the fields that come as `null` or absent when the role of the key lacks a capability.
47
+
48
+ ### Deprecated
49
+
50
+ - The legacy user key (Settings → API key) still works but is deprecated by the API and will be removed in API v2. Move to an organization API key.
51
+
5
52
  ## [0.1.0] - 2026-11-10
6
53
 
7
54
  First release: a typed client for the 82 operations of Teleleo API v1.0.0, exceptions with API error codes, automatic pagination with `for await`, safe retries and timeouts.
package/README.md CHANGED
@@ -16,7 +16,7 @@ npm install teleleo
16
16
 
17
17
  ## Quickstart
18
18
 
19
- Take the API key in the Teleleo cabinet (Settings → API key) and put it into the `TELELEO_API_KEY` environment variable.
19
+ Create an organization API key in the Teleleo cabinet (team settings of your organization → API keys) and put it into the `TELELEO_API_KEY` environment variable.
20
20
 
21
21
  ```ts
22
22
  import Teleleo from 'teleleo';
@@ -38,6 +38,16 @@ Methods take the path parameters first (`dongleId`, `smsId`, ...), then an objec
38
38
 
39
39
  ## Usage
40
40
 
41
+ ### Authentication
42
+
43
+ The client sends the key in the `auth-key` header of every request.
44
+
45
+ - **Organization API key** (`tlk_...`) - the key to use. Create it in the Teleleo cabinet, in the team settings of the organization (API keys), with a role: `owner`, `admin`, `member` or `viewer`. The key acts in its own organization only, with the rights of its role: a method the role may not call throws `PermissionDeniedError` with `errorMessage` `ORGANIZATION_CAPABILITY_FORBIDDEN`. The key is rate limited, see [Rate limits](#rate-limits).
46
+ - **Legacy user key** (Settings → API key) - deprecated, removed in API v2. It still works, with every right of its owner, in the owner's personal organization, and spends the request budget of its owner (see [Rate limits](#rate-limits)). Move to an organization API key.
47
+ - **No key** - `plans.getCatalog()`, the prices of Teleleo, is public. `new Teleleo({ apiKey: null })` makes a client without a key, even when `TELELEO_API_KEY` is set: it can call `plans.getCatalog()`, and any other method throws `TeleleoError` before anything is sent. A client with a key sends it with `plans.getCatalog()` too, so the key must be valid. See [Plans and prices](#plans-and-prices).
48
+
49
+ What each role may do is listed in the [API documentation](https://github.com/teleleo-com/teleleo-openapi) (Roles and capabilities). The capability a method needs is in its doc comment and in the Capability column of [api.md](api.md).
50
+
41
51
  ### Read incoming SMS
42
52
 
43
53
  ```ts
@@ -79,10 +89,62 @@ Without `page` and `limit` the API returns the whole list in one answer (mailing
79
89
  await client.dongles.reboot(1234);
80
90
  const info = await client.dongles.getNetworkInfo(1234);
81
91
  console.log(info.current_network_name, info.network_type, info.is_roaming);
92
+
93
+ // Devices on the modem Wi-Fi; needs modem firmware 4.5.8 or later (firmware_version in dongles.list()).
94
+ const wifi = await client.dongles.getWifiClients(1234);
95
+ for (const device of wifi.clients) console.log(device.mac, device.ip, device.hostname);
96
+
97
+ // Wi-Fi isolation and the USB gateway mode; both need modem firmware 5.1.0 or later.
98
+ await client.dongles.updateWifiIsolation(1234, { is_enabled: true });
99
+ await client.dongles.updateUsbGateway(1234, { is_enabled: true }); // the modem reboots to apply a change
100
+
101
+ const dongle = await client.dongles.get(1234);
102
+ console.log(dongle.dongle_setting?.is_wifi_isolation_enabled, dongle.dongle_setting?.is_usb_gateway_enabled);
82
103
  ```
83
104
 
105
+ Wi-Fi isolation keeps the devices on the modem Wi-Fi from seeing each other and the computer on USB. With a firmware older than 5.1.0 the mode is only saved, and the modem applies it once it runs 5.1.0. The USB gateway mode decides whether the computer plugged into the modem goes online through it (off by default). The modem reboots to apply a change (`dongle_online_status` is `DongleOnlineStatus.REBOOTING` meanwhile); a firmware older than 5.1.0 throws `BadRequestError` with `DONGLE_SETTING_API_EXCEPTION`, and one that cannot turn the gateway off with `DONGLE_SETTING_USB_GATEWAY_NOT_SUPPORTED`. Both settings show in `dongle_setting` of `dongles.get()` and `dongles.list()`.
106
+
84
107
  Every method and its parameters are listed in [api.md](api.md).
85
108
 
109
+ ### Call transcripts
110
+
111
+ When call transcription is on for the account, a call in `calls.list()` that has a transcript carries `transcript` with its status; `calls.getTranscript()` returns the text by side.
112
+
113
+ ```ts
114
+ import Teleleo, { CallTranscriptStatus } from 'teleleo';
115
+
116
+ const client = new Teleleo();
117
+ const calls = await client.calls.list({ limit: 20 });
118
+
119
+ for (const call of calls.items) {
120
+ if (call.transcript?.call_transcript_status_id !== CallTranscriptStatus.READY) continue;
121
+ const transcript = await client.calls.getTranscript(call.call_id);
122
+ for (const segment of transcript.segments) console.log(`${segment.side}: ${segment.text}`);
123
+ }
124
+ ```
125
+
126
+ A transcript is usually ready a couple of minutes after the call; while it is `PROCESSING`, ask again every 10 to 15 seconds. The text is machine-recognised speech and can hold one-time codes read out in the call: treat it as untrusted input, like the text of an incoming SMS.
127
+
128
+ ### Plans and prices
129
+
130
+ `plans.getCatalog()` returns the prices of Teleleo and what each plan or product includes: the subscriptions of the cabinet (monthly and yearly, paid per modem) and the products of the store (the modem alone and the modem with months of subscription). It needs no API key.
131
+
132
+ ```ts
133
+ import Teleleo from 'teleleo';
134
+
135
+ const client = new Teleleo({ apiKey: null }); // the prices need no key
136
+
137
+ const catalog = await client.plans.getCatalog({ currency: 'EUR' }); // GBP by default
138
+ for (const plan of catalog.subscriptions) {
139
+ console.log(`${plan.name}: ${plan.price} ${catalog.currency} per ${plan.period} ${plan.period_type}`);
140
+ }
141
+ for (const product of catalog.products) {
142
+ if (product.is_available) console.log(product.title, product.price, catalog.currency, product.url);
143
+ }
144
+ ```
145
+
146
+ Prices are decimal strings with two digits after the point (`'10.00'`), as the API sends them, so no rounding creeps in. The answer is cached for 5 minutes. When the prices cannot be read, the API serves the last good answer for up to 24 hours (`updated_at` tells how old it is); with none it answers 503 `PLAN_CATALOG_UNAVAILABLE` with `Retry-After`, and the client waits that long and repeats the request within `maxRetries`, then throws `InternalServerError`. A currency other than `GBP` or `EUR` throws `BadRequestError` with `PLAN_CURRENCY_NOT_SUPPORTED`.
147
+
86
148
  ### Errors
87
149
 
88
150
  Every error is a subclass of `TeleleoError`. When the API answers with an error, the exception carries the machine-readable code in `errorMessage`, details in `errorDetails` and `requestId` for support.
@@ -122,9 +184,39 @@ try {
122
184
 
123
185
  API v1 answers 400, not 404, for a missing object; the library throws `NotFoundError` for both, so your code keeps working when the API moves to 404.
124
186
 
187
+ ### Subscription
188
+
189
+ The API works only for modems with an active subscription; a trial counts as one. A method that names a modem without one (in the path, in `dongle_id` or `dongle_ids`, or through a call, mailing, redirection, file or other object of that modem) throws `BadRequestError` with `errorMessage` `BILLING_ERROR_IDENTIFIER_DONGLE_SUBSCRIPTION_NOT_ACTIVE`. When no modem of the organization has a subscription, every method but the ones below throws it, contacts, contact groups and files included. Lists leave out the objects of modems without a subscription.
190
+
191
+ `dongles.list()` and `dongles.get()` always answer, so you can see which modems are paid (`is_tariff_package_active` or `is_trial`); `plans.getCatalog()` is not gated either. The subscription is paid in the Teleleo cabinet, which keeps working without one, and the API opens for the modem as soon as it is paid.
192
+
193
+ ```ts
194
+ import Teleleo, { BadRequestError } from 'teleleo';
195
+
196
+ const client = new Teleleo();
197
+
198
+ for await (const dongle of client.dongles.list({ is_short: true })) {
199
+ if (!dongle.is_tariff_package_active && !dongle.is_trial)
200
+ console.log(dongle.dongle_id, 'has no subscription');
201
+ }
202
+
203
+ try {
204
+ await client.sms.send(1234, { number: '+447700900123', message: 'Hello from Teleleo' });
205
+ } catch (error) {
206
+ if (
207
+ error instanceof BadRequestError &&
208
+ error.errorMessage === 'BILLING_ERROR_IDENTIFIER_DONGLE_SUBSCRIPTION_NOT_ACTIVE'
209
+ ) {
210
+ console.log('Pay for the modem in the Teleleo cabinet');
211
+ } else {
212
+ throw error;
213
+ }
214
+ }
215
+ ```
216
+
125
217
  ### Retries, timeouts and abort
126
218
 
127
- Requests that failed for a transient reason are repeated twice with exponential backoff: connection errors, 429, and 408/502/503/504 for requests that are safe to repeat. A POST (sending an SMS, creating a call) is repeated only when the server could not have acted on it, so a retry never sends an SMS twice.
219
+ Requests that failed for a transient reason are repeated twice with exponential backoff: connection errors, 429 (after the `Retry-After` the API sends, see [Rate limits](#rate-limits)), and 408/502/503/504 for requests that are safe to repeat. When the answer carries `Retry-After` (429, and the 503 of `plans.getCatalog()`), the client waits those seconds. A POST (sending an SMS, creating a call) is repeated only when the server could not have acted on it, so a retry never sends an SMS twice.
128
220
 
129
221
  ```ts
130
222
  const client = new Teleleo({ timeout: 20_000, maxRetries: 3 });
@@ -138,16 +230,35 @@ controller.abort();
138
230
 
139
231
  The default timeout is 60 seconds.
140
232
 
233
+ ### Rate limits
234
+
235
+ An organization API key may make 600 reads (GET) and 120 writes (any other method) a minute; the minute is a fixed clock minute. Over the budget the API answers 429 with `errorMessage` `ORGANIZATION_API_KEY_RATE_LIMIT_EXCEEDED` and a `Retry-After` header: the seconds (1 to 60) until the next minute. The client waits that long and repeats the request, within `maxRetries`; then it throws `RateLimitError`. A refused request still counts, so spread the requests of a big job over time rather than retrying in a loop.
236
+
237
+ ```ts
238
+ import Teleleo, { RateLimitError } from 'teleleo';
239
+
240
+ const client = new Teleleo({ maxRetries: 0 }); // handle 429 yourself
241
+
242
+ try {
243
+ await client.dongles.list();
244
+ } catch (error) {
245
+ if (error instanceof RateLimitError) console.log('wait', error.headers.get('retry-after'), 'seconds');
246
+ else throw error;
247
+ }
248
+ ```
249
+
250
+ The legacy user key spends the request budget of its owner: 1200 requests a minute per person, shared with that person's own requests from the Teleleo cabinet and app, on most methods. Over it the API answers 429 with `errorMessage` `RATE_LIMIT_EXCEEDED` and a `Retry-After` header, and the client handles it the same way.
251
+
141
252
  ### Configuration
142
253
 
143
- | Option | Environment variable | Default |
144
- | ---------------- | -------------------- | -------------------------------------------------------------- |
145
- | `apiKey` | `TELELEO_API_KEY` | required |
146
- | `baseURL` | `TELELEO_BASE_URL` | `https://app.teleleo.com/react_api` |
147
- | `timeout` | | 60 000 ms |
148
- | `maxRetries` | | 2 |
149
- | `defaultHeaders` | | |
150
- | `fetch` | | the global `fetch`; pass your own for proxies or custom agents |
254
+ | Option | Environment variable | Default |
255
+ | ---------------- | -------------------- | ----------------------------------------------------------------------- |
256
+ | `apiKey` | `TELELEO_API_KEY` | required; `null` for a client without a key (`plans.getCatalog()` only) |
257
+ | `baseURL` | `TELELEO_BASE_URL` | `https://app.teleleo.com/react_api` |
258
+ | `timeout` | | 60 000 ms |
259
+ | `maxRetries` | | 2 |
260
+ | `defaultHeaders` | | |
261
+ | `fetch` | | the global `fetch`; pass your own for proxies or custom agents |
151
262
 
152
263
  Every method also takes request options as its last argument: `headers`, `query`, `body`, `timeout`, `maxRetries`, `signal`. Use `query` and `body` to send a parameter the library does not have yet.
153
264
 
package/api.md CHANGED
@@ -1,183 +1,201 @@
1
1
  # API reference
2
2
 
3
- Every method of the `Teleleo` client, generated from [`spec/openapi.yaml`](spec/openapi.yaml). Types are exported from the package root.
3
+ Every method of the `Teleleo` client, generated from [`spec/openapi.yaml`](spec/openapi.yaml) (Teleleo API 1.3.0). Types are exported from the package root.
4
+
5
+ Every method except `plans.getCatalog()` needs the API key, sent in the `auth-key` header. Use an organization API key (`tlk_...`): create it in the Teleleo cabinet, in the team settings of the organization (API keys), with a role. The Capability column names what the role of the key needs for a method; a key without it gets `PermissionDeniedError` with `errorMessage` `ORGANIZATION_CAPABILITY_FORBIDDEN`. Roles and rate limits are described in the README: [Authentication](README.md#authentication), [Rate limits](README.md#rate-limits). The legacy user key (cabinet Settings → API key) has every capability, but it is deprecated and will be removed in API v2.
6
+
7
+ `plans.getCatalog()` needs no key: a client made with `new Teleleo({ apiKey: null })` can call it, and any other method of such a client throws `TeleleoError` without sending the request. A key the client has is sent with it, and it must be valid.
8
+
9
+ The API works only for modems with an active subscription (a trial counts): a method that names a modem without one throws `BadRequestError` with `errorMessage` `BILLING_ERROR_IDENTIFIER_DONGLE_SUBSCRIPTION_NOT_ACTIVE`, and so does any method when no modem of the organization has one. `dongles.list()`, `dongles.get()` and `plans.getCatalog()` are not gated. See [Subscription](README.md#subscription).
4
10
 
5
11
  ## `client.dongles`
6
12
 
7
13
  Modems of the account and their commands: reboot, Wi-Fi, Wi-Fi extender, number, network info.
8
14
 
9
- | Method | HTTP | Returns | Description |
10
- |---|---|---|---|
11
- | `list(params?)` | `GET /dongle` | `PagePromise<DongleListItem>` | List modems |
12
- | `reboot(dongleId)` | `POST /dongle/{dongle_id}/reboot` | `Promise<boolean>` | Reboot modem |
13
- | `enableWifi(dongleId)` | `POST /dongle/{dongle_id}/wifi/enable` | `Promise<boolean>` | Enable modem Wi-Fi |
14
- | `disableWifi(dongleId)` | `POST /dongle/{dongle_id}/wifi/disable` | `Promise<boolean>` | Disable modem Wi-Fi |
15
- | `setWifiCredentials(dongleId, params)` | `POST /dongle/{dongle_id}/wifi/credentials` | `Promise<boolean>` | Set modem Wi-Fi credentials |
16
- | `enableWifiExtender(dongleId, params)` | `POST /dongle/{dongle_id}/wifi-extender/enable` | `Promise<boolean>` | Enable Wi-Fi extender |
17
- | `disableWifiExtender(dongleId)` | `POST /dongle/{dongle_id}/wifi-extender/disable` | `Promise<boolean>` | Disable Wi-Fi extender |
18
- | `scanWifiNetworks(dongleId)` | `POST /dongle/{dongle_id}/wifi-extender/networks` | `Promise<boolean>` | Scan Wi-Fi networks |
19
- | `updateOfflineNotification(dongleId, params)` | `PUT /dongle/{dongle_id}/setting/offline-notification` | `Promise<boolean>` | Set offline notification |
20
- | `setNumber(dongleId, params)` | `PUT /dongle/{dongle_id}/number` | `Promise<boolean>` | Set modem number |
21
- | `get(dongleId)` | `GET /dongle/{dongle_id}` | `Promise<Dongle>` | Get modem |
22
- | `update(dongleId, params?)` | `PUT /dongle/{dongle_id}` | `Promise<Dongle>` | Update modem |
23
- | `getNetworkInfo(dongleId)` | `POST /dongle/{dongle_id}/mobile-network-info` | `Promise<DongleNetworkInfo>` | Get modem network info |
24
- | `getSimIdentifiers(dongleId)` | `POST /dongle/{dongle_id}/mobile-network-ids` | `Promise<DongleSimIdentifiers>` | Get modem SIM identifiers |
25
- | `listStatistics(dongleId, params?)` | `GET /dongle/{dongle_id}/statistic` | `Promise<Array<DongleStatistic>>` | List modem traffic statistics |
15
+ | Method | HTTP | Returns | Capability | Description |
16
+ |---|---|---|---|---|
17
+ | `list(params?)` | `GET /dongle` | `PagePromise<DongleListItem>` | `device.view` | List modems |
18
+ | `reboot(dongleId)` | `POST /dongle/{dongle_id}/reboot` | `Promise<boolean>` | `device.manage` | Reboot modem |
19
+ | `getWifiClients(dongleId)` | `GET /dongle/{dongle_id}/wifi/clients` | `Promise<DongleWifiClientList>` | `network.view` | List devices on modem Wi-Fi |
20
+ | `enableWifi(dongleId)` | `POST /dongle/{dongle_id}/wifi/enable` | `Promise<boolean>` | `device.manage` | Enable modem Wi-Fi |
21
+ | `disableWifi(dongleId)` | `POST /dongle/{dongle_id}/wifi/disable` | `Promise<boolean>` | `device.manage` | Disable modem Wi-Fi |
22
+ | `setWifiCredentials(dongleId, params)` | `POST /dongle/{dongle_id}/wifi/credentials` | `Promise<boolean>` | `device.manage` | Set modem Wi-Fi credentials |
23
+ | `enableWifiExtender(dongleId, params)` | `POST /dongle/{dongle_id}/wifi-extender/enable` | `Promise<boolean>` | `device.manage` | Enable Wi-Fi extender |
24
+ | `disableWifiExtender(dongleId)` | `POST /dongle/{dongle_id}/wifi-extender/disable` | `Promise<boolean>` | `device.manage` | Disable Wi-Fi extender |
25
+ | `scanWifiNetworks(dongleId)` | `POST /dongle/{dongle_id}/wifi-extender/networks` | `Promise<boolean>` | `device.manage` | Scan Wi-Fi networks |
26
+ | `updateOfflineNotification(dongleId, params)` | `PUT /dongle/{dongle_id}/setting/offline-notification` | `Promise<boolean>` | `device.manage` | Set offline notification |
27
+ | `updateWifiIsolation(dongleId, params)` | `PUT /dongle/{dongle_id}/setting/wifi-isolation` | `Promise<boolean>` | `device.manage` | Set Wi-Fi isolation |
28
+ | `updateUsbGateway(dongleId, params)` | `PUT /dongle/{dongle_id}/setting/usb-gateway` | `Promise<boolean>` | `device.manage` | Set USB gateway mode |
29
+ | `setNumber(dongleId, params)` | `PUT /dongle/{dongle_id}/number` | `Promise<boolean>` | `device.manage` | Set modem number |
30
+ | `get(dongleId)` | `GET /dongle/{dongle_id}` | `Promise<Dongle>` | `device.view` | Get modem |
31
+ | `update(dongleId, params?)` | `PUT /dongle/{dongle_id}` | `Promise<Dongle>` | `device.manage` | Update modem |
32
+ | `getNetworkInfo(dongleId)` | `POST /dongle/{dongle_id}/mobile-network-info` | `Promise<DongleNetworkInfo>` | `device.view` | Get modem network info |
33
+ | `getSimIdentifiers(dongleId)` | `POST /dongle/{dongle_id}/mobile-network-ids` | `Promise<DongleSimIdentifiers>` | `device.view` | Get modem SIM identifiers |
34
+ | `listStatistics(dongleId, params?)` | `GET /dongle/{dongle_id}/statistic` | `Promise<Array<DongleStatistic>>` | `device.view` | List modem traffic statistics |
26
35
 
27
36
  ## `client.sms`
28
37
 
29
38
  SMS of the modems: history, sending, replies, threads.
30
39
 
31
- | Method | HTTP | Returns | Description |
32
- |---|---|---|---|
33
- | `send(dongleId, params)` | `POST /dongle/{dongle_id}/outgoing-sms` | `Promise<Sms>` | Send SMS |
34
- | `sendToContact(dongleId, params)` | `POST /dongle/{dongle_id}/outgoing-contact-sms` | `Promise<Sms>` | Send SMS to contact |
35
- | `reply(dongleId, params)` | `POST /dongle/{dongle_id}/reply-sms` | `Promise<Sms>` | Reply to SMS |
36
- | `listThreads(params?)` | `GET /sms/thread` | `PagePromise<SmsThread>` | List SMS threads |
37
- | `list(params?)` | `GET /sms` | `PagePromise<Sms>` | List SMS |
38
- | `listForDongle(dongleId, params?)` | `GET /dongle/{dongle_id}/sms` | `PagePromise<Sms>` | List modem SMS |
39
- | `get(dongleId, smsId)` | `GET /dongle/{dongle_id}/sms/{sms_id}` | `Promise<Sms>` | Get SMS |
40
- | `update(dongleId, smsId, params?)` | `PUT /dongle/{dongle_id}/sms/{sms_id}` | `Promise<Sms>` | Update SMS |
41
- | `delete(dongleId, smsId)` | `DELETE /dongle/{dongle_id}/sms/{sms_id}` | `Promise<void>` | Delete SMS |
40
+ | Method | HTTP | Returns | Capability | Description |
41
+ |---|---|---|---|---|
42
+ | `send(dongleId, params)` | `POST /dongle/{dongle_id}/outgoing-sms` | `Promise<Sms>` | `sms.send` | Send SMS |
43
+ | `sendToContact(dongleId, params)` | `POST /dongle/{dongle_id}/outgoing-contact-sms` | `Promise<Sms>` | `sms.send` | Send SMS to contact |
44
+ | `reply(dongleId, params)` | `POST /dongle/{dongle_id}/reply-sms` | `Promise<Sms>` | `sms.send` | Reply to SMS |
45
+ | `listThreads(params?)` | `GET /sms/thread` | `PagePromise<SmsThread>` | `sms.view` | List SMS threads |
46
+ | `list(params?)` | `GET /sms` | `PagePromise<Sms>` | `sms.view` | List SMS |
47
+ | `listForDongle(dongleId, params?)` | `GET /dongle/{dongle_id}/sms` | `PagePromise<Sms>` | `sms.view` | List modem SMS |
48
+ | `get(dongleId, smsId)` | `GET /dongle/{dongle_id}/sms/{sms_id}` | `Promise<Sms>` | `sms.view` | Get SMS |
49
+ | `update(dongleId, smsId, params?)` | `PUT /dongle/{dongle_id}/sms/{sms_id}` | `Promise<Sms>` | `sms.send` | Update SMS |
50
+ | `delete(dongleId, smsId)` | `DELETE /dongle/{dongle_id}/sms/{sms_id}` | `Promise<void>` | `sms.send` | Delete SMS |
42
51
 
43
52
  ## `client.calls`
44
53
 
45
- Calls of the modems: history, outgoing calls.
54
+ Calls of the modems: history, outgoing calls, transcripts.
46
55
 
47
- | Method | HTTP | Returns | Description |
48
- |---|---|---|---|
49
- | `list(params?)` | `GET /call` | `PagePromise<Call>` | List calls |
50
- | `create(dongleId, params?)` | `POST /dongle/{dongle_id}/call` | `Promise<Call>` | Make call |
51
- | `get(dongleId, callId)` | `GET /dongle/{dongle_id}/call/{call_id}` | `Promise<Call>` | Get call |
52
- | `delete(dongleId, callId)` | `DELETE /dongle/{dongle_id}/call/{call_id}` | `Promise<void>` | Delete call |
56
+ | Method | HTTP | Returns | Capability | Description |
57
+ |---|---|---|---|---|
58
+ | `list(params?)` | `GET /call` | `PagePromise<Call>` | `call.view` | List calls |
59
+ | `getTranscript(callId)` | `GET /call/{call_id}/transcript` | `Promise<CallTranscript>` | `call.view` | Get call transcript |
60
+ | `create(dongleId, params?)` | `POST /dongle/{dongle_id}/call` | `Promise<Call>` | `call.make` | Make call |
61
+ | `get(dongleId, callId)` | `GET /dongle/{dongle_id}/call/{call_id}` | `Promise<Call>` | `call.view` | Get call |
62
+ | `delete(dongleId, callId)` | `DELETE /dongle/{dongle_id}/call/{call_id}` | `Promise<void>` | `call.make` | Delete call |
53
63
 
54
64
  ## `client.ussd`
55
65
 
56
66
  USSD requests through a modem.
57
67
 
58
- | Method | HTTP | Returns | Description |
59
- |---|---|---|---|
60
- | `list(dongleId, params?)` | `GET /dongle/{dongle_id}/ussd` | `PagePromise<Ussd>` | List USSD requests |
61
- | `send(dongleId, params)` | `POST /dongle/{dongle_id}/ussd` | `Promise<Ussd>` | Send USSD |
62
- | `get(dongleId, ussdId)` | `GET /dongle/{dongle_id}/ussd/{ussd_id}` | `Promise<Ussd>` | Get USSD request |
63
- | `delete(dongleId, ussdId)` | `DELETE /dongle/{dongle_id}/ussd/{ussd_id}` | `Promise<boolean>` | Delete USSD request |
64
- | `deleteAll(dongleId)` | `DELETE /dongle/{dongle_id}/ussds` | `Promise<boolean>` | Delete USSD history |
68
+ | Method | HTTP | Returns | Capability | Description |
69
+ |---|---|---|---|---|
70
+ | `list(dongleId, params?)` | `GET /dongle/{dongle_id}/ussd` | `PagePromise<Ussd>` | `device.manage` | List USSD requests |
71
+ | `send(dongleId, params)` | `POST /dongle/{dongle_id}/ussd` | `Promise<Ussd>` | `device.manage` | Send USSD |
72
+ | `get(dongleId, ussdId)` | `GET /dongle/{dongle_id}/ussd/{ussd_id}` | `Promise<Ussd>` | `device.manage` | Get USSD request |
73
+ | `delete(dongleId, ussdId)` | `DELETE /dongle/{dongle_id}/ussd/{ussd_id}` | `Promise<boolean>` | `device.manage` | Delete USSD request |
74
+ | `deleteAll(dongleId)` | `DELETE /dongle/{dongle_id}/ussds` | `Promise<boolean>` | `device.manage` | Delete USSD history |
65
75
 
66
76
  ## `client.contacts`
67
77
 
68
78
  Address book of the account.
69
79
 
70
- | Method | HTTP | Returns | Description |
71
- |---|---|---|---|
72
- | `list(params?)` | `GET /contact` | `PagePromise<Contact>` | List contacts |
73
- | `create(params)` | `POST /contact` | `Promise<Contact>` | Create contact |
74
- | `get(contactId)` | `GET /contact/{contact_id}` | `Promise<Contact>` | Get contact |
75
- | `update(contactId, params)` | `PUT /contact/{contact_id}` | `Promise<Contact>` | Update contact |
76
- | `delete(contactId)` | `DELETE /contact/{contact_id}` | `Promise<boolean>` | Delete contact |
77
- | `importContacts(params)` | `POST /contact/import` | `Promise<ContactImportResult>` | Import contacts |
80
+ | Method | HTTP | Returns | Capability | Description |
81
+ |---|---|---|---|---|
82
+ | `list(params?)` | `GET /contact` | `PagePromise<Contact>` | `contact.view` | List contacts |
83
+ | `create(params)` | `POST /contact` | `Promise<Contact>` | `contact.manage` | Create contact |
84
+ | `get(contactId)` | `GET /contact/{contact_id}` | `Promise<Contact>` | `contact.view` | Get contact |
85
+ | `update(contactId, params)` | `PUT /contact/{contact_id}` | `Promise<Contact>` | `contact.manage` | Update contact |
86
+ | `delete(contactId)` | `DELETE /contact/{contact_id}` | `Promise<boolean>` | `contact.manage` | Delete contact |
87
+ | `importContacts(params)` | `POST /contact/import` | `Promise<ContactImportResult>` | `contact.manage` | Import contacts |
78
88
 
79
89
  ## `client.contactGroups`
80
90
 
81
91
  Groups of contacts, used by mailings, call scenarios and redirections.
82
92
 
83
- | Method | HTTP | Returns | Description |
84
- |---|---|---|---|
85
- | `list(params?)` | `GET /contact-group` | `PagePromise<ContactGroup>` | List contact groups |
86
- | `create(params)` | `POST /contact-group` | `Promise<ContactGroup>` | Create contact group |
87
- | `get(contactGroupId)` | `GET /contact-group/{contact_group_id}` | `Promise<ContactGroup>` | Get contact group |
88
- | `update(contactGroupId, params)` | `PUT /contact-group/{contact_group_id}` | `Promise<ContactGroup>` | Update contact group |
89
- | `delete(contactGroupId)` | `DELETE /contact-group/{contact_group_id}` | `Promise<boolean>` | Delete contact group |
93
+ | Method | HTTP | Returns | Capability | Description |
94
+ |---|---|---|---|---|
95
+ | `list(params?)` | `GET /contact-group` | `PagePromise<ContactGroup>` | `contact.view` | List contact groups |
96
+ | `create(params)` | `POST /contact-group` | `Promise<ContactGroup>` | `contact.manage` | Create contact group |
97
+ | `get(contactGroupId)` | `GET /contact-group/{contact_group_id}` | `Promise<ContactGroup>` | `contact.view` | Get contact group |
98
+ | `update(contactGroupId, params)` | `PUT /contact-group/{contact_group_id}` | `Promise<ContactGroup>` | `contact.manage` | Update contact group |
99
+ | `delete(contactGroupId)` | `DELETE /contact-group/{contact_group_id}` | `Promise<boolean>` | `contact.manage` | Delete contact group |
90
100
 
91
101
  ## `client.mailings`
92
102
 
93
103
  Bulk SMS and call campaigns.
94
104
 
95
- | Method | HTTP | Returns | Description |
96
- |---|---|---|---|
97
- | `list(params?)` | `GET /mailing` | `PagePromise<Mailing>` | List mailings |
98
- | `create(params)` | `POST /mailing` | `Promise<Mailing>` | Create mailing |
99
- | `createSms(params)` | `POST /mailing/sms` | `Promise<Mailing>` | Create SMS mailing |
100
- | `createCall(params)` | `POST /mailing/call` | `Promise<Mailing>` | Create call mailing |
101
- | `get(mailingId)` | `GET /mailing/{mailing_id}` | `Promise<Mailing>` | Get mailing |
102
- | `update(mailingId, params?)` | `PUT /mailing/{mailing_id}` | `Promise<Mailing>` | Update mailing |
103
- | `delete(mailingId)` | `DELETE /mailing/{mailing_id}` | `Promise<boolean>` | Delete mailing |
105
+ | Method | HTTP | Returns | Capability | Description |
106
+ |---|---|---|---|---|
107
+ | `list(params?)` | `GET /mailing` | `PagePromise<Mailing>` | `automation.view` | List mailings |
108
+ | `create(params)` | `POST /mailing` | `Promise<Mailing>` | `automation.manage` | Create mailing |
109
+ | `createSms(params)` | `POST /mailing/sms` | `Promise<Mailing>` | `automation.manage` | Create SMS mailing |
110
+ | `createCall(params)` | `POST /mailing/call` | `Promise<Mailing>` | `automation.manage` | Create call mailing |
111
+ | `get(mailingId)` | `GET /mailing/{mailing_id}` | `Promise<Mailing>` | `automation.view` | Get mailing |
112
+ | `update(mailingId, params?)` | `PUT /mailing/{mailing_id}` | `Promise<Mailing>` | `automation.manage` | Update mailing |
113
+ | `delete(mailingId)` | `DELETE /mailing/{mailing_id}` | `Promise<boolean>` | `automation.manage` | Delete mailing |
104
114
 
105
115
  ## `client.redirections`
106
116
 
107
117
  Rules for incoming SMS and calls: forwarding, auto reply, HTTP callback.
108
118
 
109
- | Method | HTTP | Returns | Description |
110
- |---|---|---|---|
111
- | `list(params?)` | `GET /redirection` | `PagePromise<Redirection>` | List redirections |
112
- | `create(params)` | `POST /redirection` | `Promise<Redirection>` | Create redirection |
113
- | `get(redirectionId)` | `GET /redirection/{redirection_id}` | `Promise<Redirection>` | Get redirection |
114
- | `update(redirectionId, params)` | `PUT /redirection/{redirection_id}` | `Promise<Redirection>` | Update redirection |
115
- | `delete(redirectionId)` | `DELETE /redirection/{redirection_id}` | `Promise<boolean>` | Delete redirection |
119
+ | Method | HTTP | Returns | Capability | Description |
120
+ |---|---|---|---|---|
121
+ | `list(params?)` | `GET /redirection` | `PagePromise<Redirection>` | `automation.view` | List redirections |
122
+ | `create(params)` | `POST /redirection` | `Promise<Redirection>` | `automation.manage` | Create redirection |
123
+ | `get(redirectionId)` | `GET /redirection/{redirection_id}` | `Promise<Redirection>` | `automation.view` | Get redirection |
124
+ | `update(redirectionId, params)` | `PUT /redirection/{redirection_id}` | `Promise<Redirection>` | `automation.manage` | Update redirection |
125
+ | `delete(redirectionId)` | `DELETE /redirection/{redirection_id}` | `Promise<boolean>` | `automation.manage` | Delete redirection |
116
126
 
117
127
  ## `client.callScenarios`
118
128
 
119
129
  What a modem plays to incoming callers.
120
130
 
121
- | Method | HTTP | Returns | Description |
122
- |---|---|---|---|
123
- | `list(params?)` | `GET /call-scenario` | `PagePromise<CallScenario>` | List call scenarios |
124
- | `create(params)` | `POST /call-scenario` | `Promise<CallScenario>` | Create call scenario |
125
- | `get(callScenarioId)` | `GET /call-scenario/{call_scenario_id}` | `Promise<CallScenario>` | Get call scenario |
126
- | `update(callScenarioId, params?)` | `PUT /call-scenario/{call_scenario_id}` | `Promise<CallScenario>` | Update call scenario |
127
- | `delete(callScenarioId)` | `DELETE /call-scenario/{call_scenario_id}` | `Promise<boolean>` | Delete call scenario |
128
- | `retry(callScenarioId)` | `POST /call-scenario/{call_scenario_id}/retry` | `Promise<CallScenario>` | Retry call scenario delivery |
131
+ | Method | HTTP | Returns | Capability | Description |
132
+ |---|---|---|---|---|
133
+ | `list(params?)` | `GET /call-scenario` | `PagePromise<CallScenario>` | `automation.view` | List call scenarios |
134
+ | `create(params)` | `POST /call-scenario` | `Promise<CallScenario>` | `automation.manage` | Create call scenario |
135
+ | `get(callScenarioId)` | `GET /call-scenario/{call_scenario_id}` | `Promise<CallScenario>` | `automation.view` | Get call scenario |
136
+ | `update(callScenarioId, params?)` | `PUT /call-scenario/{call_scenario_id}` | `Promise<CallScenario>` | `automation.manage` | Update call scenario |
137
+ | `delete(callScenarioId)` | `DELETE /call-scenario/{call_scenario_id}` | `Promise<boolean>` | `automation.manage` | Delete call scenario |
138
+ | `retry(callScenarioId)` | `POST /call-scenario/{call_scenario_id}/retry` | `Promise<CallScenario>` | `automation.manage` | Retry call scenario delivery |
129
139
 
130
140
  ## `client.followUpSmsSettings`
131
141
 
132
142
  SMS a modem sends to a caller after a call.
133
143
 
134
- | Method | HTTP | Returns | Description |
135
- |---|---|---|---|
136
- | `list(params?)` | `GET /follow-up-sms-setting` | `PagePromise<FollowUpSmsSetting>` | List follow-up SMS settings |
137
- | `create(params)` | `POST /follow-up-sms-setting` | `Promise<FollowUpSmsSetting>` | Create follow-up SMS setting |
138
- | `get(followUpSmsSettingId)` | `GET /follow-up-sms-setting/{follow_up_sms_setting_id}` | `Promise<FollowUpSmsSetting>` | Get follow-up SMS setting |
139
- | `update(followUpSmsSettingId, params)` | `PUT /follow-up-sms-setting/{follow_up_sms_setting_id}` | `Promise<FollowUpSmsSetting>` | Update follow-up SMS setting |
140
- | `delete(followUpSmsSettingId)` | `DELETE /follow-up-sms-setting/{follow_up_sms_setting_id}` | `Promise<boolean>` | Delete follow-up SMS setting |
144
+ | Method | HTTP | Returns | Capability | Description |
145
+ |---|---|---|---|---|
146
+ | `list(params?)` | `GET /follow-up-sms-setting` | `PagePromise<FollowUpSmsSetting>` | `automation.view` | List follow-up SMS settings |
147
+ | `create(params)` | `POST /follow-up-sms-setting` | `Promise<FollowUpSmsSetting>` | `automation.manage` | Create follow-up SMS setting |
148
+ | `get(followUpSmsSettingId)` | `GET /follow-up-sms-setting/{follow_up_sms_setting_id}` | `Promise<FollowUpSmsSetting>` | `automation.view` | Get follow-up SMS setting |
149
+ | `update(followUpSmsSettingId, params)` | `PUT /follow-up-sms-setting/{follow_up_sms_setting_id}` | `Promise<FollowUpSmsSetting>` | `automation.manage` | Update follow-up SMS setting |
150
+ | `delete(followUpSmsSettingId)` | `DELETE /follow-up-sms-setting/{follow_up_sms_setting_id}` | `Promise<boolean>` | `automation.manage` | Delete follow-up SMS setting |
141
151
 
142
152
  ## `client.publicVpn`
143
153
 
144
154
  VPN access through a modem.
145
155
 
146
- | Method | HTTP | Returns | Description |
147
- |---|---|---|---|
148
- | `enable(dongleId)` | `POST /dongle/{dongle_id}/public-vpn/enable` | `Promise<boolean>` | Enable public VPN |
149
- | `disable(dongleId)` | `POST /dongle/{dongle_id}/public-vpn/disable` | `Promise<boolean>` | Disable public VPN |
150
- | `refreshPassword(dongleId)` | `POST /dongle/{dongle_id}/public-vpn/refresh-password` | `Promise<boolean>` | Refresh public VPN password |
151
- | `listSessions()` | `GET /public-vpn/connect-session-list` | `Promise<Array<PublicVpnSession>>` | List public VPN sessions |
156
+ | Method | HTTP | Returns | Capability | Description |
157
+ |---|---|---|---|---|
158
+ | `enable(dongleId)` | `POST /dongle/{dongle_id}/public-vpn/enable` | `Promise<boolean>` | `network.manage` | Enable public VPN |
159
+ | `disable(dongleId)` | `POST /dongle/{dongle_id}/public-vpn/disable` | `Promise<boolean>` | `network.manage` | Disable public VPN |
160
+ | `refreshPassword(dongleId)` | `POST /dongle/{dongle_id}/public-vpn/refresh-password` | `Promise<boolean>` | `network.manage` | Refresh public VPN password |
161
+ | `listSessions()` | `GET /public-vpn/connect-session-list` | `Promise<Array<PublicVpnSession>>` | `network.view` | List public VPN sessions |
152
162
 
153
163
  ## `client.socksProxies`
154
164
 
155
165
  SOCKS5 proxy through the mobile network of a modem.
156
166
 
157
- | Method | HTTP | Returns | Description |
158
- |---|---|---|---|
159
- | `list(params?)` | `GET /dongle-socks-proxy` | `PagePromise<DongleSocksProxy>` | List SOCKS proxies |
160
- | `create(params)` | `POST /dongle-socks-proxy` | `Promise<DongleSocksProxy>` | Create SOCKS proxy |
161
- | `get(dongleSocksProxyId)` | `GET /dongle-socks-proxy/{dongle_socks_proxy_id}` | `Promise<DongleSocksProxy>` | Get SOCKS proxy |
162
- | `update(dongleSocksProxyId, params)` | `PUT /dongle-socks-proxy/{dongle_socks_proxy_id}` | `Promise<DongleSocksProxy>` | Update SOCKS proxy |
163
- | `delete(dongleSocksProxyId)` | `DELETE /dongle-socks-proxy/{dongle_socks_proxy_id}` | `Promise<boolean>` | Delete SOCKS proxy |
167
+ | Method | HTTP | Returns | Capability | Description |
168
+ |---|---|---|---|---|
169
+ | `list(params?)` | `GET /dongle-socks-proxy` | `PagePromise<DongleSocksProxy>` | `network.view` | List SOCKS proxies |
170
+ | `create(params)` | `POST /dongle-socks-proxy` | `Promise<DongleSocksProxy>` | `network.manage` | Create SOCKS proxy |
171
+ | `get(dongleSocksProxyId)` | `GET /dongle-socks-proxy/{dongle_socks_proxy_id}` | `Promise<DongleSocksProxy>` | `network.view` | Get SOCKS proxy |
172
+ | `update(dongleSocksProxyId, params)` | `PUT /dongle-socks-proxy/{dongle_socks_proxy_id}` | `Promise<DongleSocksProxy>` | `network.manage` | Update SOCKS proxy |
173
+ | `delete(dongleSocksProxyId)` | `DELETE /dongle-socks-proxy/{dongle_socks_proxy_id}` | `Promise<boolean>` | `network.manage` | Delete SOCKS proxy |
164
174
 
165
175
  ## `client.sipUsers`
166
176
 
167
177
  SIP accounts of the modems.
168
178
 
169
- | Method | HTTP | Returns | Description |
170
- |---|---|---|---|
171
- | `list(params?)` | `GET /sip-user` | `Promise<Array<PbxSipUser>>` | List SIP users |
172
- | `get(sipUserId)` | `GET /sip-user/{sip_user_id}` | `Promise<PbxSipUser>` | Get SIP user |
179
+ | Method | HTTP | Returns | Capability | Description |
180
+ |---|---|---|---|---|
181
+ | `list(params?)` | `GET /sip-user` | `Promise<Array<PbxSipUser>>` | `call.make` | List SIP users |
182
+ | `get(sipUserId)` | `GET /sip-user/{sip_user_id}` | `Promise<PbxSipUser>` | `call.make` | Get SIP user |
173
183
 
174
184
  ## `client.files`
175
185
 
176
186
  Downloads, temporary audio uploads and text-to-speech.
177
187
 
178
- | Method | HTTP | Returns | Description |
179
- |---|---|---|---|
180
- | `download(fileId)` | `GET /file/{file_id}` | `Promise<Uint8Array>` | Get file |
181
- | `downloadTmp(fileId)` | `GET /file/tmp/{file_id}` | `Promise<Uint8Array>` | Get temporary file |
182
- | `uploadTmp(params)` | `POST /file/upload-tmp` | `Promise<TmpFile>` | Upload temporary file |
183
- | `generateSpeech(params)` | `POST /file/generate-speech` | `Promise<TmpFile>` | Generate speech |
188
+ | Method | HTTP | Returns | Capability | Description |
189
+ |---|---|---|---|---|
190
+ | `download(fileId)` | `GET /file/{file_id}` | `Promise<Uint8Array>` | `device.view` | Get file |
191
+ | `downloadTmp(fileId)` | `GET /file/tmp/{file_id}` | `Promise<Uint8Array>` | `automation.manage` | Get temporary file |
192
+ | `uploadTmp(params)` | `POST /file/upload-tmp` | `Promise<TmpFile>` | `automation.manage` | Upload temporary file |
193
+ | `generateSpeech(params)` | `POST /file/generate-speech` | `Promise<TmpFile>` | `automation.manage` | Generate speech |
194
+
195
+ ## `client.plans`
196
+
197
+ Prices of Teleleo: the subscriptions of the cabinet and the products of the store. Public, without a key.
198
+
199
+ | Method | HTTP | Returns | Capability | Description |
200
+ |---|---|---|---|---|
201
+ | `getCatalog(params?)` | `GET /plan` | `Promise<PlanCatalog>` | no key needed | List plans and prices |
package/dist/client.d.ts CHANGED
@@ -17,7 +17,9 @@ export interface Teleleo extends Resources {
17
17
  export declare class Teleleo extends BaseClient {
18
18
  constructor(options?: ClientOptions);
19
19
  /**
20
- * A copy of the client with some options changed.
20
+ * A copy of the client with some options changed. The copy keeps the key of this client unless `apiKey` is
21
+ * given a value: a string, or `null` for a copy without a key. `apiKey: undefined` keeps the key and never
22
+ * reads `TELELEO_API_KEY` again.
21
23
  *
22
24
  * ```ts
23
25
  * await client.withOptions({ timeout: 5_000, maxRetries: 0 }).dongles.list();
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEvE;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,OAAQ,SAAQ,SAAS;CAAG;AAE7C,qBAAa,OAAQ,SAAQ,UAAU;gBACzB,OAAO,GAAE,aAAkB;IAKvC;;;;;;OAMG;IACH,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO;CAW7C"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEvE;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,OAAQ,SAAQ,SAAS;CAAG;AAE7C,qBAAa,OAAQ,SAAQ,UAAU;gBACzB,OAAO,GAAE,aAAkB;IAKvC;;;;;;;;OAQG;IACH,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO;CAY7C"}
package/dist/client.js CHANGED
@@ -6,7 +6,9 @@ export class Teleleo extends BaseClient {
6
6
  Object.assign(this, createResources(this));
7
7
  }
8
8
  /**
9
- * A copy of the client with some options changed.
9
+ * A copy of the client with some options changed. The copy keeps the key of this client unless `apiKey` is
10
+ * given a value: a string, or `null` for a copy without a key. `apiKey: undefined` keeps the key and never
11
+ * reads `TELELEO_API_KEY` again.
10
12
  *
11
13
  * ```ts
12
14
  * await client.withOptions({ timeout: 5_000, maxRetries: 0 }).dongles.list();
@@ -15,11 +17,12 @@ export class Teleleo extends BaseClient {
15
17
  withOptions(options) {
16
18
  return new Teleleo({
17
19
  ...this._options,
18
- apiKey: this.apiKey,
19
20
  baseURL: this.baseURL,
20
21
  timeout: this.timeout,
21
22
  maxRetries: this.maxRetries,
22
23
  ...options,
24
+ // An explicit `apiKey: undefined` must not drop the inherited key and fall back to the environment.
25
+ apiKey: options.apiKey !== undefined ? options.apiKey : this.apiKey,
23
26
  defaultHeaders: { ...this._options.defaultHeaders, ...options.defaultHeaders },
24
27
  });
25
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAkB,MAAM,sBAAsB,CAAC;AAgBvE,MAAM,OAAO,OAAQ,SAAQ,UAAU;IACrC,YAAY,UAAyB,EAAE;QACrC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;OAMG;IACH,WAAW,CAAC,OAAsB;QAChC,OAAO,IAAI,OAAO,CAAC;YACjB,GAAG,IAAI,CAAC,QAAQ;YAChB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,GAAG,OAAO;YACV,cAAc,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE;SAC/E,CAAC,CAAC;IACL,CAAC;CACF"}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAkB,MAAM,sBAAsB,CAAC;AAgBvE,MAAM,OAAO,OAAQ,SAAQ,UAAU;IACrC,YAAY,UAAyB,EAAE;QACrC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;;OAQG;IACH,WAAW,CAAC,OAAsB;QAChC,OAAO,IAAI,OAAO,CAAC;YACjB,GAAG,IAAI,CAAC,QAAQ;YAChB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,GAAG,OAAO;YACV,oGAAoG;YACpG,MAAM,EAAE,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM;YACnE,cAAc,EAAE,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE;SAC/E,CAAC,CAAC;IACL,CAAC;CACF"}