Skip to content

Commit 82117c5

Browse files
committed
fix: Make timestamp optional in Conversion API
1 parent ab0aebd commit 82117c5

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44

55
# [8.9.2] - 2024-07-12
66
- Refactoring to accommodate using v2.0.0 of Vonage JWT library
7+
- Made `timestamp` optional in Conversion API
78
- Fixed `SpeechSettings.Language.NEPALI` (de)serialisation
89
- `fromRandomNumber` true if `from` is not specified in `Call.Builder`
910
- Fixed `com.vonage.client.voice.EventWebhook` deserialisation issue

src/main/java/com/vonage/client/conversion/ConversionRequest.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
import java.util.LinkedHashMap;
2222
import java.util.Map;
2323

24+
/**
25+
*
26+
* @deprecated This class will be made package-private in the next major release.
27+
*/
28+
@Deprecated
2429
public class ConversionRequest implements QueryParamsRequest {
2530
private final Type type;
2631
private final String messageId;
@@ -55,10 +60,15 @@ public Map<String, String> makeParams() {
5560
LinkedHashMap<String, String> params = new LinkedHashMap<>(4);
5661
params.put("message-id", messageId);
5762
params.put("delivered", String.valueOf(delivered));
58-
params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timestamp));
63+
if (timestamp != null) {
64+
params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timestamp));
65+
}
5966
return params;
6067
}
6168

69+
/**
70+
* This enum will be moved to its own class in the next major release.
71+
*/
6272
public enum Type {
6373
SMS, VOICE
6474
}

src/test/java/com/vonage/client/conversion/ConversionClientTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@
2828
import org.junit.jupiter.api.*;
2929
import java.text.ParseException;
3030
import java.text.SimpleDateFormat;
31-
import java.util.Arrays;
32-
import java.util.Collection;
33-
import java.util.LinkedHashMap;
34-
import java.util.Map;
31+
import java.util.*;
3532

3633
public class ConversionClientTest extends AbstractClientTest<ConversionClient> {
3734

@@ -40,21 +37,24 @@ public ConversionClientTest() {
4037
}
4138

4239
@Test
43-
public void testSuccessfulResponse() throws Exception {
40+
public void testSuccessWithTimestamp() throws Exception {
4441
stubResponse(200);
45-
client.submitConversion(ConversionRequest.Type.VOICE,
46-
"MESSAGE-ID",
47-
true,
48-
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2014-03-04 10:11:12"));
42+
client.submitConversion(ConversionRequest.Type.VOICE, UUID.randomUUID().toString(), false,
43+
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2014-03-04 10:11:12")
44+
);
45+
}
46+
47+
@Test
48+
public void testSuccessWithoutTimestamp() throws Exception {
49+
stubResponse(200);
50+
client.submitConversion(ConversionRequest.Type.SMS, "MESSAGE-ID", true, null);
4951
}
5052

5153
@Test
5254
public void testWrongCredentials() throws Exception {
5355
stubResponse(401);
5456
assertThrows(VonageApiResponseException.class, () -> client.submitConversion(
55-
ConversionRequest.Type.SMS,
56-
"MESSAGE-ID",
57-
true,
57+
ConversionRequest.Type.SMS, "MESSAGE-ID", true,
5858
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2014-03-04 10:11:12")
5959
));
6060
}

0 commit comments

Comments
 (0)