Skip to content

Commit 2638d2a

Browse files
authored
Merge pull request #136 from rjelierse/master
Revert "Merge pull request #65 from mariuspot/master"
2 parents 31d1446 + d7027b7 commit 2638d2a

File tree

3 files changed

+15
-90
lines changed

3 files changed

+15
-90
lines changed

README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,6 @@ If you server doesn't have a direct connection to the internet you can setup a p
115115
messageBirdService.setProxy(proxy);
116116
```
117117

118-
##### Conversations WhatsApp Sandbox
119-
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.
120-
121-
```java
122-
// Create a MessageBirdService
123-
final MessageBirdService messageBirdService = new MessageBirdServiceImpl("YOUR_ACCESS_KEY");
124-
// Add the service to the client
125-
final MessageBirdClient messageBirdClient = new MessageBirdClient(messageBirdService, List.of(MessageBirdClient.Feature.ENABLE_CONVERSATION_API_WHATSAPP_SANDBOX));
126-
```
127-
128118
Documentation
129119
-------------
130120
Complete documentation, instructions, and examples are available at:

api/src/main/java/com/messagebird/MessageBirdClient.java

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ public class MessageBirdClient {
9595
* can, however, override this behaviour by providing absolute URLs
9696
* ourselves.
9797
*/
98-
private static final String BASE_URL_CONVERSATIONS = "https://conversations.messagebird.com/v1";
99-
private static final String BASE_URL_CONVERSATIONS_WHATSAPP_SANDBOX = "https://whatsapp-sandbox.messagebird.com/v1";
100-
98+
private static final String CONVERSATIONS_BASE_URL = "https://conversations.messagebird.com/v1";
10199
static final String VOICE_CALLS_BASE_URL = "https://voice.messagebird.com";
102100
static final String NUMBERS_CALLS_BASE_URL = "https://numbers.messagebird.com/v1";
103101
private static String[] supportedLanguages = {"de-DE", "en-AU", "en-UK", "en-US", "es-ES", "es-LA", "fr-FR", "it-IT", "nl-NL", "pt-BR"};
@@ -136,23 +134,11 @@ public class MessageBirdClient {
136134
private final String DOWNLOADS = "Downloads";
137135

138136
private MessageBirdService messageBirdService;
139-
private String conversationsBaseUrl;
140-
141-
public enum Feature {
142-
ENABLE_CONVERSATION_API_WHATSAPP_SANDBOX
143-
}
144137

145138
public MessageBirdClient(final MessageBirdService messageBirdService) {
146139
this.messageBirdService = messageBirdService;
147-
this.conversationsBaseUrl = BASE_URL_CONVERSATIONS;
148140
}
149141

150-
public MessageBirdClient(final MessageBirdService messageBirdService, List<Feature> features) {
151-
this(messageBirdService);
152-
if(features.indexOf(Feature.ENABLE_CONVERSATION_API_WHATSAPP_SANDBOX) >= 0) {
153-
this.conversationsBaseUrl = BASE_URL_CONVERSATIONS_WHATSAPP_SANDBOX;
154-
}
155-
}
156142
/****************************************************************************************************/
157143
/** Balance and HRL methods **/
158144
/****************************************************************************************************/
@@ -897,7 +883,7 @@ public Conversation viewConversation(final String id) throws NotFoundException,
897883
if (id == null) {
898884
throw new IllegalArgumentException("Id must be specified");
899885
}
900-
String url = this.conversationsBaseUrl + CONVERSATION_PATH;
886+
String url = CONVERSATIONS_BASE_URL + CONVERSATION_PATH;
901887
return messageBirdService.requestByID(url, id, Conversation.class);
902888
}
903889

@@ -913,7 +899,7 @@ public Conversation updateConversation(final String id, final ConversationStatus
913899
if (id == null) {
914900
throw new IllegalArgumentException("Id must be specified.");
915901
}
916-
String url = String.format("%s%s/%s", this.conversationsBaseUrl, CONVERSATION_PATH, id);
902+
String url = String.format("%s%s/%s", CONVERSATIONS_BASE_URL, CONVERSATION_PATH, id);
917903
return messageBirdService.sendPayLoad("PATCH", url, status, Conversation.class);
918904
}
919905

@@ -926,7 +912,7 @@ public Conversation updateConversation(final String id, final ConversationStatus
926912
*/
927913
public ConversationList listConversations(final int offset, final int limit)
928914
throws UnauthorizedException, GeneralException {
929-
String url = this.conversationsBaseUrl + CONVERSATION_PATH;
915+
String url = CONVERSATIONS_BASE_URL + CONVERSATION_PATH;
930916
return messageBirdService.requestList(url, offset, limit, ConversationList.class);
931917
}
932918

@@ -950,7 +936,7 @@ public ConversationList listConversations() throws UnauthorizedException, Genera
950936
*/
951937
public Conversation startConversation(ConversationStartRequest request)
952938
throws UnauthorizedException, GeneralException {
953-
String url = String.format("%s%s/start", this.conversationsBaseUrl, CONVERSATION_PATH);
939+
String url = String.format("%s%s/start", CONVERSATIONS_BASE_URL, CONVERSATION_PATH);
954940
return messageBirdService.sendPayLoad(url, request, Conversation.class);
955941
}
956942

@@ -962,7 +948,7 @@ public Conversation startConversation(ConversationStartRequest request)
962948
*/
963949
public ConversationSendResponse sendMessage(ConversationSendRequest request)
964950
throws UnauthorizedException, GeneralException {
965-
String url = String.format("%s%s", this.conversationsBaseUrl, CONVERSATION_SEND_PATH);
951+
String url = String.format("%s%s", CONVERSATIONS_BASE_URL, CONVERSATION_SEND_PATH);
966952
return messageBirdService.sendPayLoad(url, request, ConversationSendResponse.class);
967953
}
968954

@@ -981,7 +967,7 @@ public ConversationMessageList listConversationMessages(
981967
) throws UnauthorizedException, GeneralException {
982968
String url = String.format(
983969
"%s%s/%s%s",
984-
this.conversationsBaseUrl,
970+
CONVERSATIONS_BASE_URL,
985971
CONVERSATION_PATH,
986972
conversationId,
987973
CONVERSATION_MESSAGE_PATH
@@ -1012,7 +998,7 @@ public ConversationMessageList listConversationMessages(
1012998
*/
1013999
public ConversationMessage viewConversationMessage(final String messageId)
10141000
throws NotFoundException, GeneralException, UnauthorizedException {
1015-
String url = this.conversationsBaseUrl + CONVERSATION_MESSAGE_PATH;
1001+
String url = CONVERSATIONS_BASE_URL + CONVERSATION_MESSAGE_PATH;
10161002
return messageBirdService.requestByID(url, messageId, ConversationMessage.class);
10171003
}
10181004

@@ -1029,7 +1015,7 @@ public ConversationMessage sendConversationMessage(
10291015
) throws UnauthorizedException, GeneralException {
10301016
String url = String.format(
10311017
"%s%s/%s%s",
1032-
this.conversationsBaseUrl,
1018+
CONVERSATIONS_BASE_URL,
10331019
CONVERSATION_PATH,
10341020
conversationId,
10351021
CONVERSATION_MESSAGE_PATH
@@ -1044,7 +1030,7 @@ public ConversationMessage sendConversationMessage(
10441030
*/
10451031
public void deleteConversationWebhook(final String webhookId)
10461032
throws NotFoundException, GeneralException, UnauthorizedException {
1047-
String url = this.conversationsBaseUrl + CONVERSATION_WEBHOOK_PATH;
1033+
String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH;
10481034
messageBirdService.deleteByID(url, webhookId);
10491035
}
10501036

@@ -1056,7 +1042,7 @@ public void deleteConversationWebhook(final String webhookId)
10561042
*/
10571043
public ConversationWebhook sendConversationWebhook(final ConversationWebhookCreateRequest request)
10581044
throws UnauthorizedException, GeneralException {
1059-
String url = this.conversationsBaseUrl + CONVERSATION_WEBHOOK_PATH;
1045+
String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH;
10601046
return messageBirdService.sendPayLoad(url, request, ConversationWebhook.class);
10611047
}
10621048

@@ -1071,7 +1057,7 @@ public ConversationWebhook updateConversationWebhook(final String id, final Conv
10711057
throw new IllegalArgumentException("Conversation webhook ID must be specified.");
10721058
}
10731059

1074-
String url = this.conversationsBaseUrl + CONVERSATION_WEBHOOK_PATH + "/" + id;
1060+
String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH + "/" + id;
10751061
return messageBirdService.sendPayLoad("PATCH", url, request, ConversationWebhook.class);
10761062
}
10771063

@@ -1082,7 +1068,7 @@ public ConversationWebhook updateConversationWebhook(final String id, final Conv
10821068
* @return The retrieved webhook.
10831069
*/
10841070
public ConversationWebhook viewConversationWebhook(final String webhookId) throws NotFoundException, GeneralException, UnauthorizedException {
1085-
String url = this.conversationsBaseUrl + CONVERSATION_WEBHOOK_PATH;
1071+
String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH;
10861072
return messageBirdService.requestByID(url, webhookId, ConversationWebhook.class);
10871073
}
10881074

@@ -1095,7 +1081,7 @@ public ConversationWebhook viewConversationWebhook(final String webhookId) throw
10951081
*/
10961082
public ConversationWebhookList listConversationWebhooks(final int offset, final int limit)
10971083
throws UnauthorizedException, GeneralException {
1098-
String url = this.conversationsBaseUrl + CONVERSATION_WEBHOOK_PATH;
1084+
String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH;
10991085
return messageBirdService.requestList(url, offset, limit, ConversationWebhookList.class);
11001086
}
11011087

@@ -1781,4 +1767,4 @@ public void cancelNumber(String number) throws UnauthorizedException, GeneralExc
17811767
final String url = String.format("%s/phone-numbers", NUMBERS_CALLS_BASE_URL);
17821768
messageBirdService.deleteByID(url, number);
17831769
}
1784-
}
1770+
}

examples/src/main/java/ExampleStartConversationsWithWhatsAppSandbox.java

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)