Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACS chat: Api changes jan 2021 #18574

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sdk/communication/azure-communication-chat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Use the `createChatThread` method to create a chat thread.
- Use `participants` to list the thread participants to be added to the thread;

`CreateChatThreadResult` is the response returned from creating a chat thread.
It contains a `getThread()` method which returns the `ChatThread` object that can be used to get the thread client from which you can get the `ChatThreadClient` for performing operations on the created thread: add participants, send message, etc.
It contains a `getChatThread()` method which returns the `ChatThread` object that can be used to get the thread client from which you can get the `ChatThreadClient` for performing operations on the created thread: add participants, send message, etc.
The `ChatThread` object also contains the `getId()` method which retrieves the unique ID of the thread.

<!-- embedme ./src/samples/java/com/azure/communication/chat/ReadmeSamples.java#L71-L88 -->
Expand All @@ -125,7 +125,7 @@ CreateChatThreadOptions createChatThreadOptions = new CreateChatThreadOptions()
.setTopic("Topic")
.setParticipants(participants);
CreateChatThreadResult result = chatClient.createChatThread(createChatThreadOptions);
String chatThreadId = result.getThread().getId();
String chatThreadId = result.getChatThread().getId();
```

#### Get a chat thread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.azure.communication.chat.implementation.converters.SendChatMessageResultConverter;
import com.azure.communication.chat.implementation.models.SendReadReceiptRequest;
import com.azure.communication.chat.models.AddChatParticipantsOptions;
import com.azure.communication.chat.models.AddChatParticipantsResult;
import com.azure.communication.chat.models.ChatMessage;
import com.azure.communication.chat.models.ChatParticipant;
import com.azure.communication.chat.models.ChatMessageReadReceipt;
Expand Down Expand Up @@ -129,15 +130,12 @@ Mono<Response<Void>> updateTopic(String topic, Context context) {
* Adds participants to a thread. If participants already exist, no change occurs.
*
* @param options Options for adding participants.
* @return the completion.
* @return the result.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> addParticipants(AddChatParticipantsOptions options) {
public Mono<Response<AddChatParticipantsResult>> addParticipants(AddChatParticipantsOptions options) {
try {
return withContext(context -> addParticipants(options, context)
.flatMap((Response<Void> res) -> {
return Mono.empty();
}));
return withContext(context -> addParticipants(options, context));
} catch (RuntimeException ex) {

return monoError(logger, ex);
Expand All @@ -148,10 +146,10 @@ public Mono<Void> addParticipants(AddChatParticipantsOptions options) {
* Adds participants to a thread. If participants already exist, no change occurs.
*
* @param options Options for adding participants.
* @return the completion.
* @return the result.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> addParticipantsWithResponse(AddChatParticipantsOptions options) {
public Mono<Response<AddChatParticipantsResult>> addParticipantsWithResponse(AddChatParticipantsOptions options) {
try {
return withContext(context -> addParticipants(options, context));
} catch (RuntimeException ex) {
Expand All @@ -164,18 +162,15 @@ public Mono<Response<Void>> addParticipantsWithResponse(AddChatParticipantsOptio
* Adds a participant to a thread. If the participant already exists, no change occurs.
*
* @param participant The new participant.
* @return the completion.
* @return the result.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> addParticipant(ChatParticipant participant) {
public Mono<Response<AddChatParticipantsResult>> addParticipant(ChatParticipant participant) {
try {
return withContext(context -> addParticipants(
new AddChatParticipantsOptions()
.setParticipants(Collections.singletonList(participant)),
context)
.flatMap((Response<Void> res) -> {
return Mono.empty();
}));
context));
} catch (RuntimeException ex) {

return monoError(logger, ex);
Expand All @@ -186,10 +181,10 @@ public Mono<Void> addParticipant(ChatParticipant participant) {
* Adds a participant to a thread. If the participant already exists, no change occurs.
*
* @param participant The new participant.
* @return the completion.
* @return the result.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> addParticipantWithResponse(ChatParticipant participant) {
public Mono<Response<AddChatParticipantsResult>> addParticipantWithResponse(ChatParticipant participant) {
try {
return withContext(context -> addParticipants(
new AddChatParticipantsOptions()
Expand All @@ -206,9 +201,9 @@ public Mono<Response<Void>> addParticipantWithResponse(ChatParticipant participa
*
* @param options Options for adding participants.
* @param context The context to associate with this operation.
* @return the completion.
* @return the result.
*/
Mono<Response<Void>> addParticipants(AddChatParticipantsOptions options, Context context) {
Mono<Response<AddChatParticipantsResult>> addParticipants(AddChatParticipantsOptions options, Context context) {
context = context == null ? Context.NONE : context;

Objects.requireNonNull(options, "'options' cannot be null.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.
package com.azure.communication.chat;

import com.azure.communication.chat.models.AddChatParticipantsResult;
import com.azure.communication.chat.models.AddChatParticipantsOptions;
import com.azure.communication.chat.models.ChatMessage;
import com.azure.communication.chat.models.ChatParticipant;
Expand Down Expand Up @@ -96,8 +97,8 @@ public void addParticipants(AddChatParticipantsOptions options) {
* @return the completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> addParticipantsWithResponse(AddChatParticipantsOptions options, Context context) {

public Response<AddChatParticipantsResult> addParticipantsWithResponse(
AddChatParticipantsOptions options, Context context) {
return this.client.addParticipants(options, context).block();
}

Expand All @@ -121,7 +122,8 @@ public void addParticipant(ChatParticipant participant) {
* @return the completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> addParticipantWithResponse(ChatParticipant participant, Context context) {
public Response<AddChatParticipantsResult> addParticipantWithResponse(ChatParticipant participant,
Context context) {

return this.client.addParticipants(new AddChatParticipantsOptions()
.setParticipants(Collections.singletonList(participant)), context).block();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,27 @@ public SerializerAdapter getSerializerAdapter() {
}

/** The ChatThreadsImpl object to access its operations. */
private final ChatThreadImpl chatThreadClient;
private final ChatThreadImpl chatThreads;

/**
* Gets the ChatThreadsImpl object to access its operations.
*
* @return the ChatThreadsImpl object.
*/
public ChatThreadImpl getChatThreadClient() {
return this.chatThreadClient;
return this.chatThreads;
}

/** The ChatsImpl object to access its operations. */
private final ChatImpl chatClient;
private final ChatImpl chats;

/**
* Gets the ChatsImpl object to access its operations.
*
* @return the ChatsImpl object.
*/
public ChatImpl getChatClient() {
return this.chatClient;
return this.chats;
}

/** Initializes an instance of AzureCommunicationChatService client. */
Expand Down Expand Up @@ -116,7 +116,7 @@ public ChatImpl getChatClient() {
this.serializerAdapter = serializerAdapter;
this.endpoint = endpoint;
this.apiVersion = "2020-11-01-preview3";
this.chatThreadClient = new ChatThreadImpl(this);
this.chatClient = new ChatImpl(this);
this.chatThreads = new ChatThreadImpl(this);
this.chats = new ChatImpl(this);
}
}
Loading