Getting started
Installation
npm install @bandwidth/messaging
Initialization
Authentication
In order to setup authentication in the API client, you need the following information.
Parameter | Description |
---|
basicAuthUserName | The username to use with basic authentication |
basicAuthPassword | The password to use with basic authentication |
API client can be initialized as following:
const BandwidthMessaging = require('@bandwidth/messaging');
BandwidthMessaging.Configuration.basicAuthUserName = "apitoken";
BandwidthMessaging.Configuration.basicAuthPassword = "apisecret";
Class Reference
List of Controllers
APIController
Get singleton instance
The singleton instance of the APIController
class can be accessed from the API Client.
var controller = lib.APIController;
createMessage
createMessage
function createMessage(userId, body, callback)
Parameters
Parameter | Tags | Description |
---|
userId | Required | TODO: Add a parameter description |
body | Optional | TODO: Add a parameter description |
Example Usage
var userId = 'userId';
var body = new BandwidthMessaging.MessageRequest({"key":"value"});
controller.createMessage(userId, body, function(error, response, context) {
});
Errors
Error Code | Error Description |
---|
400 | 400 Request is malformed or invalid |
401 | 401 The specified user does not have access to the account |
403 | 403 The user does not have access to this API |
404 | 404 Path not found |
415 | 415 The content-type of the request is incorrect |
429 | 429 The rate limit has been reached |
listMedia
listMedia
function listMedia(userId, continuationToken, callback)
Parameters
Parameter | Tags | Description |
---|
userId | Required | TODO: Add a parameter description |
continuationToken | Optional | TODO: Add a parameter description |
Example Usage
var userId = 'userId';
var continuationToken = 'Continuation-Token';
controller.listMedia(userId, continuationToken, function(error, response, context) {
});
Errors
Error Code | Error Description |
---|
400 | 400 Request is malformed or invalid |
401 | 401 The specified user does not have access to the account |
403 | 403 The user does not have access to this API |
404 | 404 Path not found |
415 | 415 The content-type of the request is incorrect |
429 | 429 The rate limit has been reached |
getMedia
getMedia
function getMedia(userId, mediaId, callback)
Parameters
Parameter | Tags | Description |
---|
userId | Required | TODO: Add a parameter description |
mediaId | Required | TODO: Add a parameter description |
Example Usage
var userId = 'userId';
var mediaId = 'mediaId';
controller.getMedia(userId, mediaId, function(error, response, context) {
});
Errors
Error Code | Error Description |
---|
400 | 400 Request is malformed or invalid |
401 | 401 The specified user does not have access to the account |
403 | 403 The user does not have access to this API |
404 | 404 Path not found |
415 | 415 The content-type of the request is incorrect |
429 | 429 The rate limit has been reached |
uploadMedia
uploadMedia
function uploadMedia(userId, mediaId, contentLength, body, contentType, cacheControl, callback)
Parameters
Parameter | Tags | Description |
---|
userId | Required | TODO: Add a parameter description |
mediaId | Required | TODO: Add a parameter description |
contentLength | Required | TODO: Add a parameter description |
body | Required | TODO: Add a parameter description |
contentType | Optional | TODO: Add a parameter description |
cacheControl | Optional | TODO: Add a parameter description |
Example Usage
var userId = 'userId';
var mediaId = 'mediaId';
var contentLength = 217;
var body = 'body';
var contentType = 'Content-Type';
var cacheControl = 'Cache-Control';
controller.uploadMedia(userId, mediaId, contentLength, body, contentType, cacheControl, function(error, response, context) {
});
Errors
Error Code | Error Description |
---|
400 | 400 Request is malformed or invalid |
401 | 401 The specified user does not have access to the account |
403 | 403 The user does not have access to this API |
404 | 404 Path not found |
415 | 415 The content-type of the request is incorrect |
429 | 429 The rate limit has been reached |
deleteMedia
deleteMedia
function deleteMedia(userId, mediaId, callback)
Parameters
Parameter | Tags | Description |
---|
userId | Required | TODO: Add a parameter description |
mediaId | Required | TODO: Add a parameter description |
Example Usage
var userId = 'userId';
var mediaId = 'mediaId';
controller.deleteMedia(userId, mediaId, function(error, response, context) {
});
Errors
Error Code | Error Description |
---|
400 | 400 Request is malformed or invalid |
401 | 401 The specified user does not have access to the account |
403 | 403 The user does not have access to this API |
404 | 404 Path not found |
415 | 415 The content-type of the request is incorrect |
429 | 429 The rate limit has been reached |
Back to List of Controllers