content: /*
   * Management API
   *
   * The version of the OpenAPI document: 3
   *
   *
   * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
   * https://openapi-generator.tech
   * Do not edit the class manually.
   */
  
  package com.adyen.service.management;
  
  import com.adyen.Client;
  import com.adyen.Service;
  import com.adyen.constants.ApiConstants;
  import com.adyen.model.RequestOptions;
  import com.adyen.model.management.CreateMerchantUserRequest;
  import com.adyen.model.management.CreateUserResponse;
  import com.adyen.model.management.ListMerchantUsersResponse;
  import com.adyen.model.management.UpdateMerchantUserRequest;
  import com.adyen.model.management.User;
  import com.adyen.service.exception.ApiException;
  import com.adyen.service.resource.Resource;
  import java.io.IOException;
  import java.util.HashMap;
  import java.util.Map;
  
  public class UsersMerchantLevelApi extends Service {
  
    public static final String API_VERSION = "3";
  
    protected String baseURL;
  
    /**
     * Users - merchant level constructor in {@link com.adyen.service.management package}.
     *
     * @param client {@link Client } (required)
     */
    public UsersMerchantLevelApi(Client client) {
      super(client);
      this.baseURL = createBaseURL("https://management-test.adyen.com/v3");
    }
  
    /**
     * Users - merchant level constructor in {@link com.adyen.service.management package}. Please use
     * this constructor only if you would like to pass along your own url for routing or testing
     * purposes. The latest API version is defined in this class as a constant.
     *
     * @param client {@link Client } (required)
     * @param baseURL {@link String } (required)
     */
    public UsersMerchantLevelApi(Client client, String baseURL) {
      super(client);
      this.baseURL = baseURL;
    }
  
    /**
     * Create a new user
     *
     * @param merchantId {@link String } Unique identifier of the merchant. (required)
     * @param createMerchantUserRequest {@link CreateMerchantUserRequest } (required)
     * @return {@link CreateUserResponse }
     * @throws ApiException if fails to make API call
     */
    public CreateUserResponse createNewUser(
        String merchantId, CreateMerchantUserRequest createMerchantUserRequest)
        throws ApiException, IOException {
      return createNewUser(merchantId, createMerchantUserRequest, null);
    }
  
    /**
     * Create a new user
     *
     * @param merchantId {@link String } Unique identifier of the merchant. (required)
     * @param createMerchantUserRequest {@link CreateMerchantUserRequest } (required)
     * @param requestOptions {@link RequestOptions } Object to store additional data such as
     *     idempotency-keys (optional)
     * @return {@link CreateUserResponse }
     * @throws ApiException if fails to make API call
     */
    public CreateUserResponse createNewUser(
        String merchantId,
        CreateMerchantUserRequest createMerchantUserRequest,
        RequestOptions requestOptions)
        throws ApiException, IOException {
      // Add path params
      Map<String, String> pathParams = new HashMap<>();
      if (merchantId == null) {
        throw new IllegalArgumentException("Please provide the merchantId path parameter");
      }
      pathParams.put("merchantId", merchantId);
  
      String requestBody = createMerchantUserRequest.toJson();
      Resource resource = new Resource(this, this.baseURL + "/merchants/{merchantId}/users", null);
      String jsonResult =
          resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.POST, pathParams);
      return CreateUserResponse.fromJson(jsonResult);
    }
  
    /**
     * Get user details
     *
     * @param merchantId {@link String } Unique identifier of the merchant. (required)
     * @param userId {@link String } Unique identifier of the user. (required)
     * @return {@link User }
     * @throws ApiException if fails to make API call
     */
    public User getUserDetails(String merchantId, String userId) throws ApiException, IOException {
      return getUserDetails(merchantId, userId, null);
    }
  
    /**
     * Get user details
     *
     * @param merchantId {@link String } Unique identifier of the merchant. (required)
     * @param userId {@link String } Unique identifier of the user. (required)
     * @param requestOptions {@link RequestOptions } Object to store additional data such as
     *     idempotency-keys (optional)
     * @return {@link User }
     * @throws ApiException if fails to make API call
     */
    public User getUserDetails(String merchantId, String userId, RequestOptions requestOptions)
        throws ApiException, IOException {
      // Add path params
      Map<String, String> pathParams = new HashMap<>();
      if (merchantId == null) {
        throw new IllegalArgumentException("Please provide the merchantId path parameter");
      }
      pathParams.put("merchantId", merchantId);
      if (userId == null) {
        throw new IllegalArgumentException("Please provide the userId path parameter");
      }
      pathParams.put("userId", userId);
  
      String requestBody = null;
      Resource resource =
          new Resource(this, this.baseURL + "/merchants/{merchantId}/users/{userId}", null);
      String jsonResult =
          resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.GET, pathParams);
      return User.fromJson(jsonResult);
    }
  
    /**
     * Get a list of users
     *
     * @param merchantId {@link String } Unique identifier of the merchant. (required)
     * @return {@link ListMerchantUsersResponse }
     * @throws ApiException if fails to make API call
     */
    public ListMerchantUsersResponse listUsers(String merchantId) throws ApiException, IOException {
      return listUsers(merchantId, null, null, null, null);
    }
  
    /**
     * Get a list of users
     *
     * @param merchantId {@link String } Unique identifier of the merchant. (required)
     * @param pageNumber {@link Integer } Query: The number of the page to fetch. (optional)
     * @param pageSize {@link Integer } Query: The number of items to have on a page. Maximum value is
     *     **100**. The default is **10** items on a page. (optional)
     * @param username {@link String } Query: The partial or complete username to select all users
     *     that match. (optional)
     * @param requestOptions {@link RequestOptions } Object to store additional data such as
     *     idempotency-keys (optional)
     * @return {@link ListMerchantUsersResponse }
     * @throws ApiException if fails to make API call
     */
    public ListMerchantUsersResponse listUsers(
        String merchantId,
        Integer pageNumber,
        Integer pageSize,
        String username,
        RequestOptions requestOptions)
        throws ApiException, IOException {
      // Add path params
      Map<String, String> pathParams = new HashMap<>();
      if (merchantId == null) {
        throw new IllegalArgumentException("Please provide the merchantId path parameter");
      }
      pathParams.put("merchantId", merchantId);
  
      // Add query params
      Map<String, String> queryParams = new HashMap<>();
      if (pageNumber != null) {
        queryParams.put("pageNumber", pageNumber.toString());
      }
      if (pageSize != null) {
        queryParams.put("pageSize", pageSize.toString());
      }
      if (username != null) {
        queryParams.put("username", username);
      }
  
      String requestBody = null;
      Resource resource = new Resource(this, this.baseURL + "/merchants/{merchantId}/users", null);
      String jsonResult =
          resource.request(
              requestBody, requestOptions, ApiConstants.HttpMethod.GET, pathParams, queryParams);
      return ListMerchantUsersResponse.fromJson(jsonResult);
    }
  
    /**
     * Update a user
     *
     * @param merchantId {@link String } Unique identifier of the merchant. (required)
     * @param userId {@link String } Unique identifier of the user. (required)
     * @param updateMerchantUserRequest {@link UpdateMerchantUserRequest } (required)
     * @return {@link User }
     * @throws ApiException if fails to make API call
     */
    public User updateUser(
        String merchantId, String userId, UpdateMerchantUserRequest updateMerchantUserRequest)
        throws ApiException, IOException {
      return updateUser(merchantId, userId, updateMerchantUserRequest, null);
    }
  
    /**
     * Update a user
     *
     * @param merchantId {@link String } Unique identifier of the merchant. (required)
     * @param userId {@link String } Unique identifier of the user. (required)
     * @param updateMerchantUserRequest {@link UpdateMerchantUserRequest } (required)
     * @param requestOptions {@link RequestOptions } Object to store additional data such as
     *     idempotency-keys (optional)
     * @return {@link User }
     * @throws ApiException if fails to make API call
     */
    public User updateUser(
        String merchantId,
        String userId,
        UpdateMerchantUserRequest updateMerchantUserRequest,
        RequestOptions requestOptions)
        throws ApiException, IOException {
      // Add path params
      Map<String, String> pathParams = new HashMap<>();
      if (merchantId == null) {
        throw new IllegalArgumentException("Please provide the merchantId path parameter");
      }
      pathParams.put("merchantId", merchantId);
      if (userId == null) {
        throw new IllegalArgumentException("Please provide the userId path parameter");
      }
      pathParams.put("userId", userId);
  
      String requestBody = updateMerchantUserRequest.toJson();
      Resource resource =
          new Resource(this, this.baseURL + "/merchants/{merchantId}/users/{userId}", null);
      String jsonResult =
          resource.request(requestBody, requestOptions, ApiConstants.HttpMethod.PATCH, pathParams);
      return User.fromJson(jsonResult);
    }
  }
  