All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.camunda.identity.sdk.impl.rest.request.UsersRequest Maven / Gradle / Ivy

There is a newer version: 8.5.9
Show newest version
/*
 * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
 * one or more contributor license agreements. Licensed under a proprietary license. See the
 * License.txt file for more information. You may not use this file except in compliance with the
 * proprietary license.
 */

package io.camunda.identity.sdk.impl.rest.request;

import static io.camunda.identity.sdk.impl.UsersImpl.USERS_PATH;
import static io.camunda.identity.sdk.utility.UrlUtility.combinePaths;

import com.fasterxml.jackson.core.type.TypeReference;
import io.camunda.identity.sdk.users.dto.User;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class UsersRequest extends Request> {
  public UsersRequest(
      final String baseUrl,
      final String authentication,
      final List userIds
  ) {
    this(baseUrl, authentication, null, null, null, userIds);
  }

  public UsersRequest(
      final String baseUrl,
      final String authentication,
      final String search,
      final Integer page,
      final Integer resultSize
  ) {
    this(baseUrl, authentication, search, page, resultSize, null);
  }

  private UsersRequest(
      final String baseUrl,
      final String authentication,
      final String search,
      final Integer page,
      final Integer resultSize,
      final List userIds
  ) {
    super(combinePaths(baseUrl, USERS_PATH), new TypeReference<>() {
    });

    final Map params = buildParamMap(search, page, resultSize, userIds);

    this.setAuthentication(authentication);
    this.setParams(params);
  }

  private Map buildParamMap(
      final String search,
      final Integer page,
      final Integer resultSize,
      final List userIds
  ) {
    final Map params = new HashMap<>();

    if (search != null) {
      params.put("search", search);
    }

    if (page != null) {
      params.put("page", String.valueOf(page));
    }

    if (resultSize != null) {
      params.put("resultSize", String.valueOf(resultSize));
    }

    if (userIds != null) {
      params.put("userIds", String.join(",", userIds));
    }

    return params;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy