|
| 1 | +# API |
| 2 | + |
| 3 | +```java |
| 4 | +APIController aPIController = client.getMessagingClient().getAPIController(); |
| 5 | +``` |
| 6 | + |
| 7 | +## Class Name |
| 8 | + |
| 9 | +`APIController` |
| 10 | + |
| 11 | +## Methods |
| 12 | + |
| 13 | +* [List Media](/doc/Messaging/controllers/api.md#list-media) |
| 14 | +* [Get Media](/doc/Messaging/controllers/api.md#get-media) |
| 15 | +* [Upload Media](/doc/Messaging/controllers/api.md#upload-media) |
| 16 | +* [Delete Media](/doc/Messaging/controllers/api.md#delete-media) |
| 17 | +* [Get Messages](/doc/Messaging/controllers/api.md#get-messages) |
| 18 | +* [Create Message](/doc/Messaging/controllers/api.md#create-message) |
| 19 | + |
| 20 | + |
| 21 | +# List Media |
| 22 | + |
| 23 | +Gets a list of your media files. No query parameters are supported. |
| 24 | + |
| 25 | +```java |
| 26 | +CompletableFuture<ApiResponse<List<Media>>> listMediaAsync( |
| 27 | + final String accountId, |
| 28 | + final String continuationToken) |
| 29 | +``` |
| 30 | + |
| 31 | +## Parameters |
| 32 | + |
| 33 | +| Parameter | Type | Tags | Description | |
| 34 | +| --- | --- | --- | --- | |
| 35 | +| `accountId` | `String` | Template, Required | User's account ID | |
| 36 | +| `continuationToken` | `String` | Header, Optional | Continuation token used to retrieve subsequent media. | |
| 37 | + |
| 38 | +## Server |
| 39 | + |
| 40 | +`Server.MESSAGINGDEFAULT` |
| 41 | + |
| 42 | +## Response Type |
| 43 | + |
| 44 | +[`List<Media>`]($m/Messaging/Media) |
| 45 | + |
| 46 | +## Example Usage |
| 47 | + |
| 48 | +```java |
| 49 | +String accountId = "900000"; |
| 50 | +String continuationToken = "12345"; |
| 51 | + |
| 52 | +aPIController.listMediaAsync(accountId, continuationToken).thenAccept(result -> { |
| 53 | + // TODO success callback handler |
| 54 | +}).exceptionally(exception -> { |
| 55 | + // TODO failure callback handler |
| 56 | + return null; |
| 57 | +}); |
| 58 | +``` |
| 59 | + |
| 60 | +## Errors |
| 61 | + |
| 62 | +| HTTP Status Code | Error Description | Exception Class | |
| 63 | +| --- | --- | --- | |
| 64 | +| 400 | 400 Request is malformed or invalid | [`MessagingException`]($m/Messaging/MessagingException) | |
| 65 | +| 401 | 401 The specified user does not have access to the account | [`MessagingException`]($m/Messaging/MessagingException) | |
| 66 | +| 403 | 403 The user does not have access to this API | [`MessagingException`]($m/Messaging/MessagingException) | |
| 67 | +| 404 | 404 Path not found | [`MessagingException`]($m/Messaging/MessagingException) | |
| 68 | +| 415 | 415 The content-type of the request is incorrect | [`MessagingException`]($m/Messaging/MessagingException) | |
| 69 | +| 429 | 429 The rate limit has been reached | [`MessagingException`]($m/Messaging/MessagingException) | |
| 70 | + |
| 71 | + |
| 72 | +# Get Media |
| 73 | + |
| 74 | +Downloads a media file you previously uploaded. |
| 75 | + |
| 76 | +```java |
| 77 | +CompletableFuture<ApiResponse<InputStream>> getMediaAsync( |
| 78 | + final String accountId, |
| 79 | + final String mediaId) |
| 80 | +``` |
| 81 | + |
| 82 | +## Parameters |
| 83 | + |
| 84 | +| Parameter | Type | Tags | Description | |
| 85 | +| --- | --- | --- | --- | |
| 86 | +| `accountId` | `String` | Template, Required | User's account ID | |
| 87 | +| `mediaId` | `String` | Template, Required | Media ID to retrieve<br>**Constraints**: *Pattern*: `.+` | |
| 88 | + |
| 89 | +## Server |
| 90 | + |
| 91 | +`Server.MESSAGINGDEFAULT` |
| 92 | + |
| 93 | +## Response Type |
| 94 | + |
| 95 | +`InputStream` |
| 96 | + |
| 97 | +## Example Usage |
| 98 | + |
| 99 | +```java |
| 100 | +String accountId = "900000"; |
| 101 | +String mediaId = "0a610655-ba58"; |
| 102 | + |
| 103 | +aPIController.getMediaAsync(accountId, mediaId).thenAccept(result -> { |
| 104 | + // TODO success callback handler |
| 105 | +}).exceptionally(exception -> { |
| 106 | + // TODO failure callback handler |
| 107 | + return null; |
| 108 | +}); |
| 109 | +``` |
| 110 | + |
| 111 | +## Errors |
| 112 | + |
| 113 | +| HTTP Status Code | Error Description | Exception Class | |
| 114 | +| --- | --- | --- | |
| 115 | +| 400 | 400 Request is malformed or invalid | [`MessagingException`]($m/Messaging/MessagingException) | |
| 116 | +| 401 | 401 The specified user does not have access to the account | [`MessagingException`]($m/Messaging/MessagingException) | |
| 117 | +| 403 | 403 The user does not have access to this API | [`MessagingException`]($m/Messaging/MessagingException) | |
| 118 | +| 404 | 404 Path not found | [`MessagingException`]($m/Messaging/MessagingException) | |
| 119 | +| 415 | 415 The content-type of the request is incorrect | [`MessagingException`]($m/Messaging/MessagingException) | |
| 120 | +| 429 | 429 The rate limit has been reached | [`MessagingException`]($m/Messaging/MessagingException) | |
| 121 | + |
| 122 | + |
| 123 | +# Upload Media |
| 124 | + |
| 125 | +Uploads a file the normal HTTP way. You may add headers to the request in order to provide some control to your media-file. |
| 126 | + |
| 127 | +```java |
| 128 | +CompletableFuture<ApiResponse<Void>> uploadMediaAsync( |
| 129 | + final String accountId, |
| 130 | + final String mediaId, |
| 131 | + final FileWrapper body, |
| 132 | + final String contentType, |
| 133 | + final String cacheControl) |
| 134 | +``` |
| 135 | + |
| 136 | +## Parameters |
| 137 | + |
| 138 | +| Parameter | Type | Tags | Description | |
| 139 | +| --- | --- | --- | --- | |
| 140 | +| `accountId` | `String` | Template, Required | User's account ID | |
| 141 | +| `mediaId` | `String` | Template, Required | The user supplied custom media ID<br>**Constraints**: *Pattern*: `.+` | |
| 142 | +| `body` | `FileWrapper` | Body, Required | - | |
| 143 | +| `contentType` | `String` | Header, Optional | The media type of the entity-body<br>**Default**: `"application/octet-stream"` | |
| 144 | +| `cacheControl` | `String` | Header, Optional | General-header field is used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain. | |
| 145 | + |
| 146 | +## Server |
| 147 | + |
| 148 | +`Server.MESSAGINGDEFAULT` |
| 149 | + |
| 150 | +## Response Type |
| 151 | + |
| 152 | +`void` |
| 153 | + |
| 154 | +## Example Usage |
| 155 | + |
| 156 | +```java |
| 157 | +String accountId = "900000"; |
| 158 | +String mediaId = "my-media-id"; |
| 159 | +FileWrapper body = new FileWrapper(new File("dummy_file"), "optional-content-type"); |
| 160 | +String contentType = "audio/wav"; |
| 161 | +String cacheControl = "no-cache"; |
| 162 | + |
| 163 | +aPIController.uploadMediaAsync(accountId, mediaId, body, contentType, cacheControl).thenAccept(result -> { |
| 164 | + // TODO success callback handler |
| 165 | +}).exceptionally(exception -> { |
| 166 | + // TODO failure callback handler |
| 167 | + return null; |
| 168 | +}); |
| 169 | +``` |
| 170 | + |
| 171 | +## Errors |
| 172 | + |
| 173 | +| HTTP Status Code | Error Description | Exception Class | |
| 174 | +| --- | --- | --- | |
| 175 | +| 400 | 400 Request is malformed or invalid | [`MessagingException`]($m/Messaging/MessagingException) | |
| 176 | +| 401 | 401 The specified user does not have access to the account | [`MessagingException`]($m/Messaging/MessagingException) | |
| 177 | +| 403 | 403 The user does not have access to this API | [`MessagingException`]($m/Messaging/MessagingException) | |
| 178 | +| 404 | 404 Path not found | [`MessagingException`]($m/Messaging/MessagingException) | |
| 179 | +| 415 | 415 The content-type of the request is incorrect | [`MessagingException`]($m/Messaging/MessagingException) | |
| 180 | +| 429 | 429 The rate limit has been reached | [`MessagingException`]($m/Messaging/MessagingException) | |
| 181 | + |
| 182 | + |
| 183 | +# Delete Media |
| 184 | + |
| 185 | +Deletes a media file from Bandwidth API server. Make sure you don't have any application scripts still using the media before you delete. If you accidentally delete a media file, you can immediately upload a new file with the same name. |
| 186 | + |
| 187 | +```java |
| 188 | +CompletableFuture<ApiResponse<Void>> deleteMediaAsync( |
| 189 | + final String accountId, |
| 190 | + final String mediaId) |
| 191 | +``` |
| 192 | + |
| 193 | +## Parameters |
| 194 | + |
| 195 | +| Parameter | Type | Tags | Description | |
| 196 | +| --- | --- | --- | --- | |
| 197 | +| `accountId` | `String` | Template, Required | User's account ID | |
| 198 | +| `mediaId` | `String` | Template, Required | The media ID to delete<br>**Constraints**: *Pattern*: `.+` | |
| 199 | + |
| 200 | +## Server |
| 201 | + |
| 202 | +`Server.MESSAGINGDEFAULT` |
| 203 | + |
| 204 | +## Response Type |
| 205 | + |
| 206 | +`void` |
| 207 | + |
| 208 | +## Example Usage |
| 209 | + |
| 210 | +```java |
| 211 | +String accountId = "900000"; |
| 212 | +String mediaId = "tjdla-4562ld"; |
| 213 | + |
| 214 | +aPIController.deleteMediaAsync(accountId, mediaId).thenAccept(result -> { |
| 215 | + // TODO success callback handler |
| 216 | +}).exceptionally(exception -> { |
| 217 | + // TODO failure callback handler |
| 218 | + return null; |
| 219 | +}); |
| 220 | +``` |
| 221 | + |
| 222 | +## Errors |
| 223 | + |
| 224 | +| HTTP Status Code | Error Description | Exception Class | |
| 225 | +| --- | --- | --- | |
| 226 | +| 400 | 400 Request is malformed or invalid | [`MessagingException`]($m/Messaging/MessagingException) | |
| 227 | +| 401 | 401 The specified user does not have access to the account | [`MessagingException`]($m/Messaging/MessagingException) | |
| 228 | +| 403 | 403 The user does not have access to this API | [`MessagingException`]($m/Messaging/MessagingException) | |
| 229 | +| 404 | 404 Path not found | [`MessagingException`]($m/Messaging/MessagingException) | |
| 230 | +| 415 | 415 The content-type of the request is incorrect | [`MessagingException`]($m/Messaging/MessagingException) | |
| 231 | +| 429 | 429 The rate limit has been reached | [`MessagingException`]($m/Messaging/MessagingException) | |
| 232 | + |
| 233 | + |
| 234 | +# Get Messages |
| 235 | + |
| 236 | +Gets a list of messages based on query parameters. |
| 237 | + |
| 238 | +```java |
| 239 | +CompletableFuture<ApiResponse<BandwidthMessagesList>> getMessagesAsync( |
| 240 | + final String accountId, |
| 241 | + final String messageId, |
| 242 | + final String sourceTn, |
| 243 | + final String destinationTn, |
| 244 | + final String messageStatus, |
| 245 | + final Integer errorCode, |
| 246 | + final String fromDateTime, |
| 247 | + final String toDateTime, |
| 248 | + final String pageToken, |
| 249 | + final Integer limit) |
| 250 | +``` |
| 251 | + |
| 252 | +## Parameters |
| 253 | + |
| 254 | +| Parameter | Type | Tags | Description | |
| 255 | +| --- | --- | --- | --- | |
| 256 | +| `accountId` | `String` | Template, Required | User's account ID | |
| 257 | +| `messageId` | `String` | Query, Optional | The ID of the message to search for. Special characters need to be encoded using URL encoding | |
| 258 | +| `sourceTn` | `String` | Query, Optional | The phone number that sent the message | |
| 259 | +| `destinationTn` | `String` | Query, Optional | The phone number that received the message | |
| 260 | +| `messageStatus` | `String` | Query, Optional | The status of the message. One of RECEIVED, QUEUED, SENDING, SENT, FAILED, DELIVERED, ACCEPTED, UNDELIVERED | |
| 261 | +| `errorCode` | `Integer` | Query, Optional | The error code of the message | |
| 262 | +| `fromDateTime` | `String` | Query, Optional | The start of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days. | |
| 263 | +| `toDateTime` | `String` | Query, Optional | The end of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days. | |
| 264 | +| `pageToken` | `String` | Query, Optional | A base64 encoded value used for pagination of results | |
| 265 | +| `limit` | `Integer` | Query, Optional | The maximum records requested in search result. Default 100. The sum of limit and after cannot be more than 10000 | |
| 266 | + |
| 267 | +## Server |
| 268 | + |
| 269 | +`Server.MESSAGINGDEFAULT` |
| 270 | + |
| 271 | +## Response Type |
| 272 | + |
| 273 | +[`BandwidthMessagesList`]($m/Messaging/BandwidthMessagesList) |
| 274 | + |
| 275 | +## Example Usage |
| 276 | + |
| 277 | +```java |
| 278 | +String accountId = "900000"; |
| 279 | +String messageId = "9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6"; |
| 280 | +String sourceTn = "%2B15554443333"; |
| 281 | +String destinationTn = "%2B15554443333"; |
| 282 | +String messageStatus = "RECEIVED"; |
| 283 | +Integer errorCode = 9902; |
| 284 | +String fromDateTime = "2016-09-14T18:20:16.000Z"; |
| 285 | +String toDateTime = "2016-09-14T18:20:16.000Z"; |
| 286 | +String pageToken = "gdEewhcJLQRB5"; |
| 287 | +Integer limit = 50; |
| 288 | + |
| 289 | +aPIController.getMessagesAsync(accountId, messageId, sourceTn, destinationTn, messageStatus, errorCode, fromDateTime, toDateTime, pageToken, limit).thenAccept(result -> { |
| 290 | + // TODO success callback handler |
| 291 | +}).exceptionally(exception -> { |
| 292 | + // TODO failure callback handler |
| 293 | + return null; |
| 294 | +}); |
| 295 | +``` |
| 296 | + |
| 297 | +## Errors |
| 298 | + |
| 299 | +| HTTP Status Code | Error Description | Exception Class | |
| 300 | +| --- | --- | --- | |
| 301 | +| 400 | 400 Request is malformed or invalid | [`MessagingException`]($m/Messaging/MessagingException) | |
| 302 | +| 401 | 401 The specified user does not have access to the account | [`MessagingException`]($m/Messaging/MessagingException) | |
| 303 | +| 403 | 403 The user does not have access to this API | [`MessagingException`]($m/Messaging/MessagingException) | |
| 304 | +| 404 | 404 Path not found | [`MessagingException`]($m/Messaging/MessagingException) | |
| 305 | +| 415 | 415 The content-type of the request is incorrect | [`MessagingException`]($m/Messaging/MessagingException) | |
| 306 | +| 429 | 429 The rate limit has been reached | [`MessagingException`]($m/Messaging/MessagingException) | |
| 307 | + |
| 308 | + |
| 309 | +# Create Message |
| 310 | + |
| 311 | +Endpoint for sending text messages and picture messages using V2 messaging. |
| 312 | + |
| 313 | +```java |
| 314 | +CompletableFuture<ApiResponse<BandwidthMessage>> createMessageAsync( |
| 315 | + final String accountId, |
| 316 | + final MessageRequest body) |
| 317 | +``` |
| 318 | + |
| 319 | +## Parameters |
| 320 | + |
| 321 | +| Parameter | Type | Tags | Description | |
| 322 | +| --- | --- | --- | --- | |
| 323 | +| `accountId` | `String` | Template, Required | User's account ID | |
| 324 | +| `body` | [`MessageRequest`]($m/Messaging/MessageRequest) | Body, Required | - | |
| 325 | + |
| 326 | +## Server |
| 327 | + |
| 328 | +`Server.MESSAGINGDEFAULT` |
| 329 | + |
| 330 | +## Response Type |
| 331 | + |
| 332 | +[`BandwidthMessage`]($m/Messaging/BandwidthMessage) |
| 333 | + |
| 334 | +## Example Usage |
| 335 | + |
| 336 | +```java |
| 337 | +String accountId = "900000"; |
| 338 | +MessageRequest body = new MessageRequest(); |
| 339 | +body.setApplicationId("93de2206-9669-4e07-948d-329f4b722ee2"); |
| 340 | +body.setTo(new LinkedList<>()); |
| 341 | +body.getTo().add("+15554443333"); |
| 342 | +body.getTo().add("+15552223333"); |
| 343 | +body.setFrom("+15551113333"); |
| 344 | + |
| 345 | +aPIController.createMessageAsync(accountId, body).thenAccept(result -> { |
| 346 | + // TODO success callback handler |
| 347 | +}).exceptionally(exception -> { |
| 348 | + // TODO failure callback handler |
| 349 | + return null; |
| 350 | +}); |
| 351 | +``` |
| 352 | + |
| 353 | +## Errors |
| 354 | + |
| 355 | +| HTTP Status Code | Error Description | Exception Class | |
| 356 | +| --- | --- | --- | |
| 357 | +| 400 | 400 Request is malformed or invalid | [`MessagingException`]($m/Messaging/MessagingException) | |
| 358 | +| 401 | 401 The specified user does not have access to the account | [`MessagingException`]($m/Messaging/MessagingException) | |
| 359 | +| 403 | 403 The user does not have access to this API | [`MessagingException`]($m/Messaging/MessagingException) | |
| 360 | +| 404 | 404 Path not found | [`MessagingException`]($m/Messaging/MessagingException) | |
| 361 | +| 415 | 415 The content-type of the request is incorrect | [`MessagingException`]($m/Messaging/MessagingException) | |
| 362 | +| 429 | 429 The rate limit has been reached | [`MessagingException`]($m/Messaging/MessagingException) | |
| 363 | + |
0 commit comments