Skip to content

Commit

Permalink
[Communication] - Identity - CommunicationUserIdentifierAndTokenResul…
Browse files Browse the repository at this point in the history
…t renaming (Azure#19599)

* Updated changelog

* Addressed comments

* CommunicationUserIdentifierAndTokenResult name
  • Loading branch information
jbeauregardb authored Mar 4, 2021
1 parent 0f616e4 commit e01f66b
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
`CommunicationIdentityClient.createUserAndToken` and `CommunicationIdentityAsyncClient.createUserAndToken`.
- `CommunicationIdentityClient.createUserWithTokenWithResponse` and `CommunicationIdentityAsyncClient.createUserWithTokenWithResponse` have been renamed to
`CommunicationIdentityClient.createUserAndTokenWithResponse` and `CommunicationIdentityAsyncClient.createUserAndTokenWithResponse`.
- `CommunicationUserIdentifierWithTokenResult` class has been renamed to `CommunicationUserIdentifierAndTokenResult`.
- `CommunicationUserIdentifierWithTokenResult` class has been renamed to `CommunicationUserIdentifierAndToken`.

## 1.0.0-beta.5 (2021-03-02)
### Breaking
Expand Down
2 changes: 1 addition & 1 deletion sdk/communication/azure-communication-identity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ For this option, a list of communication tokens scopes must be defined.
List<CommunicationTokenScope> scopes =
new ArrayList<>(Arrays.asList(CommunicationTokenScope.CHAT));

CommunicationUserIdentifierAndTokenResult result = communicationIdentityClient.createUserAndToken(scopes);
CommunicationUserIdentifierAndToken result = communicationIdentityClient.createUserAndToken(scopes);
System.out.println("User id: " + result.getUser().getId());
System.out.println("User token value: " + result.getUserToken().getToken());
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.azure.communication.identity.implementation.models.CommunicationIdentityAccessTokenResult;
import com.azure.communication.identity.implementation.models.CommunicationIdentityCreateRequest;
import com.azure.communication.identity.models.CommunicationTokenScope;
import com.azure.communication.identity.models.CommunicationUserIdentifierAndTokenResult;
import com.azure.communication.identity.models.CommunicationUserIdentifierAndToken;
import com.azure.communication.common.CommunicationUserIdentifier;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
Expand Down Expand Up @@ -90,7 +90,7 @@ public Mono<Response<CommunicationUserIdentifier>> createUserWithResponse() {
* @return the result with created communication user and token.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<CommunicationUserIdentifierAndTokenResult>
public Mono<CommunicationUserIdentifierAndToken>
createUserAndToken(Iterable<CommunicationTokenScope> scopes) {
try {
Objects.requireNonNull(scopes);
Expand All @@ -112,7 +112,7 @@ public Mono<Response<CommunicationUserIdentifier>> createUserWithResponse() {
* @return the result with created communication user and token with response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<CommunicationUserIdentifierAndTokenResult>>
public Mono<Response<CommunicationUserIdentifierAndToken>>
createUserAndTokenWithResponse(Iterable<CommunicationTokenScope> scopes) {
try {
Objects.requireNonNull(scopes);
Expand All @@ -121,7 +121,7 @@ public Mono<Response<CommunicationUserIdentifier>> createUserWithResponse() {
new CommunicationIdentityCreateRequest().setCreateTokenWithScopes(scopesInput))
.flatMap(
(Response<CommunicationIdentityAccessTokenResult> response) -> {
return Mono.just(new SimpleResponse<CommunicationUserIdentifierAndTokenResult>(response,
return Mono.just(new SimpleResponse<CommunicationUserIdentifierAndToken>(response,
userWithAccessTokenResultConverter(response.getValue())));
});
} catch (RuntimeException ex) {
Expand Down Expand Up @@ -245,18 +245,18 @@ public Mono<Response<AccessToken>> getTokenWithResponse(CommunicationUserIdentif
}

/**
* Converts CommunicationIdentityAccessTokenResult to CommunicationUserIdentifierAndTokenResult
* Converts CommunicationIdentityAccessTokenResult to CommunicationUserIdentifierAndToken
*
* @param identityAccessTokenResult The result input.
* @return the result converted to CommunicationUserIdentifierAndTokenResult type
* @return the result converted to CommunicationUserIdentifierAndToken type
*/
private CommunicationUserIdentifierAndTokenResult userWithAccessTokenResultConverter(
private CommunicationUserIdentifierAndToken userWithAccessTokenResultConverter(
CommunicationIdentityAccessTokenResult identityAccessTokenResult) {
CommunicationUserIdentifier user =
new CommunicationUserIdentifier(identityAccessTokenResult.getIdentity().getId());
AccessToken token = new AccessToken(
identityAccessTokenResult.getAccessToken().getToken(),
identityAccessTokenResult.getAccessToken().getExpiresOn());
return new CommunicationUserIdentifierAndTokenResult(user, token);
return new CommunicationUserIdentifierAndToken(user, token);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.azure.communication.identity.implementation.models.CommunicationIdentityAccessTokenResult;
import com.azure.communication.identity.implementation.models.CommunicationIdentityCreateRequest;
import com.azure.communication.identity.models.CommunicationTokenScope;
import com.azure.communication.identity.models.CommunicationUserIdentifierAndTokenResult;
import com.azure.communication.identity.models.CommunicationUserIdentifierAndToken;
import com.azure.communication.common.CommunicationUserIdentifier;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
Expand Down Expand Up @@ -79,7 +79,7 @@ public Response<CommunicationUserIdentifier> createUserWithResponse(Context cont
* @return the result with created communication user and token
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public CommunicationUserIdentifierAndTokenResult createUserAndToken(
public CommunicationUserIdentifierAndToken createUserAndToken(
Iterable<CommunicationTokenScope> scopes) {
Objects.requireNonNull(scopes);
final List<CommunicationTokenScope> scopesInput = StreamSupport.stream(scopes.spliterator(), false).collect(Collectors.toList());
Expand All @@ -96,7 +96,7 @@ public CommunicationUserIdentifierAndTokenResult createUserAndToken(
* @return the result with created communication user and token
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<CommunicationUserIdentifierAndTokenResult> createUserAndTokenWithResponse(
public Response<CommunicationUserIdentifierAndToken> createUserAndTokenWithResponse(
Iterable<CommunicationTokenScope> scopes, Context context) {
Objects.requireNonNull(scopes);
context = context == null ? Context.NONE : context;
Expand All @@ -107,7 +107,7 @@ public Response<CommunicationUserIdentifierAndTokenResult> createUserAndTokenWit
if (response == null || response.getValue() == null) {
throw logger.logExceptionAsError(new IllegalStateException("Service failed to return a response or expected value."));
}
return new SimpleResponse<CommunicationUserIdentifierAndTokenResult>(
return new SimpleResponse<CommunicationUserIdentifierAndToken>(
response,
userWithAccessTokenResultConverter(response.getValue()));
}
Expand Down Expand Up @@ -215,14 +215,14 @@ public Response<AccessToken> getTokenWithResponse(CommunicationUserIdentifier co
new AccessToken(response.getValue().getToken(), response.getValue().getExpiresOn()));
}

private CommunicationUserIdentifierAndTokenResult userWithAccessTokenResultConverter(
private CommunicationUserIdentifierAndToken userWithAccessTokenResultConverter(
CommunicationIdentityAccessTokenResult identityAccessTokenResult) {
CommunicationUserIdentifier user =
new CommunicationUserIdentifier(identityAccessTokenResult.getIdentity().getId());
AccessToken token = new AccessToken(
identityAccessTokenResult.getAccessToken().getToken(),
identityAccessTokenResult.getAccessToken().getExpiresOn());
return new CommunicationUserIdentifierAndTokenResult(user, token);
return new CommunicationUserIdentifierAndToken(user, token);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
import com.azure.core.credential.AccessToken;

/** The CommunicationUserIdentifierWithAccessTokenResult model. */
public final class CommunicationUserIdentifierAndTokenResult {
public final class CommunicationUserIdentifierAndToken {

private final CommunicationUserIdentifier communicationUser;
private final AccessToken userToken;

/**
* Creates a CommunicationUserIdentifierAndTokenResult object
* Creates a CommunicationUserIdentifierAndToken object
*
* @param communicationUser the communication user identifier
* @param userToken the user token of the communication user
* @throws IllegalArgumentException thrown if id parameter fail the validation.
*/
public CommunicationUserIdentifierAndTokenResult(CommunicationUserIdentifier communicationUser,
public CommunicationUserIdentifierAndToken(CommunicationUserIdentifier communicationUser,
AccessToken userToken) {
this.communicationUser = communicationUser;
this.userToken = userToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import com.azure.communication.common.CommunicationUserIdentifier;
import com.azure.communication.identity.models.CommunicationTokenScope;
import com.azure.communication.identity.models.CommunicationUserIdentifierAndTokenResult;
import com.azure.communication.identity.models.CommunicationUserIdentifierAndToken;
import com.azure.core.credential.AccessToken;
import com.azure.core.credential.AzureKeyCredential;
import com.azure.core.http.HttpClient;
Expand Down Expand Up @@ -96,13 +96,13 @@ public CommunicationUserIdentifier createNewUser() {
*
* @return the result with the created user and token
*/
public CommunicationUserIdentifierAndTokenResult createNewUserAndToken() {
public CommunicationUserIdentifierAndToken createNewUserAndToken() {
CommunicationIdentityClient communicationIdentityClient = createCommunicationIdentityClient();
// Define a list of communication token scopes
List<CommunicationTokenScope> scopes =
new ArrayList<>(Arrays.asList(CommunicationTokenScope.CHAT));

CommunicationUserIdentifierAndTokenResult result = communicationIdentityClient.createUserAndToken(scopes);
CommunicationUserIdentifierAndToken result = communicationIdentityClient.createUserAndToken(scopes);
System.out.println("User id: " + result.getUser().getId());
System.out.println("User token value: " + result.getUserToken().getToken());
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import com.azure.communication.common.CommunicationUserIdentifier;
import com.azure.communication.identity.models.CommunicationTokenScope;
import com.azure.communication.identity.models.CommunicationUserIdentifierAndTokenResult;
import com.azure.communication.identity.models.CommunicationUserIdentifierAndToken;
import com.azure.core.credential.AccessToken;
import com.azure.core.http.HttpClient;
import com.azure.core.http.rest.Response;
Expand Down Expand Up @@ -109,7 +109,7 @@ public void createUserAndToken(HttpClient httpClient) {
List<CommunicationTokenScope> scopes = Arrays.asList(CommunicationTokenScope.CHAT);

// Action & Assert
Mono<CommunicationUserIdentifierAndTokenResult> createUserAndToken = asyncClient.createUserAndToken(scopes);
Mono<CommunicationUserIdentifierAndToken> createUserAndToken = asyncClient.createUserAndToken(scopes);
StepVerifier.create(createUserAndToken)
.assertNext(result -> {
assertNotNull(result.getUserToken());
Expand All @@ -127,7 +127,7 @@ public void createUserAndTokenWithResponse(HttpClient httpClient) {
List<CommunicationTokenScope> scopes = Arrays.asList(CommunicationTokenScope.CHAT);

// Action & Assert
Mono<Response<CommunicationUserIdentifierAndTokenResult>> createUserAndToken =
Mono<Response<CommunicationUserIdentifierAndToken>> createUserAndToken =
asyncClient.createUserAndTokenWithResponse(scopes);
StepVerifier.create(createUserAndToken)
.assertNext(result -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import com.azure.communication.common.CommunicationUserIdentifier;
import com.azure.communication.identity.models.CommunicationTokenScope;
import com.azure.communication.identity.models.CommunicationUserIdentifierAndTokenResult;
import com.azure.communication.identity.models.CommunicationUserIdentifierAndToken;
import com.azure.core.credential.AccessToken;
import com.azure.core.http.HttpClient;
import com.azure.core.http.rest.Response;
Expand Down Expand Up @@ -93,7 +93,7 @@ public void createUserAndToken(HttpClient httpClient) {
List<CommunicationTokenScope> scopes = Arrays.asList(CommunicationTokenScope.CHAT);

// Action & Assert
CommunicationUserIdentifierAndTokenResult result = client.createUserAndToken(scopes);
CommunicationUserIdentifierAndToken result = client.createUserAndToken(scopes);
assertNotNull(result.getUser().getId());
assertNotNull(result.getUserToken());
assertFalse(result.getUser().getId().isEmpty());
Expand All @@ -107,9 +107,9 @@ public void createUserAndTokenWithResponse(HttpClient httpClient) {
client = setupClient(builder, "createUserAndTokenWithResponseSync");
List<CommunicationTokenScope> scopes = Arrays.asList(CommunicationTokenScope.CHAT);
// Action & Assert
Response<CommunicationUserIdentifierAndTokenResult> response =
Response<CommunicationUserIdentifierAndToken> response =
client.createUserAndTokenWithResponse(scopes, Context.NONE);
CommunicationUserIdentifierAndTokenResult result = response.getValue();
CommunicationUserIdentifierAndToken result = response.getValue();
assertEquals(201, response.getStatusCode());
assertNotNull(result.getUser().getId());
assertNotNull(result.getUserToken());
Expand Down

0 comments on commit e01f66b

Please sign in to comment.