Skip to content

Commit b58a6cd

Browse files
authored
Merge pull request #19 from Bandwidth/release/2021-01-27-20-46-18
New deploy
2 parents 2019521 + ec8ed73 commit b58a6cd

File tree

16 files changed

+1764
-507
lines changed

16 files changed

+1764
-507
lines changed

pom.xml

Lines changed: 129 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,73 @@
1-
<project>
2-
<modelVersion>4.0.0</modelVersion>
3-
<groupId>com.bandwidth.sdk</groupId>
4-
<artifactId>bandwidth-sdk</artifactId>
5-
<version>4.0.0</version>
6-
<packaging>jar</packaging>
7-
<name>BandwidthLib</name>
8-
<build>
9-
<pluginManagement>
10-
<plugins>
11-
<plugin>
12-
<groupId>org.eclipse.m2e</groupId>
13-
<artifactId>lifecycle-mapping</artifactId>
14-
<version>1.0.0</version>
15-
<configuration>
16-
<lifecycleMappingMetadata>
17-
<pluginExecutions>
18-
<pluginExecution>
19-
<pluginExecutionFilter>
20-
<groupId>org.apache.maven.plugins</groupId>
21-
<artifactId>maven-enforcer-plugin</artifactId>
22-
<versionRange>[2.0.0,)</versionRange>
23-
<goals>
24-
<goal>enforce</goal>
25-
</goals>
26-
</pluginExecutionFilter>
27-
<action>
28-
<execute>
29-
<runOnIncremental>true</runOnIncremental>
30-
</execute>
31-
</action>
32-
</pluginExecution>
33-
</pluginExecutions>
34-
</lifecycleMappingMetadata>
35-
</configuration>
36-
</plugin>
37-
</plugins>
38-
</pluginManagement>
39-
<plugins>
40-
<plugin>
41-
<groupId>org.apache.maven.plugins</groupId>
42-
<artifactId>maven-enforcer-plugin</artifactId>
43-
<version>3.0.0-M2</version>
44-
<executions>
45-
<execution>
46-
<id>enforce-versions</id>
47-
<goals>
48-
<goal>enforce</goal>
49-
</goals>
50-
<configuration>
51-
<fail>true</fail>
52-
<rules>
53-
<requireJavaVersion>
54-
<version>1.8</version>
55-
</requireJavaVersion>
56-
</rules>
57-
</configuration>
58-
</execution>
59-
</executions>
60-
</plugin>
61-
<plugin>
62-
<artifactId>maven-assembly-plugin</artifactId>
63-
<configuration>
64-
<descriptorRefs>
65-
<descriptorRef>jar-with-dependencies</descriptorRef>
66-
</descriptorRefs>
67-
<appendAssemblyId>false</appendAssemblyId>
68-
</configuration>
69-
</plugin>
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.bandwidth.sdk</groupId>
5+
<artifactId>bandwidth-sdk</artifactId>
6+
<version>5.0.0</version>
7+
<packaging>jar</packaging>
8+
<name>BandwidthLib</name>
9+
<build>
10+
<pluginManagement>
11+
<plugins>
12+
<plugin>
13+
<groupId>org.eclipse.m2e</groupId>
14+
<artifactId>lifecycle-mapping</artifactId>
15+
<version>1.0.0</version>
16+
<configuration>
17+
<lifecycleMappingMetadata>
18+
<pluginExecutions>
19+
<pluginExecution>
20+
<pluginExecutionFilter>
21+
<groupId>org.apache.maven.plugins</groupId>
22+
<artifactId>maven-enforcer-plugin</artifactId>
23+
<versionRange>[2.0.0,)</versionRange>
24+
<goals>
25+
<goal>enforce</goal>
26+
</goals>
27+
</pluginExecutionFilter>
28+
<action>
29+
<execute>
30+
<runOnIncremental>true</runOnIncremental>
31+
</execute >
32+
</action>
33+
</pluginExecution>
34+
</pluginExecutions>
35+
</lifecycleMappingMetadata>
36+
</configuration>
37+
</plugin>
38+
</plugins>
39+
</pluginManagement>
40+
<plugins>
41+
<plugin>
42+
<groupId>org.apache.maven.plugins</groupId>
43+
<artifactId>maven-enforcer-plugin</artifactId>
44+
<version>3.0.0-M2</version>
45+
<executions>
46+
<execution>
47+
<id>enforce-versions</id>
48+
<goals>
49+
<goal>enforce</goal>
50+
</goals>
51+
<configuration>
52+
<fail>true</fail>
53+
<rules>
54+
<requireJavaVersion>
55+
<version>1.8</version>
56+
</requireJavaVersion>
57+
</rules>
58+
</configuration>
59+
</execution>
60+
</executions>
61+
</plugin>
62+
<plugin>
63+
<artifactId>maven-assembly-plugin</artifactId>
64+
<configuration>
65+
<descriptorRefs>
66+
<descriptorRef>jar-with-dependencies</descriptorRef>
67+
</descriptorRefs>
68+
<appendAssemblyId>false</appendAssemblyId>
69+
</configuration>
70+
</plugin>
7071
<plugin>
7172
<groupId>org.apache.maven.plugins</groupId>
7273
<artifactId>maven-source-plugin</artifactId>
@@ -110,57 +111,64 @@
110111
</execution>
111112
</executions>
112113
</plugin>
113-
</plugins>
114-
</build>
115-
<properties>
116-
<jackson.version>2.9.10</jackson.version>
117-
<jackson.databind.version>2.9.10.7</jackson.databind.version>
118-
<maven.compiler.source>1.8</maven.compiler.source>
119-
<maven.compiler.target>1.8</maven.compiler.target>
120-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
121-
</properties>
122-
<dependencies>
123-
<dependency>
124-
<groupId>javax.xml.bind</groupId>
125-
<artifactId>jaxb-api</artifactId>
126-
<version>2.3.0</version>
127-
</dependency>
128-
<dependency>
129-
<groupId>com.sun.xml.bind</groupId>
130-
<artifactId>jaxb-core</artifactId>
131-
<version>2.3.0</version>
132-
</dependency>
133-
<dependency>
134-
<groupId>com.sun.xml.bind</groupId>
135-
<artifactId>jaxb-impl</artifactId>
136-
<version>2.3.0</version>
137-
</dependency>
138-
<dependency>
139-
<groupId>org.projectlombok</groupId>
140-
<artifactId>lombok</artifactId>
141-
<version>1.18.8</version>
142-
</dependency>
143-
<dependency>
144-
<groupId>com.squareup.okhttp3</groupId>
145-
<artifactId>okhttp</artifactId>
146-
<version>3.12.1</version>
147-
</dependency>
148-
<dependency>
149-
<groupId>com.fasterxml.jackson.core</groupId>
150-
<artifactId>jackson-databind</artifactId>
151-
<version>${jackson.databind.version}</version>
152-
</dependency>
153-
<dependency>
154-
<groupId>com.fasterxml.jackson.core</groupId>
155-
<artifactId>jackson-core</artifactId>
156-
<version>${jackson.version}</version>
157-
</dependency>
158-
<dependency>
159-
<groupId>com.fasterxml.jackson.core</groupId>
160-
<artifactId>jackson-annotations</artifactId>
161-
<version>${jackson.version}</version>
162-
</dependency>
163-
</dependencies>
114+
</plugins>
115+
</build>
116+
<properties>
117+
<jackson.version>2.9.10</jackson.version>
118+
<jackson.databind.version>2.9.10.7</jackson.databind.version>
119+
<maven.compiler.source>1.8</maven.compiler.source>
120+
<maven.compiler.target>1.8</maven.compiler.target>
121+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
122+
</properties>
123+
<dependencies>
124+
<dependency>
125+
<groupId>javax.xml.bind</groupId>
126+
<artifactId>jaxb-api</artifactId>
127+
<version>2.3.0</version>
128+
</dependency>
129+
<dependency>
130+
<groupId>com.sun.xml.bind</groupId>
131+
<artifactId>jaxb-core</artifactId>
132+
<version>2.3.0</version>
133+
</dependency>
134+
<dependency>
135+
<groupId>com.sun.xml.bind</groupId>
136+
<artifactId>jaxb-impl</artifactId>
137+
<version>2.3.0</version>
138+
</dependency>
139+
<dependency>
140+
<groupId>org.projectlombok</groupId>
141+
<artifactId>lombok</artifactId>
142+
<version>1.18.8</version>
143+
</dependency>
144+
145+
<dependency>
146+
<groupId>com.squareup.okhttp3</groupId>
147+
<artifactId>okhttp</artifactId>
148+
<version>3.12.1</version>
149+
</dependency>
150+
<dependency>
151+
<groupId>com.fasterxml.jackson.core</groupId>
152+
<artifactId>jackson-databind</artifactId>
153+
<version>${jackson.databind.version}</version>
154+
</dependency>
155+
<dependency>
156+
<groupId>com.fasterxml.jackson.core</groupId>
157+
<artifactId>jackson-core</artifactId>
158+
<version>${jackson.version}</version>
159+
</dependency>
160+
<dependency>
161+
<groupId>com.fasterxml.jackson.core</groupId>
162+
<artifactId>jackson-annotations</artifactId>
163+
<version>${jackson.version}</version>
164+
</dependency>
165+
<dependency>
166+
<groupId>junit</groupId>
167+
<artifactId>junit</artifactId>
168+
<version>4.13.1</version>
169+
<scope>test</scope>
170+
</dependency>
171+
</dependencies>
164172
<distributionManagement>
165173
<snapshotRepository>
166174
<id>ossrh</id>
@@ -198,4 +206,4 @@
198206
<timezone>-5</timezone>
199207
</developer>
200208
</developers>
201-
</project>
209+
</project>

src/main/java/com/bandwidth/BandwidthClient.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
package com.bandwidth;
88

9+
import com.bandwidth.http.client.HttpCallback;
910
import com.bandwidth.http.client.HttpClient;
1011
import com.bandwidth.http.client.HttpClientConfiguration;
1112
import com.bandwidth.http.client.OkClient;
@@ -79,18 +80,24 @@ public final class BandwidthClient implements Configuration {
7980
*/
8081
private Map<String, AuthManager> authManagers;
8182

83+
/**
84+
* Callback to be called before and after the HTTP call for an endpoint is made.
85+
*/
86+
private final HttpCallback httpCallback;
87+
8288
private BandwidthClient(Environment environment, String baseUrl, HttpClient httpClient,
8389
long timeout, ReadonlyHttpClientConfiguration httpClientConfig,
8490
String messagingBasicAuthUserName, String messagingBasicAuthPassword,
8591
String twoFactorAuthBasicAuthUserName, String twoFactorAuthBasicAuthPassword,
8692
String voiceBasicAuthUserName, String voiceBasicAuthPassword,
8793
String webRtcBasicAuthUserName, String webRtcBasicAuthPassword,
88-
Map<String, AuthManager> authManagers) {
94+
Map<String, AuthManager> authManagers, HttpCallback httpCallback) {
8995
this.environment = environment;
9096
this.baseUrl = baseUrl;
9197
this.httpClient = httpClient;
9298
this.timeout = timeout;
9399
this.httpClientConfig = httpClientConfig;
100+
this.httpCallback = httpCallback;
94101

95102
this.authManagers = (authManagers == null) ? new HashMap<>() : new HashMap<>(authManagers);
96103
if (this.authManagers.containsKey("messaging")) {
@@ -369,6 +376,7 @@ public Builder newBuilder() {
369376
builder.webRtcBasicAuthUserName = getWebRtcBasicAuthCredentials().getBasicAuthUserName();
370377
builder.webRtcBasicAuthPassword = getWebRtcBasicAuthCredentials().getBasicAuthPassword();
371378
builder.authManagers = authManagers;
379+
builder.httpCallback = httpCallback;
372380
builder.setHttpClientConfig(httpClientConfig);
373381
return builder;
374382
}
@@ -390,6 +398,7 @@ public static class Builder {
390398
private String webRtcBasicAuthUserName = "TODO: Replace";
391399
private String webRtcBasicAuthPassword = "TODO: Replace";
392400
private Map<String, AuthManager> authManagers = null;
401+
private HttpCallback httpCallback = null;
393402
private HttpClientConfiguration httpClientConfig;
394403

395404
/**
@@ -500,6 +509,16 @@ public Builder timeout(long timeout) {
500509
return this;
501510
}
502511

512+
/**
513+
* HttpCallback.
514+
* @param httpCallback Callback to be called before and after the HTTP call.
515+
* @return Builder
516+
*/
517+
public Builder httpCallback(HttpCallback httpCallback) {
518+
this.httpCallback = httpCallback;
519+
return this;
520+
}
521+
503522

504523
private void setHttpClientConfig(ReadonlyHttpClientConfiguration httpClientConfig) {
505524
this.timeout = httpClientConfig.getTimeout();
@@ -518,7 +537,7 @@ public BandwidthClient build() {
518537
messagingBasicAuthUserName, messagingBasicAuthPassword,
519538
twoFactorAuthBasicAuthUserName, twoFactorAuthBasicAuthPassword,
520539
voiceBasicAuthUserName, voiceBasicAuthPassword, webRtcBasicAuthUserName,
521-
webRtcBasicAuthPassword, authManagers);
540+
webRtcBasicAuthPassword, authManagers, httpCallback);
522541
}
523542
}
524543
}

src/main/java/com/bandwidth/controllers/BaseController.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.bandwidth.AuthManager;
1010
import com.bandwidth.Configuration;
1111
import com.bandwidth.exceptions.ApiException;
12+
import com.bandwidth.http.client.HttpCallback;
1213
import com.bandwidth.http.client.HttpClient;
1314
import com.bandwidth.http.client.HttpContext;
1415
import com.bandwidth.http.request.HttpRequest;
@@ -30,17 +31,35 @@ public abstract class BaseController {
3031
*/
3132
protected final Configuration config;
3233

34+
/**
35+
* Protected variable to hold an instance of HttpCallback if the user provides it.
36+
*/
37+
protected final HttpCallback httpCallback;
38+
3339
protected Map<String, AuthManager> authManagers;
3440

3541
private HttpClient httpClient;
36-
42+
3743
protected BaseController(Configuration config, HttpClient httpClient,
3844
Map<String, AuthManager> authManagers) {
45+
this(config, httpClient, authManagers, null);
46+
}
47+
48+
protected BaseController(Configuration config, HttpClient httpClient,
49+
Map<String, AuthManager> authManagers, HttpCallback httpCallback) {
3950
this.config = config;
4051
this.httpClient = httpClient;
4152
this.authManagers = authManagers;
53+
this.httpCallback = httpCallback;
4254
}
4355

56+
/**
57+
* Get httpCallback associated with this controller.
58+
* @return HttpCallback
59+
*/
60+
public HttpCallback getHttpCallback() {
61+
return httpCallback;
62+
}
4463

4564
/**
4665
* Shared instance of the Http client.

0 commit comments

Comments
 (0)