Skip to content

Commit

Permalink
fix: Make timestamp optional in Conversion API
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Jul 12, 2024
1 parent ab0aebd commit 82117c5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

# [8.9.2] - 2024-07-12
- Refactoring to accommodate using v2.0.0 of Vonage JWT library
- Made `timestamp` optional in Conversion API
- Fixed `SpeechSettings.Language.NEPALI` (de)serialisation
- `fromRandomNumber` true if `from` is not specified in `Call.Builder`
- Fixed `com.vonage.client.voice.EventWebhook` deserialisation issue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
import java.util.LinkedHashMap;
import java.util.Map;

/**
*
* @deprecated This class will be made package-private in the next major release.
*/
@Deprecated
public class ConversionRequest implements QueryParamsRequest {
private final Type type;
private final String messageId;
Expand Down Expand Up @@ -55,10 +60,15 @@ public Map<String, String> makeParams() {
LinkedHashMap<String, String> params = new LinkedHashMap<>(4);
params.put("message-id", messageId);
params.put("delivered", String.valueOf(delivered));
params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timestamp));
if (timestamp != null) {
params.put("timestamp", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timestamp));
}
return params;
}

/**
* This enum will be moved to its own class in the next major release.
*/
public enum Type {
SMS, VOICE
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@
import org.junit.jupiter.api.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.*;

public class ConversionClientTest extends AbstractClientTest<ConversionClient> {

Expand All @@ -40,21 +37,24 @@ public ConversionClientTest() {
}

@Test
public void testSuccessfulResponse() throws Exception {
public void testSuccessWithTimestamp() throws Exception {
stubResponse(200);
client.submitConversion(ConversionRequest.Type.VOICE,
"MESSAGE-ID",
true,
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2014-03-04 10:11:12"));
client.submitConversion(ConversionRequest.Type.VOICE, UUID.randomUUID().toString(), false,
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2014-03-04 10:11:12")
);
}

@Test
public void testSuccessWithoutTimestamp() throws Exception {
stubResponse(200);
client.submitConversion(ConversionRequest.Type.SMS, "MESSAGE-ID", true, null);
}

@Test
public void testWrongCredentials() throws Exception {
stubResponse(401);
assertThrows(VonageApiResponseException.class, () -> client.submitConversion(
ConversionRequest.Type.SMS,
"MESSAGE-ID",
true,
ConversionRequest.Type.SMS, "MESSAGE-ID", true,
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2014-03-04 10:11:12")
));
}
Expand Down

0 comments on commit 82117c5

Please sign in to comment.