@@ -24,6 +24,7 @@ public final class BandwidthClient implements Configuration {
2424 private MessagingClient messagingClient ;
2525 private TwoFactorAuthClient twoFactorAuthClient ;
2626 private VoiceClient voiceClient ;
27+ private WebRtcClient webRtcClient ;
2728
2829 /**
2930 * Provides access to messagingClient Client
@@ -49,6 +50,14 @@ public VoiceClient getVoiceClient() {
4950 return voiceClient ;
5051 }
5152
53+ /**
54+ * Provides access to webRtcClient Client
55+ * @return Returns the WebRtcClient instance
56+ */
57+ public WebRtcClient getWebRtcClient () {
58+ return webRtcClient ;
59+ }
60+
5261
5362 /**
5463 * Shutdown the underlying HttpClient instance
@@ -60,8 +69,8 @@ public static void shutdown() {
6069 private BandwidthClient (Environment environment , String messagingBasicAuthUserName ,
6170 String messagingBasicAuthPassword , String twoFactorAuthBasicAuthUserName ,
6271 String twoFactorAuthBasicAuthPassword , String voiceBasicAuthUserName , String voiceBasicAuthPassword ,
63- HttpClient httpClient , long timeout , ReadonlyHttpClientConfiguration httpClientConfig ,
64- Map <String , AuthManager > authManagers ) {
72+ String webRtcBasicAuthUserName , String webRtcBasicAuthPassword , HttpClient httpClient , long timeout ,
73+ ReadonlyHttpClientConfiguration httpClientConfig , Map <String , AuthManager > authManagers ) {
6574 this .environment = environment ;
6675 this .httpClient = httpClient ;
6776 this .timeout = timeout ;
@@ -95,12 +104,22 @@ private BandwidthClient(Environment environment, String messagingBasicAuthUserNa
95104 this .voiceBasicAuthManager = new VoiceBasicAuthManager (voiceBasicAuthUserName , voiceBasicAuthPassword );
96105 this .authManagers .put ("voice" , voiceBasicAuthManager );
97106 }
107+ if (this .authManagers .containsKey ("webRtc" )) {
108+ this .webRtcBasicAuthManager = (WebRtcBasicAuthManager )this .authManagers .get ("webRtc" );
109+ }
110+ if (!this .authManagers .containsKey ("webRtc" )
111+ || getWebRtcBasicAuthCredentials ().getWebRtcBasicAuthUserName () != webRtcBasicAuthUserName
112+ || getWebRtcBasicAuthCredentials ().getWebRtcBasicAuthPassword () != webRtcBasicAuthPassword ) {
113+ this .webRtcBasicAuthManager = new WebRtcBasicAuthManager (webRtcBasicAuthUserName , webRtcBasicAuthPassword );
114+ this .authManagers .put ("webRtc" , webRtcBasicAuthManager );
115+ }
98116
99117
100118
101119 messagingClient = new MessagingClient (this );
102120 twoFactorAuthClient = new TwoFactorAuthClient (this );
103121 voiceClient = new VoiceClient (this );
122+ webRtcClient = new WebRtcClient (this );
104123 }
105124
106125 /**
@@ -143,6 +162,11 @@ private BandwidthClient(Environment environment, String messagingBasicAuthUserNa
143162 */
144163 private VoiceBasicAuthManager voiceBasicAuthManager ;
145164
165+ /**
166+ * WebRtcBasicAuthManager
167+ */
168+ private WebRtcBasicAuthManager webRtcBasicAuthManager ;
169+
146170 /**
147171 * Current API environment
148172 * @return environment
@@ -223,6 +247,22 @@ public VoiceBasicAuthCredentials getVoiceBasicAuthCredentials() {
223247 return voiceBasicAuthManager ;
224248 }
225249
250+ private String getWebRtcBasicAuthUserName () {
251+ return getWebRtcBasicAuthCredentials ().getWebRtcBasicAuthUserName ();
252+ }
253+
254+ private String getWebRtcBasicAuthPassword () {
255+ return getWebRtcBasicAuthCredentials ().getWebRtcBasicAuthPassword ();
256+ }
257+
258+ /**
259+ * The credentials to use with basic authentication
260+ * @return webRtcBasicAuthCredentials
261+ */
262+ public WebRtcBasicAuthCredentials getWebRtcBasicAuthCredentials () {
263+ return webRtcBasicAuthManager ;
264+ }
265+
226266 /**
227267 * The list of auth managers
228268 * @return authManagers
@@ -271,6 +311,9 @@ private static String environmentMapper(Environment environment, Server server)
271311 if (server .equals (Server .VOICEDEFAULT )) {
272312 return "https://voice.bandwidth.com" ;
273313 }
314+ if (server .equals (Server .WEBRTCDEFAULT )) {
315+ return "https://api.webrtc.bandwidth.com/v1" ;
316+ }
274317 }
275318 return "api.bandwidth.com" ;
276319 }
@@ -290,6 +333,8 @@ public Builder newBuilder() {
290333 builder .twoFactorAuthBasicAuthPassword = getTwoFactorAuthBasicAuthPassword ();
291334 builder .voiceBasicAuthUserName = getVoiceBasicAuthUserName ();
292335 builder .voiceBasicAuthPassword = getVoiceBasicAuthPassword ();
336+ builder .webRtcBasicAuthUserName = getWebRtcBasicAuthUserName ();
337+ builder .webRtcBasicAuthPassword = getWebRtcBasicAuthPassword ();
293338 builder .httpClient = getHttpClient ();
294339 builder .timeout = getTimeout ();
295340 builder .authManagers = authManagers ;
@@ -308,6 +353,8 @@ public static class Builder {
308353 private String twoFactorAuthBasicAuthPassword = "TODO: Replace" ;
309354 private String voiceBasicAuthUserName = "TODO: Replace" ;
310355 private String voiceBasicAuthPassword = "TODO: Replace" ;
356+ private String webRtcBasicAuthUserName = "TODO: Replace" ;
357+ private String webRtcBasicAuthPassword = "TODO: Replace" ;
311358 private HttpClient httpClient ;
312359 private long timeout = 0 ;
313360 private Map <String , AuthManager > authManagers = null ;
@@ -362,6 +409,22 @@ public Builder voiceBasicAuthCredentials(String voiceBasicAuthUserName, String v
362409 this .voiceBasicAuthPassword = voiceBasicAuthPassword ;
363410 return this ;
364411 }
412+ /**
413+ * The username and password to use with basic authentication
414+ * @param webRtcBasicAuthUserName
415+ * @param webRtcBasicAuthPassword
416+ */
417+ public Builder webRtcBasicAuthCredentials (String webRtcBasicAuthUserName , String webRtcBasicAuthPassword ) {
418+ if (webRtcBasicAuthUserName == null ) {
419+ throw new NullPointerException ("Username cannot be null." );
420+ }
421+ if (webRtcBasicAuthPassword == null ) {
422+ throw new NullPointerException ("Password cannot be null." );
423+ }
424+ this .webRtcBasicAuthUserName = webRtcBasicAuthUserName ;
425+ this .webRtcBasicAuthPassword = webRtcBasicAuthPassword ;
426+ return this ;
427+ }
365428 /**
366429 * Current API environment
367430 * @param environment
@@ -396,7 +459,8 @@ public BandwidthClient build() {
396459
397460 return new BandwidthClient (environment , messagingBasicAuthUserName , messagingBasicAuthPassword ,
398461 twoFactorAuthBasicAuthUserName , twoFactorAuthBasicAuthPassword , voiceBasicAuthUserName ,
399- voiceBasicAuthPassword , httpClient , timeout , httpClientConfig , authManagers );
462+ voiceBasicAuthPassword , webRtcBasicAuthUserName , webRtcBasicAuthPassword , httpClient , timeout ,
463+ httpClientConfig , authManagers );
400464 }
401465 }
402466}
0 commit comments