Skip to content

Commit

Permalink
fix: ConversationsClient.listEvents (#537)
Browse files Browse the repository at this point in the history
* Bump version

* Add Embedded object to ListEventsResponse

* Make GenericEvent builder accessible
  • Loading branch information
SMadani authored Jul 9, 2024
1 parent 7e9785b commit 9bde798
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 40 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
# [8.9.1] - 2024-07-09
- Fixed parsing issue in `ConversationsClient#listEvents`
- `body` method in `CustomEvent.Builder` is now accessible
- Bumped JWT library version to 1.1.3

# [8.9.0] - 2024-06-20
- Added `User-to-User` header in Voice Connect SIP endpoint
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.vonage</groupId>
<artifactId>server-sdk</artifactId>
<version>8.9.0</version>
<version>8.9.1</version>

<packaging>jar</packaging>
<name>Vonage Java Server SDK</name>
Expand Down Expand Up @@ -46,15 +46,15 @@
<java.testVersion>21</java.testVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<nexusUrl>https://oss.sonatype.org</nexusUrl>
<jackson.version>2.17.1</jackson.version>
<jackson.version>2.17.2</jackson.version>
</properties>

<dependencies>
<!-- Compile / Runtime -->
<dependency>
<groupId>com.vonage</groupId>
<artifactId>jwt</artifactId>
<version>1.1.1</version>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/vonage/client/HttpWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
public class HttpWrapper {
private static final String
CLIENT_NAME = "vonage-java-sdk",
CLIENT_VERSION = "8.9.0",
CLIENT_VERSION = "8.9.1",
JAVA_VERSION = System.getProperty("java.version"),
USER_AGENT = String.format("%s/%s java/%s", CLIENT_NAME, CLIENT_VERSION, JAVA_VERSION);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GenericEvent extends EventWithBody<Map<String, ?>> {
}

@SuppressWarnings("unchecked")
static abstract class Builder<E extends GenericEvent,
public static abstract class Builder<E extends GenericEvent,
B extends Builder<? extends E, ? extends B>>
extends EventWithBody.Builder<GenericEvent, Builder<E, B>> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,32 @@
*/
package com.vonage.client.conversations;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.vonage.client.JsonableBaseObject;
import com.vonage.client.common.HalPageResponse;
import java.util.List;

/**
* HAL response for {@link ConversationsClient#listEvents(String, ListEventsRequest)}.
*/
public final class ListEventsResponse extends HalPageResponse {
@JsonProperty("_embedded") private List<Event> events;
@JsonProperty("_embedded") private Embedded _embedded;

ListEventsResponse() {
}

static final class Embedded extends JsonableBaseObject {
@JsonProperty("events") private List<Event> events;
}

/**
* Gets the events contained in the {@code _embedded} response.
*
* @return The events for this page.
*/
@JsonProperty("_embedded")
@JsonIgnore
public List<Event> getEvents() {
return events;
return _embedded != null ? _embedded.events : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public class ConversationsClientTest extends AbstractClientTest<ConversationsCli
"updated": "\{TIMESTAMP_UPDATED_STR}",
"destroyed": "\{TIMESTAMP_DESTROYED_STR}"
},""",
SAMPLE_BASE_CONVERSATION_RESPONSE = STR."\{SAMPLE_BASE_CONVERSATION_RESPONSE_PARTIAL
.substring(0, SAMPLE_BASE_CONVERSATION_RESPONSE_PARTIAL.length() - 1)}\n\t}",
SAMPLE_BASE_CONVERSATION_RESPONSE = SAMPLE_BASE_CONVERSATION_RESPONSE_PARTIAL
.substring(0, SAMPLE_BASE_CONVERSATION_RESPONSE_PARTIAL.length() - 1)+"\n\t}",
SAMPLE_CONVERSATION_RESPONSE_PARTIAL = SAMPLE_BASE_CONVERSATION_RESPONSE_PARTIAL + STR."""
"state": "\{CONVERSATION_STATE_STR}",
"sequence_number": \{CONVERSATION_SEQUENCE_NUMBER},
Expand Down Expand Up @@ -207,30 +207,6 @@ public class ConversationsClientTest extends AbstractClientTest<ConversationsCli
}
}
""",
SAMPLE_LIST_USER_SESSIONS_RESPONSE = STR."""
{
"page_size": \{PAGE_SIZE},
"_embedded": {
"sessions": [
{}, \{SAMPLE_USER_SESSION_RESPONSE}, {"_embedded":{"user":{}}}
]
},
"_links": {
"first": {
"href": "https://api.nexmo.com/v1/users/USR-82e028d9-5201-4f1e-8188-604b2d3471ec/sessions?order=desc&page_size=10"
},
"self": {
"href": "https://api.nexmo.com/v1/users/USR-82e028d9-5201-4f1e-8188-604b2d3471ec/sessions?order=desc&page_size=10&cursor=7EjDNQrAcipmOnc0HCzpQRkhBULzY44ljGUX4lXKyUIVfiZay5pv9wg="
},
"next": {
"href": "https://api.nexmo.com/v1/users/USR-82e028d9-5201-4f1e-8188-604b2d3471ec/sessions?order=desc&page_size=10&cursor=7EjDNQrAcipmOnc0HCzpQRkhBULzY44ljGUX4lXKyUIVfiZay5pv9wg="
},
"prev": {
"href": "https://api.nexmo.com/v1/users/USR-82e028d9-5201-4f1e-8188-604b2d3471ec/sessions?order=desc&page_size=10&cursor=7EjDNQrAcipmOnc0HCzpQRkhBULzY44ljGUX4lXKyUIVfiZay5pv9wg="
}
}
}
""",
SAMPLE_BASE_MEMBER_RESPONSE_PARTIAL = STR."""
{
"id": "\{MEMBER_ID}",
Expand Down Expand Up @@ -349,10 +325,12 @@ public class ConversationsClientTest extends AbstractClientTest<ConversationsCli
"_links": {
"first": {},"self": {},"next": {},"prev": {}
},
"_embedded": [
\{SAMPLE_EVENT_RESPONSE},
{}, {"type": "\{KNOWN_EVENT_TYPE_STR}"}
]
"_embedded": {
"events": [
\{SAMPLE_EVENT_RESPONSE},
{}, {"type": "\{KNOWN_EVENT_TYPE_STR}"}
]
}
}
""";

Expand Down

0 comments on commit 9bde798

Please sign in to comment.