Skip to content

Commit 5282227

Browse files
authored
User-Agent (#23)
* User-Agent added * added runtime version from maven plugin in jar
1 parent c47b7cc commit 5282227

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,18 @@
201201
<autoReleaseAfterClose>true</autoReleaseAfterClose>
202202
</configuration>
203203
</plugin>
204+
<plugin>
205+
<groupId>org.apache.maven.plugins</groupId>
206+
<artifactId>maven-jar-plugin</artifactId>
207+
<configuration>
208+
<archive>
209+
<manifest>
210+
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
211+
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
212+
</manifest>
213+
</archive>
214+
</configuration>
215+
</plugin>
204216
</plugins>
205217
</build>
206218

src/main/java/com/bandwidth/iris/sdk/IrisClient.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.apache.http.entity.FileEntity;
1616
import org.apache.http.entity.StringEntity;
1717
import org.apache.http.impl.client.DefaultHttpClient;
18+
import org.apache.http.params.HttpParams;
1819
import org.apache.http.util.EntityUtils;
1920
import java.io.FileOutputStream;
2021

@@ -26,6 +27,8 @@
2627

2728
public class IrisClient {
2829

30+
public static final String USER_AGENT = "java-bandwidth-iris-" + IrisClient.class.getPackage().getSpecificationVersion();
31+
2932
private static final String defaultUri = "https://dashboard.bandwidth.com/api";
3033
private static final String defaultVersion = "v1.0";
3134
private final String baseAccountUrl;
@@ -162,6 +165,8 @@ public String buildModelUri(String[] tokens) throws URISyntaxException {
162165
}
163166

164167
protected IrisResponse executeRequest(HttpUriRequest request) throws Exception {
168+
request.addHeader("User-Agent", USER_AGENT);
169+
165170
Map<String, String> headers = new HashMap<String, String>();
166171
IrisResponse irisResponse = new IrisResponse();
167172
HttpResponse response = httpClient.execute(request);

src/test/java/com/bandwidth/iris/sdk/EmergencyNotificationTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class EmergencyNotificationTests extends BaseModelTests {
1616
public void TestCreateRecipients() throws Exception {
1717
String url = "/v1.0/accounts/accountId/emergencyNotificationRecipients";
1818
stubFor(post(urlMatching(url))
19+
.withHeader("User-Agent", equalTo(IrisClient.USER_AGENT))
1920
.willReturn(aResponse()
2021
.withStatus(201).withBody(IrisClientTestUtils.emergencyNotificationRecipientsResponse)));
2122

0 commit comments

Comments
 (0)