Skip to content

Commit 5e6a106

Browse files
Update readme, changelog, add back some previous changes
Add SendChatMessageResult converting to messageId changes back Add renaming updateChatThread to updateTopic back Add renaming UpdateChatThreadRequest to UpdateTopicRequest back Update README Update CHANGELOG Co-authored-by: Marc Ma <[email protected]>
1 parent 773de46 commit 5e6a106

File tree

6 files changed

+100
-92
lines changed

6 files changed

+100
-92
lines changed

sdk/communication/azure-communication-chat/CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,19 @@
1111

1212
### Breaking Changes
1313
- Chat client is split into chatClient and chatThreadClient
14-
- Rename member and threadMember to participant
1514
- Add participants API changed with a /:add at the end
1615
- Remove priority in message
16+
- Change request and response types to more specific types
17+
- listChatParticipantsPages takes two more parameters: maxPageSize and skip
18+
- listChatReadReceiptsPages takes two more parameters: maxPageSize and skip
19+
20+
### Renamed
21+
- Rename retrieveNextThreadPages to listChatThreadsNext
22+
- Rename retrieveNextThreadPages to listChatThreadsNext
23+
- Rename retrieveNextMessagePages to listChatMessagesNext
24+
- Rename retrieveNextParticipantsPages to listChatParticipantsNext
25+
- Rename retrieveNextReceiptsPages to listChatReadReceiptsNext
26+
1727

1828

1929
## 1.0.0-beta.4 (Skipped)
@@ -33,6 +43,12 @@
3343
- All OffsetDateTime properties are now in RFC3339 format instead of ISO8601 format
3444

3545
## 1.0.0-beta.3 (Skipped)
46+
### Breaking Changes
47+
- Return messageId instead of SendChatMessageResult
48+
- Rename ReadReceipt to ChatMessageReadReceipt
49+
- Rename updateChatThread to updateTopic
50+
- Rename UpdateChatThreadRequest to UpdateTopicRequest
51+
- Rename member and threadMember to participant
3652

3753
## 1.0.0-beta.2 (2020-10-06)
3854
This is the initial release of Azure Communication Services for chat. For more information, please see the [README][read_me] and [documentation][documentation].

sdk/communication/azure-communication-chat/README.md

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,11 @@ CreateChatThreadRequest thread = new CreateChatThreadRequest()
145145
.setTopic(topic)
146146
.setParticipants(participants);
147147

148-
client.createChatThread(thread, new Callback<MultiStatusResponse>() {
149-
public void onSuccess(MultiStatusResponse result, okhttp3.Response response) {
148+
// optional, set a repeat request ID
149+
final String repeatabilityRequestID = '123';
150+
151+
client.createChatThread(thread, repeatabilityRequestID, new Callback<CreateChatThreadResult>() {
152+
public void onSuccess(CreateChatThreadResult result, okhttp3.Response response) {
150153
// MultiStatusResponse is the result returned from creating a thread.
151154
// It has a 'multipleStatus' property which represents a list of IndividualStatusResponse.
152155
String threadId;
@@ -225,9 +228,8 @@ client.listChatThreadsPages(maxPageSize, startTime,
225228
}
226229
});
227230

228-
void retrieveNextThreadPages(String nextPageId,
229-
AsyncPagedDataCollection<ChatThreadInfo, Page<ChatThreadInfo>> pageCollection) {
230-
pageCollection.getPage(nextPageId, new Callback<Page<ChatThreadInfo>>() {
231+
void listChatThreadsNext(String nextLink,
232+
AsyncPagedDataCollection<Page<ChatThreadInfo>> pageCollection) {
231233
@Override
232234
public void onSuccess(Page<ChatThreadInfo> nextPage, Response response) {
233235
for (ChatThreadInfo thread : nextPage.getItems()) {
@@ -242,7 +244,6 @@ void retrieveNextThreadPages(String nextPageId,
242244
public void onFailure(Throwable throwable, Response response) {
243245
// Handle error.
244246
}
245-
});
246247
}
247248
```
248249

@@ -309,7 +310,7 @@ SendChatMessageRequest message = new SendChatMessageRequest()
309310
310311
// The unique ID of the thread.
311312
final String threadId = "<thread_id>";
312-
client.sendChatMessage(threadId, message, new Callback<SendChatMessageResult>() {
313+
client.sendChatMessage(threadId, message, new Callback<String>() {
313314
@Override
314315
public void onSuccess(String messageId, Response response) {
315316
// A string is the response returned from sending a message, it is an id,
@@ -392,9 +393,8 @@ client.listChatMessagesPages(threadId,
392393
}
393394
});
394395
395-
void retrieveNextMessagePages(String nextPageId,
396-
AsyncPagedDataCollection<ChatMessage, Page<ChatMessage>> pageCollection) {
397-
pageCollection.getPage(nextPageId, new Callback<Page<ChatMessage>>() {
396+
void listChatMessagesNext(String nextLink,
397+
AsyncPagedDataCollection<Page<ChatMessage>> pageCollection) {
398398
@Override
399399
public void onSuccess(Page<ChatMessage> nextPage, Response response) {
400400
for (ChatMessage thread : nextPage.getItems()) {
@@ -409,7 +409,6 @@ void retrieveNextMessagePages(String nextPageId,
409409
public void onFailure(Throwable throwable, Response response) {
410410
// Handle error.
411411
}
412-
});
413412
}
414413
```
415414
@@ -472,7 +471,16 @@ Use the `listChatParticipants` method to retrieve the participants participating
472471
```java
473472
// The unique ID of the thread.
474473
final String threadId = "<thread_id>";
474+
475+
// The maximum number of participants to be returned per page, optional.
476+
final int maxPageSize = 10;
477+
478+
// Skips participants up to a specified position in response.
479+
final int skip = 0;
480+
475481
client.listChatParticipantsPages(threadId,
482+
maxPageSize,
483+
skip,
476484
new Callback<AsyncPagedDataCollection<ChatParticipant, Page<ChatParticipant>>>() {
477485
@Override
478486
public void onSuccess(AsyncPagedDataCollection<ChatParticipant, Page<ChatParticipant>> firstPage,
@@ -500,9 +508,8 @@ client.listChatParticipantsPages(threadId,
500508
}
501509
});
502510
503-
void retrieveNextParticipantsPages(String nextPageId,
504-
AsyncPagedDataCollection<ChatParticipant, Page<ChatParticipant>> pageCollection) {
505-
pageCollection.getPage(nextPageId, new Callback<Page<ChatParticipant>>() {
511+
void listChatParticipantsNext(String nextLink,
512+
AsyncPagedDataCollection<Page<ChatParticipant>> pageCollection) {
506513
@Override
507514
public void onSuccess(Page<ChatParticipant> nextPage, Response response) {
508515
for (ChatParticipant participant : nextPage.getItems()) {
@@ -517,7 +524,6 @@ void retrieveNextParticipantsPages(String nextPageId,
517524
public void onFailure(Throwable throwable, Response response) {
518525
// Handle error.
519526
}
520-
});
521527
}
522528
```
523529
@@ -629,15 +635,24 @@ Use the `listChatReadReceipts` method to retrieve read receipts for a thread.
629635
```java
630636
// The unique ID of the thread.
631637
final String threadId = "<thread_id>";
638+
639+
// The maximum number of participants to be returned per page, optional.
640+
final int maxPageSize = 10;
641+
642+
// Skips participants up to a specified position in response.
643+
final int skip = 0;
644+
632645
client.listChatReadReceiptsPages(threadId,
633-
new Callback<AsyncPagedDataCollection<ReadReceipt, Page<ReadReceipt>>>() {
646+
maxPageSize,
647+
skip,
648+
new Callback<AsyncPagedDataCollection<ChatMessageReadReceipt, Page<ChatMessageReadReceipt>>>() {
634649
@Override
635-
public void onSuccess(AsyncPagedDataCollection<ReadReceipt, Page<ReadReceipt>> result,
650+
public void onSuccess(AsyncPagedDataCollection<ChatMessageReadReceipt, Page<ChatMessageReadReceipt>> result,
636651
Response response) {
637652
// pageCollection enables enumerating list of chat participants.
638-
pageCollection.getFirstPage(new Callback<Page<ReadReceipt>>() {
653+
pageCollection.getFirstPage(new Callback<Page<ChatMessageReadReceipt>>() {
639654
@Override
640-
public void onSuccess(Page<ReadReceipt> firstPage, Response response) {
655+
public void onSuccess(Page<ChatMessageReadReceipt> firstPage, Response response) {
641656
for (ReadReceipt receipt : firstPage.getItems()) {
642657
// Take further action.
643658
}
@@ -657,11 +672,10 @@ client.listChatReadReceiptsPages(threadId,
657672
}
658673
});
659674
660-
void retrieveNextReceiptsPages(String nextPageId,
661-
AsyncPagedDataCollection<ReadReceipt, Page<ReadReceipt>> pageCollection) {
662-
pageCollection.getPage(nextPageId, new Callback<Page<ReadReceipt>>() {
675+
void listChatReadReceiptsNext(String nextLink,
676+
AsyncPagedDataCollection<Page<ChatMessageReadReceipt>> pageCollection) {
663677
@Override
664-
public void onSuccess(Page<ReadReceipt> nextPage, Response response) {
678+
public void onSuccess(Page<ChatMessageReadReceipt> nextPage, Response response) {
665679
for (ReadReceipt receipt : nextPage.getItems()) {
666680
// Take further action.
667681
}
@@ -674,7 +688,6 @@ void retrieveNextReceiptsPages(String nextPageId,
674688
public void onFailure(Throwable throwable, Response response) {
675689
// Handle error.
676690
}
677-
});
678691
}
679692
```
680693
@@ -683,7 +696,7 @@ void retrieveNextReceiptsPages(String nextPageId,
683696
When an error occurs, the client calls the callback's `onFailure` method. You can use the provided `Throwable` to act upon the failure.
684697

685698
```java
686-
client.createChatThread(thread, new Callback<MultiStatusResponse>() {
699+
client.createChatThread(thread, new Callback<CreateChatThreadResult>() {
687700
public void onFailure(Throwable throwable, okhttp3.Response response) {
688701
// Handle error.
689702
}

sdk/communication/azure-communication-chat/src/main/java/com/azure/android/communication/chat/ChatThreadAsyncClient.java

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,21 @@
1010
import com.azure.android.communication.chat.models.AddChatParticipantsResult;
1111
import com.azure.android.communication.chat.models.ChatMessage;
1212
import com.azure.android.communication.chat.models.ChatMessageReadReceipt;
13-
import com.azure.android.communication.chat.models.ChatMessageReadReceiptsCollection;
14-
import com.azure.android.communication.chat.models.ChatMessagesCollection;
1513
import com.azure.android.communication.chat.models.ChatParticipant;
16-
import com.azure.android.communication.chat.models.ChatParticipantsCollection;
1714
import com.azure.android.communication.chat.models.CommunicationErrorResponseException;
1815
import com.azure.android.communication.chat.models.SendChatMessageRequest;
1916
import com.azure.android.communication.chat.models.SendChatMessageResult;
2017
import com.azure.android.communication.chat.models.SendReadReceiptRequest;
2118
import com.azure.android.communication.chat.models.UpdateChatMessageRequest;
22-
import com.azure.android.communication.chat.models.UpdateChatThreadRequest;
19+
import com.azure.android.communication.chat.models.UpdateTopicRequest;
2320
import com.azure.android.core.http.Callback;
24-
import com.azure.android.core.http.Response;
2521
import com.azure.android.core.http.ServiceClient;
26-
import com.azure.android.core.http.exception.HttpResponseException;
2722
import com.azure.android.core.http.responsepaging.AsyncPagedDataCollection;
28-
import com.azure.android.core.http.responsepaging.AsyncPagedDataRetriever;
29-
import com.azure.android.core.http.responsepaging.PagedDataResponseCollection;
30-
import com.azure.android.core.http.responsepaging.PagedDataResponseRetriever;
3123
import com.azure.android.core.util.paging.Page;
32-
import com.azure.android.core.util.paging.PagedDataCollection;
33-
import com.azure.android.core.util.paging.PagedDataRetriever;
24+
3425
import okhttp3.Interceptor;
35-
import okhttp3.RequestBody;
36-
import okhttp3.ResponseBody;
26+
3727
import org.threeten.bp.OffsetDateTime;
38-
import retrofit2.Call;
39-
import retrofit2.http.Body;
40-
import retrofit2.http.DELETE;
41-
import retrofit2.http.GET;
42-
import retrofit2.http.Header;
43-
import retrofit2.http.PATCH;
44-
import retrofit2.http.Path;
45-
import retrofit2.http.POST;
46-
import retrofit2.http.Query;
4728

4829
/**
4930
* Initializes a new instance of the asynchronous AzureCommunicationChatService type.
@@ -125,8 +106,23 @@ public void sendChatReadReceipt(String chatThreadId, SendReadReceiptRequest send
125106
* @throws CommunicationErrorResponseException thrown if the request is rejected by server.
126107
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
127108
*/
128-
public void sendChatMessage(String chatThreadId, SendChatMessageRequest sendChatMessageRequest, final Callback<SendChatMessageResult> callback) {
129-
this.serviceClient.sendChatMessage(chatThreadId, sendChatMessageRequest, callback);
109+
public void sendChatMessage(String chatThreadId, SendChatMessageRequest sendChatMessageRequest, final Callback<String> callback) {
110+
Callback<SendChatMessageResult> proxyCallback = new Callback<SendChatMessageResult>() {
111+
@Override
112+
public void onSuccess(SendChatMessageResult result, okhttp3.Response response) {
113+
if (result == null) {
114+
callback.onSuccess(null, response);
115+
} else {
116+
callback.onSuccess(result.getId(), response);
117+
}
118+
}
119+
120+
@Override
121+
public void onFailure(Throwable throwable, okhttp3.Response response) {
122+
callback.onFailure(throwable, response);
123+
}
124+
};
125+
this.serviceClient.sendChatMessage(chatThreadId, sendChatMessageRequest, proxyCallback);
130126
}
131127

132128
/**
@@ -303,14 +299,14 @@ public void addChatParticipants(String chatThreadId, AddChatParticipantsRequest
303299
* Updates a thread's properties.
304300
*
305301
* @param chatThreadId The id of the thread to update.
306-
* @param updateChatThreadRequest Request payload for updating a chat thread.
302+
* @param updateTopicRequest Request payload for updating a chat thread.
307303
* @param callback the Callback that receives the response.
308304
* @throws IllegalArgumentException thrown if parameters fail the validation.
309305
* @throws CommunicationErrorResponseException thrown if the request is rejected by server.
310306
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
311307
*/
312-
public void updateChatThread(String chatThreadId, UpdateChatThreadRequest updateChatThreadRequest, final Callback<Void> callback) {
313-
this.serviceClient.updateChatThread(chatThreadId, updateChatThreadRequest, callback);
308+
public void updateTopic(String chatThreadId, UpdateTopicRequest updateTopicRequest, final Callback<Void> callback) {
309+
this.serviceClient.updateChatThread(chatThreadId, updateTopicRequest, callback);
314310
}
315311

316312
/**

sdk/communication/azure-communication-chat/src/main/java/com/azure/android/communication/chat/ChatThreadClient.java

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,22 @@
1010
import com.azure.android.communication.chat.models.AddChatParticipantsResult;
1111
import com.azure.android.communication.chat.models.ChatMessage;
1212
import com.azure.android.communication.chat.models.ChatMessageReadReceipt;
13-
import com.azure.android.communication.chat.models.ChatMessageReadReceiptsCollection;
14-
import com.azure.android.communication.chat.models.ChatMessagesCollection;
1513
import com.azure.android.communication.chat.models.ChatParticipant;
16-
import com.azure.android.communication.chat.models.ChatParticipantsCollection;
1714
import com.azure.android.communication.chat.models.CommunicationErrorResponseException;
1815
import com.azure.android.communication.chat.models.SendChatMessageRequest;
1916
import com.azure.android.communication.chat.models.SendChatMessageResult;
2017
import com.azure.android.communication.chat.models.SendReadReceiptRequest;
2118
import com.azure.android.communication.chat.models.UpdateChatMessageRequest;
22-
import com.azure.android.communication.chat.models.UpdateChatThreadRequest;
23-
import com.azure.android.core.http.Callback;
19+
import com.azure.android.communication.chat.models.UpdateTopicRequest;
2420
import com.azure.android.core.http.Response;
2521
import com.azure.android.core.http.ServiceClient;
26-
import com.azure.android.core.http.exception.HttpResponseException;
27-
import com.azure.android.core.http.responsepaging.AsyncPagedDataCollection;
28-
import com.azure.android.core.http.responsepaging.AsyncPagedDataRetriever;
2922
import com.azure.android.core.http.responsepaging.PagedDataResponseCollection;
30-
import com.azure.android.core.http.responsepaging.PagedDataResponseRetriever;
3123
import com.azure.android.core.util.paging.Page;
3224
import com.azure.android.core.util.paging.PagedDataCollection;
33-
import com.azure.android.core.util.paging.PagedDataRetriever;
25+
3426
import okhttp3.Interceptor;
35-
import okhttp3.RequestBody;
36-
import okhttp3.ResponseBody;
27+
3728
import org.threeten.bp.OffsetDateTime;
38-
import retrofit2.Call;
39-
import retrofit2.http.Body;
40-
import retrofit2.http.DELETE;
41-
import retrofit2.http.GET;
42-
import retrofit2.http.Header;
43-
import retrofit2.http.PATCH;
44-
import retrofit2.http.Path;
45-
import retrofit2.http.POST;
46-
import retrofit2.http.Query;
4729

4830
/**
4931
* Initializes a new instance of the synchronous AzureCommunicationChatService type.
@@ -140,8 +122,11 @@ public Response<Void> sendChatReadReceiptWithRestResponse(String chatThreadId, S
140122
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
141123
* @return result of the send message operation.
142124
*/
143-
public Response<SendChatMessageResult> sendChatMessageWithRestResponse(String chatThreadId, SendChatMessageRequest sendChatMessageRequest) {
144-
return this.serviceClient.sendChatMessageWithRestResponse(chatThreadId, sendChatMessageRequest);
125+
public Response<String> sendChatMessageWithRestResponse(String chatThreadId, SendChatMessageRequest sendChatMessageRequest) {
126+
Response<SendChatMessageResult> sendResult = this.serviceClient.sendChatMessageWithRestResponse(chatThreadId, sendChatMessageRequest);
127+
if (sendResult.getValue() == null)
128+
return new Response<String>(null, sendResult.getStatusCode(), sendResult.getHeaders(), null);
129+
return new Response<String>(null, sendResult.getStatusCode(), sendResult.getHeaders(), sendResult.getValue().getId());
145130
}
146131

147132
/**
@@ -348,14 +333,14 @@ public Response<AddChatParticipantsResult> addChatParticipantsWithRestResponse(S
348333
* Updates a thread's properties.
349334
*
350335
* @param chatThreadId The id of the thread to update.
351-
* @param updateChatThreadRequest Request payload for updating a chat thread.
336+
* @param updateTopicRequest Request payload for updating a chat thread.
352337
* @throws IllegalArgumentException thrown if parameters fail the validation.
353338
* @throws CommunicationErrorResponseException thrown if the request is rejected by server.
354339
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
355340
* @return the completion.
356341
*/
357-
public Response<Void> updateChatThreadWithRestResponse(String chatThreadId, UpdateChatThreadRequest updateChatThreadRequest) {
358-
return this.serviceClient.updateChatThreadWithRestResponse(chatThreadId, updateChatThreadRequest);
342+
public Response<Void> updateTopicWithRestResponse(String chatThreadId, UpdateTopicRequest updateTopicRequest) {
343+
return this.serviceClient.updateChatThreadWithRestResponse(chatThreadId, updateTopicRequest);
359344
}
360345

361346
/**

0 commit comments

Comments
 (0)