Skip to content

Add WhatsApp Sandbox support to Conversations API #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Sep 16, 2019
Merged
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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ If you server doesn't have a direct connection to the internet you can setup a p
messageBirdService.setProxy(proxy);
```

##### Conversations WhatsApp Sandbox
To use the whatsapp sandbox you need to add `MessageBirdClient.ENABLE_CONVERSATION_API_WHATSAPP_SANDBOX` to the list of features you want enabled. Don't forget to replace `YOUR_ACCESS_KEY` with your actual access key.

```java
// Create a MessageBirdService
final MessageBirdService messageBirdService = new MessageBirdServiceImpl("YOUR_ACCESS_KEY");
// Add the service to the client
final MessageBirdClient messageBirdClient = new MessageBirdClient(messageBirdService, new MessageBirdClient.Feature[]{MessageBirdClient.Feature.ENABLE_CONVERSATION_API_WHATSAPP_SANDBOX});
```

Documentation
-------------
Complete documentation, instructions, and examples are available at:
Expand Down
15 changes: 14 additions & 1 deletion api/src/main/java/com/messagebird/MessageBirdClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public class MessageBirdClient {
* can, however, override this behaviour by providing absolute URLs
* ourselves.
*/
private static final String CONVERSATIONS_BASE_URL = "https://conversations.messagebird.com/v1";
private String CONVERSATIONS_BASE_URL = "https://conversations.messagebird.com/v1";
private static final String CONVERSATIONS_WHATSAPP_SANDBOX_BASE_URL ="https://whatsapp-sandbox.messagebird.com/v1";

static final String VOICE_CALLS_BASE_URL = "https://voice.messagebird.com";
private static String[] supportedLanguages = {"de-DE", "en-AU", "en-UK", "en-US", "es-ES", "es-LA", "fr-FR", "it-IT", "nl-NL", "pt-BR"};

Expand All @@ -68,10 +70,21 @@ public class MessageBirdClient {

private MessageBirdService messageBirdService;


public enum Feature {
ENABLE_CONVERSATION_API_WHATSAPP_SANDBOX
}

public MessageBirdClient(final MessageBirdService messageBirdService) {
this.messageBirdService = messageBirdService;
}

public MessageBirdClient(final MessageBirdService messageBirdService, Feature[] features) {
this.messageBirdService = messageBirdService;
if(Arrays.asList(features).contains(Feature.ENABLE_CONVERSATION_API_WHATSAPP_SANDBOX)) {
this.CONVERSATIONS_BASE_URL = CONVERSATIONS_WHATSAPP_SANDBOX_BASE_URL;
}
}
/****************************************************************************************************/
/** Balance and HRL methods **/
/****************************************************************************************************/
Expand Down