symphonyoss / symphony-java-client

Java client library for Symphony
Apache License 2.0
34 stars 37 forks source link

Get user last login time #127

Closed rboughani closed 6 years ago

rboughani commented 6 years ago
SymUser contact = symphonyClient.getUsersClient().getUserFromId(userId);
Date lastLogin = contact.getLastLoginDate();

Got evry time null why ? There is a problem with mapping SymUser with sympony api ?

rboughani commented 6 years ago

When getting response, your api dont add lastLogin value to SymUser bean !

 /**
 * This method converts a {@link UserV2} to a {@link SymUser}.
 * @param user the {@link UserV2} to convert from.
 * @return symUser the {@link SymUser} generated from the {@link UserV2}.
 */
public static SymUser toSymUser(UserV2 user) {
    if(user==null)
        return null;

    SymUser symUser = new SymUser();

    symUser.setCompany(user.getCompany());
    symUser.setDisplayName(user.getDisplayName());
    symUser.setEmailAddress(user.getEmailAddress());
    symUser.setFirstName(user.getFirstName());
    symUser.setLastName(user.getLastName());
    symUser.setId(user.getId());
    symUser.setLocation(user.getLocation());
    symUser.setTitle(user.getTitle());
    symUser.setUsername(user.getUsername());
    symUser.setDepartment(user.getDepartment());

    List<SymAvatar> avatars = new ArrayList<>();
    for (Avatar avatar : user.getAvatars()) {
        SymAvatar symAvatar = new SymAvatar();
        symAvatar.setSize(avatar.getSize());
        symAvatar.setUrl(avatar.getUrl());
        avatars.add(symAvatar);
    }
    symUser.setAvatars(avatars);

    return symUser;

}
rboughani commented 6 years ago

I have created this rest call, and it work, if you want to add it to your api

 /**
 * Retrieve a streams info across stream id
 * 
 * @param sessionToken Session authentication token. (required)
 * @param skip         Number of items to skip. Default is 0. (optional)
 * @param limit        Maximum number of items to return. Default is 50. This
 *                     value cannot exceed 100. (optional)
 * @param filter       Stream filtering criteria. (optional)
 * @return AdminStreamList
 * @throws ApiException if fails to make API call
 */
public V2StreamInfo v2StreamInfo(String idStream, String sessionToken) throws ApiException {

    Object localVarPostBody = null;

    // verify the required parameter 'sessionToken' is set
    if (sessionToken == null) {
        throw new ApiException(400,
                "Missing the required parameter 'sessionToken' when calling v1AdminStreamsListPost");
    }

    // create path and map variables
    String localVarPath = "/v2/streams/{id}/info".replaceAll("\\{" + "id" + "\\}",
            apiClient.escapeString(idStream.toString()));

    // query params
    List<Pair> localVarQueryParams = new ArrayList<Pair>();
    Map<String, String> localVarHeaderParams = new HashMap<String, String>();
    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    if (sessionToken != null)
        localVarHeaderParams.put("sessionToken", apiClient.parameterToString(sessionToken));

    final String[] localVarAccepts = { "application/json" };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);

    final String[] localVarContentTypes = {

    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);

    String[] localVarAuthNames = new String[] {};

    GenericType<V2StreamInfo> localVarReturnType = new GenericType<V2StreamInfo>() {
    };
    return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody,
            localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames,
            localVarReturnType);
}
rboughani commented 6 years ago

in V2StreamInfo i got two attribute id, and lastMessageDate, public class V2StreamInfo {

     private String id;

     private String lastMessageDate;

         // ....