Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

bwdb-15583-new #1163

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
262 changes: 142 additions & 120 deletions site/specs/messaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,29 +83,34 @@ paths:
}
- lang: Java
source: |
import com.bandwidth.BandwidthClient;
import com.bandwidth.http.response.ApiResponse;
import com.bandwidth.messaging.models.Media;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.List;

public class Sample {
public static final String USERNAME = "api-username";
public static final String PASSWORD = "api-password";
public static final String ACCOUNT_ID = "12345";

import com.bandwidth.sdk.ApiClient;
import com.bandwidth.sdk.ApiException;
import com.bandwidth.sdk.Configuration;
import com.bandwidth.sdk.auth.*;
import com.bandwidth.sdk.models.*;
import com.bandwidth.sdk.api.MediaApi;

public class Example {
public static void main(String[] args) {
BandwidthClient client = new BandwidthClient.Builder()
.messagingBasicAuthCredentials(USERNAME, PASSWORD)
.build();
ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure HTTP basic authorization: Basic
HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
Basic.setUsername("YOUR USERNAME");
Basic.setPassword("YOUR PASSWORD");

MediaApi apiInstance = new MediaApi(defaultClient);
String accountId = "9900000"; // String | Your Bandwidth Account ID.
String continuationToken = "1XEi2tsFtLo1JbtLwETnM1ZJ+PqAa8w6ENvC5QKvwyrCDYII663Gy5M4s40owR1tjkuWUif6qbWvFtQJR5/ipqbUnfAqL254LKNlPy6tATCzioKSuHuOqgzloDkSwRtX0LtcL2otHS69hK343m+SjdL+vlj71tT39"; // String | Continuation token used to retrieve subsequent media.
try {
CompletableFuture<ApiResponse<List<Media>>> completableFuture = client.getMessagingClient().getAPIController().listMediaAsync(ACCOUNT_ID, null);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
List<Media> result = apiInstance.listMedia(accountId, continuationToken);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MediaApi#listMedia");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Expand Down Expand Up @@ -496,32 +501,36 @@ paths:
}
- lang: Java
source: |
import com.bandwidth.BandwidthClient;
import com.bandwidth.http.response.ApiResponse;
import com.bandwidth.utilities.FileWrapper;

import java.io.File;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class Sample {
public static final String USERNAME = "api-username";
public static final String PASSWORD = "api-password";
public static final String ACCOUNT_ID = "12345";

import com.bandwidth.sdk.ApiClient;
import com.bandwidth.sdk.ApiException;
import com.bandwidth.sdk.Configuration;
import com.bandwidth.sdk.auth.*;
import com.bandwidth.sdk.models.*;
import com.bandwidth.sdk.api.MediaApi;

public class Example {
public static void main(String[] args) {
BandwidthClient client = new BandwidthClient.Builder()
.messagingBasicAuthCredentials(USERNAME, PASSWORD)
.build();

String mediaId = "media-id-123";
FileWrapper fileWrapper = new FileWrapper(new File("/path/to/file"));

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure HTTP basic authorization: Basic
HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
Basic.setUsername("YOUR USERNAME");
Basic.setPassword("YOUR PASSWORD");

MediaApi apiInstance = new MediaApi(defaultClient);
String accountId = "9900000"; // String | Your Bandwidth Account ID.
String mediaId = "14762070468292kw2fuqty55yp2b2/0/bw.png"; // String | Media ID to retrieve.
File body = new File("/path/to/file"); // File |
String contentType = "audio/wav"; // String | The media type of the entity-body.
String cacheControl = "no-cache"; // String | General-header field is used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain.
try {
CompletableFuture<ApiResponse<Void>> completableFuture = client.getMessagingClient().getAPIController().uploadMediaAsync(ACCOUNT_ID, mediaId, fileWrapper, "content/type", "no-cache");
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
apiInstance.uploadMedia(accountId, mediaId, body, contentType, cacheControl);
} catch (ApiException e) {
System.err.println("Exception when calling MediaApi#uploadMedia");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Expand Down Expand Up @@ -740,32 +749,34 @@ paths:
}
- lang: Java
source: |
import com.bandwidth.BandwidthClient;
import com.bandwidth.http.response.ApiResponse;
import com.bandwidth.messaging.models.BandwidthMessage;
import com.bandwidth.messaging.models.MessageRequest;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.Collections;

public class Sample {
public static final String USERNAME = "api-username";
public static final String PASSWORD = "api-password";
public static final String ACCOUNT_ID = "12345";

import com.bandwidth.sdk.ApiClient;
import com.bandwidth.sdk.ApiException;
import com.bandwidth.sdk.Configuration;
import com.bandwidth.sdk.auth.*;
import com.bandwidth.sdk.models.*;
import com.bandwidth.sdk.api.MediaApi;

public class Example {
public static void main(String[] args) {
String mediaId = "media-id-123";
ApiClient defaultClient = Configuration.getDefaultApiClient();

BandwidthClient client = new BandwidthClient.Builder()
.messagingBasicAuthCredentials(USERNAME, PASSWORD)
.build();
// Configure HTTP basic authorization: Basic
HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
Basic.setUsername("YOUR USERNAME");
Basic.setPassword("YOUR PASSWORD");

MediaApi apiInstance = new MediaApi(defaultClient);
String accountId = "9900000"; // String | Your Bandwidth Account ID.
String mediaId = "14762070468292kw2fuqty55yp2b2/0/bw.png"; // String | Media ID to retrieve.
try {
CompletableFuture<ApiResponse<Void>> completableFuture = client.getMessagingClient().getAPIController().deleteMediaAsync(ACCOUNT_ID, mediaId);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
File result = apiInstance.getMedia(accountId, mediaId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MediaApi#getMedia");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Expand Down Expand Up @@ -947,30 +958,48 @@ paths:
}
- lang: Java
source: |
import com.bandwidth.BandwidthClient;
import com.bandwidth.http.response.ApiResponse;
import com.bandwidth.messaging.models.BandwidthMessagesList;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class Sample {
public static final String USERNAME = "api-username";
public static final String PASSWORD = "api-password";
public static final String ACCOUNT_ID = "12345";

import com.bandwidth.sdk.ApiClient;
import com.bandwidth.sdk.ApiException;
import com.bandwidth.sdk.Configuration;
import com.bandwidth.sdk.auth.*;
import com.bandwidth.sdk.models.*;
import com.bandwidth.sdk.api.MessagesApi;

public class Example {
public static void main(String[] args) {
String bandwidthNumber = "+15554443333";

BandwidthClient client = new BandwidthClient.Builder()
.messagingBasicAuthCredentials(USERNAME, PASSWORD)
.build();

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure HTTP basic authorization: Basic
HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
Basic.setUsername("YOUR USERNAME");
Basic.setPassword("YOUR PASSWORD");

MessagesApi apiInstance = new MessagesApi(defaultClient);
String accountId = "9900000"; // String | Your Bandwidth Account ID.
String messageId = "9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6"; // String | The ID of the message to search for. Special characters need to be encoded using URL encoding. Message IDs could come in different formats, e.g., 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 and 1589228074636lm4k2je7j7jklbn2 are valid message ID formats. Note that you must include at least one query parameter.
String sourceTn = "%2B15554443333"; // String | The phone number that sent the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. '%2B1919').
String destinationTn = "%2B15554443333"; // String | The phone number that received the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. '%2B1919').
MessageStatusEnum messageStatus = MessageStatusEnum.fromValue("RECEIVED"); // MessageStatusEnum | The status of the message. One of RECEIVED QUEUED SENDING SENT FAILED DELIVERED ACCEPTED UNDELIVERED.
ListMessageDirectionEnum messageDirection = ListMessageDirectionEnum.fromValue("INBOUND"); // ListMessageDirectionEnum | The direction of the message. One of INBOUND OUTBOUND.
String carrierName = "Verizon"; // String | The name of the carrier used for this message. Possible values include but are not limited to Verizon and TMobile. Special characters need to be encoded using URL encoding (i.e. AT&T should be passed as AT%26T).
MessageTypeEnum messageType = MessageTypeEnum.fromValue("sms"); // MessageTypeEnum | The type of message. Either sms or mms.
Integer errorCode = 9902; // Integer | The error code of the message.
String fromDateTime = "2022-09-14T18:20:16.000Z"; // String | 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.
String toDateTime = "2022-09-14T18:20:16.000Z"; // String | 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.
String campaignId = "CJEUMDK"; // String | The campaign ID of the message.
String sort = "sourceTn:desc"; // String | The field and direction to sort by combined with a colon. Direction is either asc or desc.
String pageToken = "gdEewhcJLQRB5"; // String | A base64 encoded value used for pagination of results.
Integer limit = 50; // Integer | The maximum records requested in search result. Default 100. The sum of limit and after cannot be more than 10000.
Boolean limitTotalCount = true; // Boolean | When set to true, the response's totalCount field will have a maximum value of 10,000. When set to false, or excluded, this will give an accurate totalCount of all messages that match the provided filters. If you are experiencing latency, try using this parameter to limit your results.
try {
CompletableFuture<ApiResponse<BandwidthMessagesList>> completableFuture = client.getMessagingClient().getAPIController().getMessagesAsync(ACCOUNT_ID, null, bandwidthNumber, null, null, null, null, null, null, null);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
MessagesList result = apiInstance.listMessages(accountId, messageId, sourceTn, destinationTn, messageStatus, messageDirection, carrierName, messageType, errorCode, fromDateTime, toDateTime, campaignId, sort, pageToken, limit, limitTotalCount);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MessagesApi#listMessages");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Expand Down Expand Up @@ -1171,40 +1200,33 @@ paths:
}
- lang: Java
source: |
import com.bandwidth.BandwidthClient;
import com.bandwidth.http.response.ApiResponse;
import com.bandwidth.messaging.models.BandwidthMessage;
import com.bandwidth.messaging.models.MessageRequest;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.Collections;

public class Sample {
public static final String USERNAME = "api-username";
public static final String PASSWORD = "api-password";
public static final String ACCOUNT_ID = "12345";

import com.bandwidth.sdk.ApiClient;
import com.bandwidth.sdk.ApiException;
import com.bandwidth.sdk.Configuration;
import com.bandwidth.sdk.auth.*;
import com.bandwidth.sdk.models.*;
import com.bandwidth.sdk.api.MessagesApi;

public class Example {
public static void main(String[] args) {
String messagingApplicationId = "1234-asdf";
String to = "+15553334444";
String from = "+15554443333";

BandwidthClient client = new BandwidthClient.Builder()
.messagingBasicAuthCredentials(USERNAME, PASSWORD)
.build();

MessageRequest request = new MessageRequest();
request.setApplicationId(messagingApplicationId);
request.setTo(Collections.singletonList(to));
request.setFrom(from);
request.setText("Hello world");

ApiClient defaultClient = Configuration.getDefaultApiClient();
// Configure HTTP basic authorization: Basic
HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
Basic.setUsername("YOUR USERNAME");
Basic.setPassword("YOUR PASSWORD");

MessagesApi apiInstance = new MessagesApi(defaultClient);
String accountId = "9900000"; // String | Your Bandwidth Account ID.
MessageRequest messageRequest = new MessageRequest(); // MessageRequest |
try {
CompletableFuture<ApiResponse<BandwidthMessage>> completableFuture = client.getMessagingClient().getAPIController().createMessageAsync(ACCOUNT_ID, request);
System.out.println(completableFuture.get().getResult());
} catch (InterruptedException | ExecutionException e) {
System.out.println(e.getMessage());
Message result = apiInstance.createMessage(accountId, messageRequest);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MessagesApi#createMessage");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Expand Down
Loading
Loading