Skip to content

Commit 0182328

Browse files
DX-2093 voice, mfa, messaging interface updates (breaking changes) (#35)
* New deploy * readded tests * updated tests * added dynamic response * fixed more classes * fixed pom Co-authored-by: jmulford-bw <[email protected]>
1 parent b36eae9 commit 0182328

File tree

122 files changed

+6658
-4989
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+6658
-4989
lines changed

.gitkeep

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
README.md
22
src/main/java/com/bandwidth/voice/bxml/*.java
3-
src/main/java/com/bandwidth/webrtc/utils/*.java
3+
src/main/java/com/bandwidth/webrtc/utils/*.java
4+
src/test/*

pom.xml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
- BandwidthLib
33
-
4-
- This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
4+
- This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
55
-->
66
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
77
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -46,6 +46,14 @@
4646
</plugins>
4747
</pluginManagement>
4848
<plugins>
49+
<plugin>
50+
<groupId>org.codehaus.mojo</groupId>
51+
<artifactId>versions-maven-plugin</artifactId>
52+
<version>2.5</version>
53+
<configuration>
54+
<rulesUri>file://${project.basedir}/version-rules.xml</rulesUri>
55+
</configuration>
56+
</plugin>
4957
<plugin>
5058
<groupId>org.apache.maven.plugins</groupId>
5159
<artifactId>maven-enforcer-plugin</artifactId>
@@ -124,7 +132,7 @@
124132

125133
<properties>
126134
<jackson.version>2.9.10</jackson.version>
127-
<jackson.databind.version>2.9.10.7</jackson.databind.version>
135+
<jackson.databind.version>2.9.10.5</jackson.databind.version>
128136
<maven.compiler.source>1.8</maven.compiler.source>
129137
<maven.compiler.target>1.8</maven.compiler.target>
130138
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -166,7 +174,7 @@
166174
<dependency>
167175
<groupId>com.squareup.okhttp3</groupId>
168176
<artifactId>okhttp</artifactId>
169-
<version>3.12.1</version>
177+
<version>[3.12, 4.9.1]</version>
170178
</dependency>
171179
<dependency>
172180
<groupId>com.fasterxml.jackson.core</groupId>

src/main/java/com/bandwidth/ApiHelper.java

Lines changed: 61 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* BandwidthLib
33
*
4-
* This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
4+
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
55
*/
66

77
package com.bandwidth;
@@ -11,7 +11,6 @@
1111
import com.bandwidth.http.request.MultipartWrapper;
1212
import com.fasterxml.jackson.annotation.JsonFormat;
1313
import com.fasterxml.jackson.annotation.JsonGetter;
14-
import com.fasterxml.jackson.annotation.JsonInclude;
1514
import com.fasterxml.jackson.core.JsonProcessingException;
1615
import com.fasterxml.jackson.core.type.TypeReference;
1716
import com.fasterxml.jackson.databind.DeserializationFeature;
@@ -26,6 +25,7 @@
2625
import java.lang.annotation.Annotation;
2726
import java.lang.reflect.InvocationTargetException;
2827
import java.lang.reflect.Method;
28+
import java.lang.reflect.Modifier;
2929
import java.math.BigDecimal;
3030
import java.net.URLEncoder;
3131
import java.util.AbstractMap.SimpleEntry;
@@ -52,7 +52,6 @@ public class ApiHelper {
5252
private static final long serialVersionUID = -174113593500315394L;
5353
{
5454
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
55-
setSerializationInclusion(JsonInclude.Include.NON_NULL);
5655
configOverride(BigDecimal.class).setFormat(
5756
JsonFormat.Value.forShape(JsonFormat.Shape.STRING));
5857
}
@@ -136,7 +135,6 @@ public static String serialize(Object obj, final JsonSerializer serializer)
136135
}.writeValueAsString(obj);
137136
}
138137

139-
140138
/**
141139
* Json deserialization of the given Json string using a specified JsonDerializer.
142140
* @param json The Json string to deserialize.
@@ -215,6 +213,24 @@ public static <T extends Object> T deserialize(String json, TypeReference<T> typ
215213
return mapper.readValue(json, typeReference);
216214
}
217215

216+
/**
217+
* Json deserialization of the given Json string.
218+
* @param json The Json string to deserialize
219+
* @return The deserialized Json as an Object
220+
*/
221+
public static Object deserializeAsObject(String json) {
222+
if (isNullOrWhiteSpace(json)) {
223+
return null;
224+
}
225+
try {
226+
return ApiHelper.deserialize(json, new TypeReference<Object>() {});
227+
} catch (IOException e) {
228+
// Failed to deserialize when json is not representing a JSON object.
229+
// i.e. either its string or any primitive type.
230+
return json;
231+
}
232+
}
233+
218234
/**
219235
* JSON Deserialization of the given json string.
220236
* @param <T> The type of the object to deserialize into
@@ -558,42 +574,52 @@ private static void objectToList(String objName, Object obj,
558574
} else {
559575
// Process objects
560576
// Invoke getter methods
561-
Method[] methods = obj.getClass().getMethods();
562-
for (Method method : methods) {
563-
// Is a getter?
564-
if (method.getParameterTypes().length != 0 || !method.getName().startsWith("get")) {
565-
continue;
566-
}
577+
Class<?> clazz = obj.getClass();
578+
while (clazz != null) {
579+
for (Method method : clazz.getDeclaredMethods()) {
580+
581+
// Is a public/protected getter or internalGetter?
582+
if (method.getParameterTypes().length != 0
583+
|| Modifier.isPrivate(method.getModifiers())
584+
|| (!method.getName().startsWith("get")
585+
&& !method.getName().startsWith("internalGet"))) {
586+
continue;
587+
}
567588

568-
// Get Json attribute name
569-
Annotation getterAnnotation = method.getAnnotation(JsonGetter.class);
570-
if (getterAnnotation == null) {
571-
continue;
572-
}
589+
// Get JsonGetter annotation
590+
Annotation getterAnnotation = method.getAnnotation(JsonGetter.class);
591+
if (getterAnnotation == null) {
592+
continue;
593+
}
573594

574-
// Load key name
575-
String attribName = ((JsonGetter) getterAnnotation).value();
576-
if ((objName != null) && (!objName.isEmpty())) {
577-
attribName = String.format("%s[%s]", objName, attribName);
578-
}
595+
// Load key name from getter attribute name
596+
String attribName = ((JsonGetter) getterAnnotation).value();
597+
if ((objName != null) && (!objName.isEmpty())) {
598+
attribName = String.format("%s[%s]", objName, attribName);
599+
}
579600

580-
try {
581-
// Load key value pair
582-
Object value = method.invoke(obj);
583-
JsonSerialize serializerAnnotation = method.getAnnotation(JsonSerialize.class);
584-
if (serializerAnnotation != null) {
585-
loadKeyValuePairForEncoding(attribName, value, objectList, processed,
586-
serializerAnnotation);
587-
} else {
588-
loadKeyValuePairForEncoding(attribName, value, objectList, processed);
601+
try {
602+
// Load value by invoking getter method
603+
method.setAccessible(true);
604+
Object value = method.invoke(obj);
605+
JsonSerialize serializerAnnotation = method
606+
.getAnnotation(JsonSerialize.class);
607+
// Load key value pair into objectList
608+
if (serializerAnnotation != null) {
609+
loadKeyValuePairForEncoding(attribName, value, objectList, processed,
610+
serializerAnnotation);
611+
} else {
612+
loadKeyValuePairForEncoding(attribName, value, objectList, processed);
613+
}
614+
} catch (IllegalAccessException | IllegalArgumentException
615+
| InvocationTargetException e) {
616+
// This block only calls getter methods.
617+
// These getters don't throw any exception except invocationTargetException.
618+
// The getters are public so there is no chance of an IllegalAccessException
619+
// Steps we've followed ensure that the object has the specified method.
589620
}
590-
} catch (IllegalAccessException | IllegalArgumentException
591-
| InvocationTargetException e) {
592-
// This block only calls getter methods.
593-
// These getters don't throw any exception except invocationTargetException.
594-
// The getters are public so there is no chance of an IllegalAccessException
595-
// Steps we've followed ensure that the object has the specified method.
596621
}
622+
clazz = clazz.getSuperclass();
597623
}
598624
}
599625
}

src/main/java/com/bandwidth/AuthManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* BandwidthLib
33
*
4-
* This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ).
4+
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
55
*/
66

77
package com.bandwidth;

0 commit comments

Comments
 (0)