@@ -95,9 +95,7 @@ public class MessageBirdClient {
95
95
* can, however, override this behaviour by providing absolute URLs
96
96
* ourselves.
97
97
*/
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" ;
101
99
static final String VOICE_CALLS_BASE_URL = "https://voice.messagebird.com" ;
102
100
static final String NUMBERS_CALLS_BASE_URL = "https://numbers.messagebird.com/v1" ;
103
101
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 {
136
134
private final String DOWNLOADS = "Downloads" ;
137
135
138
136
private MessageBirdService messageBirdService ;
139
- private String conversationsBaseUrl ;
140
-
141
- public enum Feature {
142
- ENABLE_CONVERSATION_API_WHATSAPP_SANDBOX
143
- }
144
137
145
138
public MessageBirdClient (final MessageBirdService messageBirdService ) {
146
139
this .messageBirdService = messageBirdService ;
147
- this .conversationsBaseUrl = BASE_URL_CONVERSATIONS ;
148
140
}
149
141
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
- }
156
142
/****************************************************************************************************/
157
143
/** Balance and HRL methods **/
158
144
/****************************************************************************************************/
@@ -897,7 +883,7 @@ public Conversation viewConversation(final String id) throws NotFoundException,
897
883
if (id == null ) {
898
884
throw new IllegalArgumentException ("Id must be specified" );
899
885
}
900
- String url = this . conversationsBaseUrl + CONVERSATION_PATH ;
886
+ String url = CONVERSATIONS_BASE_URL + CONVERSATION_PATH ;
901
887
return messageBirdService .requestByID (url , id , Conversation .class );
902
888
}
903
889
@@ -913,7 +899,7 @@ public Conversation updateConversation(final String id, final ConversationStatus
913
899
if (id == null ) {
914
900
throw new IllegalArgumentException ("Id must be specified." );
915
901
}
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 );
917
903
return messageBirdService .sendPayLoad ("PATCH" , url , status , Conversation .class );
918
904
}
919
905
@@ -926,7 +912,7 @@ public Conversation updateConversation(final String id, final ConversationStatus
926
912
*/
927
913
public ConversationList listConversations (final int offset , final int limit )
928
914
throws UnauthorizedException , GeneralException {
929
- String url = this . conversationsBaseUrl + CONVERSATION_PATH ;
915
+ String url = CONVERSATIONS_BASE_URL + CONVERSATION_PATH ;
930
916
return messageBirdService .requestList (url , offset , limit , ConversationList .class );
931
917
}
932
918
@@ -950,7 +936,7 @@ public ConversationList listConversations() throws UnauthorizedException, Genera
950
936
*/
951
937
public Conversation startConversation (ConversationStartRequest request )
952
938
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 );
954
940
return messageBirdService .sendPayLoad (url , request , Conversation .class );
955
941
}
956
942
@@ -962,7 +948,7 @@ public Conversation startConversation(ConversationStartRequest request)
962
948
*/
963
949
public ConversationSendResponse sendMessage (ConversationSendRequest request )
964
950
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 );
966
952
return messageBirdService .sendPayLoad (url , request , ConversationSendResponse .class );
967
953
}
968
954
@@ -981,7 +967,7 @@ public ConversationMessageList listConversationMessages(
981
967
) throws UnauthorizedException , GeneralException {
982
968
String url = String .format (
983
969
"%s%s/%s%s" ,
984
- this . conversationsBaseUrl ,
970
+ CONVERSATIONS_BASE_URL ,
985
971
CONVERSATION_PATH ,
986
972
conversationId ,
987
973
CONVERSATION_MESSAGE_PATH
@@ -1012,7 +998,7 @@ public ConversationMessageList listConversationMessages(
1012
998
*/
1013
999
public ConversationMessage viewConversationMessage (final String messageId )
1014
1000
throws NotFoundException , GeneralException , UnauthorizedException {
1015
- String url = this . conversationsBaseUrl + CONVERSATION_MESSAGE_PATH ;
1001
+ String url = CONVERSATIONS_BASE_URL + CONVERSATION_MESSAGE_PATH ;
1016
1002
return messageBirdService .requestByID (url , messageId , ConversationMessage .class );
1017
1003
}
1018
1004
@@ -1029,7 +1015,7 @@ public ConversationMessage sendConversationMessage(
1029
1015
) throws UnauthorizedException , GeneralException {
1030
1016
String url = String .format (
1031
1017
"%s%s/%s%s" ,
1032
- this . conversationsBaseUrl ,
1018
+ CONVERSATIONS_BASE_URL ,
1033
1019
CONVERSATION_PATH ,
1034
1020
conversationId ,
1035
1021
CONVERSATION_MESSAGE_PATH
@@ -1044,7 +1030,7 @@ public ConversationMessage sendConversationMessage(
1044
1030
*/
1045
1031
public void deleteConversationWebhook (final String webhookId )
1046
1032
throws NotFoundException , GeneralException , UnauthorizedException {
1047
- String url = this . conversationsBaseUrl + CONVERSATION_WEBHOOK_PATH ;
1033
+ String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH ;
1048
1034
messageBirdService .deleteByID (url , webhookId );
1049
1035
}
1050
1036
@@ -1056,7 +1042,7 @@ public void deleteConversationWebhook(final String webhookId)
1056
1042
*/
1057
1043
public ConversationWebhook sendConversationWebhook (final ConversationWebhookCreateRequest request )
1058
1044
throws UnauthorizedException , GeneralException {
1059
- String url = this . conversationsBaseUrl + CONVERSATION_WEBHOOK_PATH ;
1045
+ String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH ;
1060
1046
return messageBirdService .sendPayLoad (url , request , ConversationWebhook .class );
1061
1047
}
1062
1048
@@ -1071,7 +1057,7 @@ public ConversationWebhook updateConversationWebhook(final String id, final Conv
1071
1057
throw new IllegalArgumentException ("Conversation webhook ID must be specified." );
1072
1058
}
1073
1059
1074
- String url = this . conversationsBaseUrl + CONVERSATION_WEBHOOK_PATH + "/" + id ;
1060
+ String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH + "/" + id ;
1075
1061
return messageBirdService .sendPayLoad ("PATCH" , url , request , ConversationWebhook .class );
1076
1062
}
1077
1063
@@ -1082,7 +1068,7 @@ public ConversationWebhook updateConversationWebhook(final String id, final Conv
1082
1068
* @return The retrieved webhook.
1083
1069
*/
1084
1070
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 ;
1086
1072
return messageBirdService .requestByID (url , webhookId , ConversationWebhook .class );
1087
1073
}
1088
1074
@@ -1095,7 +1081,7 @@ public ConversationWebhook viewConversationWebhook(final String webhookId) throw
1095
1081
*/
1096
1082
public ConversationWebhookList listConversationWebhooks (final int offset , final int limit )
1097
1083
throws UnauthorizedException , GeneralException {
1098
- String url = this . conversationsBaseUrl + CONVERSATION_WEBHOOK_PATH ;
1084
+ String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH ;
1099
1085
return messageBirdService .requestList (url , offset , limit , ConversationWebhookList .class );
1100
1086
}
1101
1087
@@ -1781,4 +1767,4 @@ public void cancelNumber(String number) throws UnauthorizedException, GeneralExc
1781
1767
final String url = String .format ("%s/phone-numbers" , NUMBERS_CALLS_BASE_URL );
1782
1768
messageBirdService .deleteByID (url , number );
1783
1769
}
1784
- }
1770
+ }
0 commit comments