Skip to content

Commit 6996025

Browse files
UPL-244 Add until parameter to listMessages
1 parent 47e9954 commit 6996025

4 files changed

Lines changed: 84 additions & 4 deletions

File tree

symphony-bdk-core/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ dependencies {
7676
}
7777

7878
// OpenAPI code generation
79-
def apiBaseUrl = "https://raw.githubusercontent.com/finos/symphony-api-spec/5526c5e81cb2313c4aab18119b526534652ba98e"
79+
def apiBaseUrl = "https://raw.githubusercontent.com/finos/symphony-api-spec/fc80c3204d8a92a0b82d3c951eab7f5cb78a7c53"
8080
def generatedFolder = "$buildDir/generated/openapi"
8181
def apisToGenerate = [
8282
Agent: 'agent/agent-api-public-deprecated.yaml',

symphony-bdk-core/src/main/java/com/symphony/bdk/core/service/message/MessageService.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ public List<V4Message> listMessages(@Nonnull V4Stream stream, @Nonnull Instant s
143143
return listMessages(stream.getStreamId(), since, pagination);
144144
}
145145

146+
@Override
147+
public List<V4Message> listMessages(@Nonnull V4Stream stream, @Nonnull Instant since, Instant until,
148+
@Nonnull PaginationAttribute pagination) {
149+
return listMessages(stream.getStreamId(), since, until, pagination);
150+
}
151+
146152
/**
147153
* {@inheritDoc}
148154
*/
@@ -151,6 +157,11 @@ public List<V4Message> listMessages(@Nonnull V4Stream stream, @Nonnull Instant s
151157
return listMessages(stream.getStreamId(), since);
152158
}
153159

160+
@Override
161+
public List<V4Message> listMessages(@Nonnull V4Stream stream, @Nonnull Instant since, Instant until) {
162+
return listMessages(stream.getStreamId(), since, until);
163+
}
164+
154165
/**
155166
* {@inheritDoc}
156167
*/
@@ -159,6 +170,19 @@ public List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant s
159170
@Nonnull PaginationAttribute pagination) {
160171
return executeAndRetry("getMessages", messageApi.getApiClient().getBasePath(),
161172
() -> messagesApi.v4StreamSidMessageGet(toUrlSafeIdIfNeeded(streamId), getEpochMillis(since),
173+
null,
174+
pagination.getSkip(),
175+
pagination.getLimit(),
176+
authSession.getSessionToken(),
177+
authSession.getKeyManagerToken()));
178+
}
179+
180+
@Override
181+
public List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant since, Instant until,
182+
@Nonnull PaginationAttribute pagination) {
183+
return executeAndRetry("getMessages", messageApi.getApiClient().getBasePath(),
184+
() -> messagesApi.v4StreamSidMessageGet(toUrlSafeIdIfNeeded(streamId), getEpochMillis(since),
185+
getEpochMillis(until),
162186
pagination.getSkip(),
163187
pagination.getLimit(),
164188
authSession.getSessionToken(),
@@ -171,7 +195,14 @@ public List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant s
171195
@Override
172196
public List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant since) {
173197
return executeAndRetry("getMessages", messageApi.getApiClient().getBasePath(),
174-
() -> messagesApi.v4StreamSidMessageGet(toUrlSafeIdIfNeeded(streamId), getEpochMillis(since), null, null,
198+
() -> messagesApi.v4StreamSidMessageGet(toUrlSafeIdIfNeeded(streamId), getEpochMillis(since), null,null, null,
199+
authSession.getSessionToken(), authSession.getKeyManagerToken()));
200+
}
201+
202+
@Override
203+
public List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant since, Instant until) {
204+
return executeAndRetry("getMessages", messageApi.getApiClient().getBasePath(),
205+
() -> messagesApi.v4StreamSidMessageGet(toUrlSafeIdIfNeeded(streamId), getEpochMillis(since), getEpochMillis(until),null, null,
175206
authSession.getSessionToken(), authSession.getKeyManagerToken()));
176207
}
177208

symphony-bdk-core/src/main/java/com/symphony/bdk/core/service/message/OboMessageService.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ public interface OboMessageService {
4141
*/
4242
List<V4Message> listMessages(@Nonnull V4Stream stream, @Nonnull Instant since, @Nonnull PaginationAttribute pagination);
4343

44+
/**
45+
* Get messages from an existing stream. Additionally returns any attachments associated with the message.
46+
*
47+
* @param stream the stream where to look for messages
48+
* @param since instant of the earliest possible date of the first message returned.
49+
* @param until instant of the last possible date of the last message returned.
50+
* @param pagination The skip and limit for pagination.
51+
* @return the list of matching messages in the stream.
52+
* @see <a href="https://developers.symphony.com/restapi/reference/messages-v4">Messages</a>
53+
*/
54+
List<V4Message> listMessages(@Nonnull V4Stream stream, @Nonnull Instant since, Instant until, @Nonnull PaginationAttribute pagination);
55+
4456
/**
4557
* Get messages from an existing stream with default limit equals 50.
4658
* Additionally returns any attachments associated with the message.
@@ -52,6 +64,19 @@ public interface OboMessageService {
5264
*/
5365
List<V4Message> listMessages(@Nonnull V4Stream stream, @Nonnull Instant since);
5466

67+
/**
68+
* Get messages from an existing stream with default limit equals 50.
69+
* Additionally returns any attachments associated with the message.
70+
*
71+
* @param stream the stream where to look for messages
72+
* @param since instant of the earliest possible date of the first message returned.
73+
* @param until instant of the last possible date of the last message returned.
74+
* @return the list of matching messages in the stream.
75+
* @see <a href="https://developers.symphony.com/restapi/reference/messages-v4">Messages</a>
76+
*/
77+
List<V4Message> listMessages(@Nonnull V4Stream stream, @Nonnull Instant since, Instant until);
78+
79+
5580
/**
5681
* Get messages from an existing stream. Additionally returns any attachments associated with the message.
5782
*
@@ -63,6 +88,18 @@ public interface OboMessageService {
6388
*/
6489
List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant since, @Nonnull PaginationAttribute pagination);
6590

91+
/**
92+
* Get messages from an existing stream. Additionally returns any attachments associated with the message.
93+
*
94+
* @param streamId the streamID where to look for messages
95+
* @param since instant of the earliest possible date of the first message returned.
96+
* @param until instant of the last possible date of the last message returned.
97+
* @param pagination The skip and limit for pagination.
98+
* @return the list of matching messages in the stream.
99+
* @see <a href="https://developers.symphony.com/restapi/reference/messages-v4">Messages</a>
100+
*/
101+
List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant since, Instant until, @Nonnull PaginationAttribute pagination);
102+
66103
/**
67104
* Get messages from an existing stream with default limit equals 50.
68105
* Additionally returns any attachments associated with the message.
@@ -74,6 +111,18 @@ public interface OboMessageService {
74111
*/
75112
List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant since);
76113

114+
/**
115+
* Get messages from an existing stream with default limit equals 50.
116+
* Additionally returns any attachments associated with the message.
117+
*
118+
* @param streamId the streamID where to look for messages
119+
* @param since instant of the earliest possible date of the first message returned.
120+
* @param until instant of the last possible date of the last message returned.
121+
* @return the list of matching messages in the stream.
122+
* @see <a href="https://developers.symphony.com/restapi/reference/messages-v4">Messages</a>
123+
*/
124+
List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant since, Instant until);
125+
77126
/**
78127
* Sends a message to the stream ID of the passed {@link V4Stream} object.
79128
*

symphony-bdk-core/src/test/java/com/symphony/bdk/core/service/message/MessageServiceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void testGetMessagesWithStreamObject() {
162162
@Test
163163
void testGetPaginationMessagesWithStreamObject() {
164164
MessageService service = spy(messageService);
165-
doReturn(Collections.emptyList()).when(service).listMessages(anyString(), any(), any());
165+
doReturn(Collections.emptyList()).when(service).listMessages(anyString(), any(Instant.class), any(PaginationAttribute.class));
166166

167167
final V4Stream v4Stream = new V4Stream().streamId(STREAM_ID);
168168
Instant now = Instant.now();
@@ -177,7 +177,7 @@ void testGetMessages() throws IOException {
177177
mockApiClient.onGet(V4_STREAM_MESSAGE.replace("{sid}", streamId),
178178
JsonHelper.readFromClasspath("/message/get_message_stream_id.json"));
179179

180-
final List<V4Message> messages = messageService.listMessages(streamId, Instant.now());
180+
final List<V4Message> messages = messageService.listMessages(streamId, Instant.now(), Instant.now());
181181

182182
assertEquals(2, messages.size());
183183
assertEquals(Arrays.asList("messageId1", "messageId2"),

0 commit comments

Comments
 (0)