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

com.wallee.sdk.service.HumanUserService Maven / Gradle / Ivy

There is a newer version: 8.1.1
Show newest version
package com.wallee.sdk.service;

import com.wallee.sdk.ApiClient;
import com.wallee.sdk.ErrorCode;
import com.wallee.sdk.WalleeSdkException;
import com.wallee.sdk.URIBuilderUtil;

import com.wallee.sdk.model.ClientError;
import com.wallee.sdk.model.EntityExportRequest;
import com.wallee.sdk.model.EntityQuery;
import com.wallee.sdk.model.EntityQueryFilter;
import com.wallee.sdk.model.HumanUser;
import com.wallee.sdk.model.HumanUserCreate;
import com.wallee.sdk.model.HumanUserUpdate;
import com.wallee.sdk.model.ServerError;


import com.fasterxml.jackson.core.type.TypeReference;
import com.google.api.client.http.*;
import com.google.api.client.json.Json;

import org.apache.http.client.utils.URIBuilder;

import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.ArrayList;


public class HumanUserService {
    private ApiClient apiClient;

    public HumanUserService(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    public ApiClient getApiClient() {
        return apiClient;
    }

    public void setApiClient(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

  /**
    * Count
    
    * Counts the number of items in the database as restricted by the given filter.
    * 

200 - This status code indicates that a client request was successfully received, understood, and accepted. *

442 - This status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error. *

542 - This status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the client request. * @param filter The filter which restricts the entities which are used to calculate the count. * @return Long * @throws IOException if an error occurs while attempting to invoke the API * For more information visit this link. * @see Count Documentation **/ public Long count(EntityQueryFilter filter) throws IOException { HttpResponse response = countForHttpResponse(filter); String returnType = "Long"; if(returnType.equals("String")){ return (Long) (Object) response.parseAsString(); } TypeReference typeRef = new TypeReference() {}; if (isNoBodyResponse(response)) { throw new WalleeSdkException(ErrorCode.ENTITY_NOT_FOUND, "Entity was not found for: " + typeRef.getType().getTypeName()); } return (Long)apiClient.getObjectMapper().readValue(response.getContent(), typeRef); } /** * Count * Counts the number of items in the database as restricted by the given filter. *

200 - This status code indicates that a client request was successfully received, understood, and accepted. *

442 - This status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error. *

542 - This status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the client request. * @param params Map of query params. A collection will be interpreted as passing in multiple instances of the same query param. * @return Long * @throws IOException if an error occurs while attempting to invoke the API * For more information visit this link. * @see Count Documentation **/ public Long count(EntityQueryFilter filter, Map params) throws IOException { HttpResponse response = countForHttpResponse(filter, params); String returnType = "Long"; if(returnType.equals("String")){ return (Long) (Object) response.parseAsString(); } TypeReference typeRef = new TypeReference() {}; if (isNoBodyResponse(response)) { throw new WalleeSdkException(ErrorCode.ENTITY_NOT_FOUND, "Entity was not found for: " + typeRef.getType().getTypeName()); } return (Long)apiClient.getObjectMapper().readValue(response.getContent(), typeRef); } public HttpResponse countForHttpResponse(EntityQueryFilter filter) throws IOException { URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/count"); GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = apiClient.new JacksonJsonHttpContent(filter); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } public HttpResponse countForHttpResponse(java.io.InputStream filter, String mediaType) throws IOException { URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/count"); GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = filter == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, filter); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } public HttpResponse countForHttpResponse(EntityQueryFilter filter, Map params) throws IOException { URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/count"); // Copy the params argument if present, to allow passing in immutable maps Map allParams = params == null ? new HashMap() : new HashMap(params); for (Map.Entry entryMap: allParams.entrySet()) { String key = entryMap.getKey(); Object value = entryMap.getValue(); if (key != null && value != null) { uriBuilder = URIBuilderUtil.applyQueryParam(uriBuilder, key, value); } } GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = apiClient.new JacksonJsonHttpContent(filter); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } /** * Create * Creates the entity with the given properties. *

200 - This status code indicates that a client request was successfully received, understood, and accepted. *

442 - This status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error. *

542 - This status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the client request. * @param entity The human user object with the properties which should be created. * @return HumanUser * @throws IOException if an error occurs while attempting to invoke the API * For more information visit this link. * @see Create Documentation **/ public HumanUser create(HumanUserCreate entity) throws IOException { HttpResponse response = createForHttpResponse(entity); String returnType = "HumanUser"; if(returnType.equals("String")){ return (HumanUser) (Object) response.parseAsString(); } TypeReference typeRef = new TypeReference() {}; if (isNoBodyResponse(response)) { throw new WalleeSdkException(ErrorCode.ENTITY_NOT_FOUND, "Entity was not found for: " + typeRef.getType().getTypeName()); } return (HumanUser)apiClient.getObjectMapper().readValue(response.getContent(), typeRef); } /** * Create * Creates the entity with the given properties. *

200 - This status code indicates that a client request was successfully received, understood, and accepted. *

442 - This status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error. *

542 - This status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the client request. * @param entity The human user object with the properties which should be created. * @param params Map of query params. A collection will be interpreted as passing in multiple instances of the same query param. * @return HumanUser * @throws IOException if an error occurs while attempting to invoke the API * For more information visit this link. * @see Create Documentation **/ public HumanUser create(HumanUserCreate entity, Map params) throws IOException { HttpResponse response = createForHttpResponse(entity, params); String returnType = "HumanUser"; if(returnType.equals("String")){ return (HumanUser) (Object) response.parseAsString(); } TypeReference typeRef = new TypeReference() {}; if (isNoBodyResponse(response)) { throw new WalleeSdkException(ErrorCode.ENTITY_NOT_FOUND, "Entity was not found for: " + typeRef.getType().getTypeName()); } return (HumanUser)apiClient.getObjectMapper().readValue(response.getContent(), typeRef); } public HttpResponse createForHttpResponse(HumanUserCreate entity) throws IOException { // verify the required parameter 'entity' is set if (entity == null) { throw new IllegalArgumentException("Missing the required parameter 'entity' when calling create"); } URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/create"); GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = apiClient.new JacksonJsonHttpContent(entity); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } public HttpResponse createForHttpResponse(java.io.InputStream entity, String mediaType) throws IOException { // verify the required parameter 'entity' is set if (entity == null) { throw new IllegalArgumentException("Missing the required parameter 'entity' when calling create"); } URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/create"); GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = entity == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, entity); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } public HttpResponse createForHttpResponse(HumanUserCreate entity, Map params) throws IOException { // verify the required parameter 'entity' is set if (entity == null) { throw new IllegalArgumentException("Missing the required parameter 'entity' when calling create"); } URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/create"); // Copy the params argument if present, to allow passing in immutable maps Map allParams = params == null ? new HashMap() : new HashMap(params); for (Map.Entry entryMap: allParams.entrySet()) { String key = entryMap.getKey(); Object value = entryMap.getValue(); if (key != null && value != null) { uriBuilder = URIBuilderUtil.applyQueryParam(uriBuilder, key, value); } } GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = apiClient.new JacksonJsonHttpContent(entity); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } /** * Delete * Deletes the entity with the given id. *

409 - This status code indicates that there was a conflict with the current version of the data in the database and the provided data in the request. *

442 - This status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error. *

542 - This status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the client request. * @param id * @throws IOException if an error occurs while attempting to invoke the API * For more information visit this link. * @see Delete Documentation **/ public void delete(Long id) throws IOException { deleteForHttpResponse(id); } /** * Delete * Deletes the entity with the given id. *

409 - This status code indicates that there was a conflict with the current version of the data in the database and the provided data in the request. *

442 - This status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error. *

542 - This status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the client request. * @param id * @param params Map of query params. A collection will be interpreted as passing in multiple instances of the same query param. * @throws IOException if an error occurs while attempting to invoke the API * For more information visit this link. * @see Delete Documentation **/ public void delete(Long id, Map params) throws IOException { deleteForHttpResponse(id, params); } public HttpResponse deleteForHttpResponse(Long id) throws IOException { // verify the required parameter 'id' is set if (id == null) { throw new IllegalArgumentException("Missing the required parameter 'id' when calling delete"); } URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/delete"); GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = apiClient.new JacksonJsonHttpContent(id); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } public HttpResponse deleteForHttpResponse(java.io.InputStream id, String mediaType) throws IOException { // verify the required parameter 'id' is set if (id == null) { throw new IllegalArgumentException("Missing the required parameter 'id' when calling delete"); } URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/delete"); GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = id == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, id); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } public HttpResponse deleteForHttpResponse(Long id, Map params) throws IOException { // verify the required parameter 'id' is set if (id == null) { throw new IllegalArgumentException("Missing the required parameter 'id' when calling delete"); } URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/delete"); // Copy the params argument if present, to allow passing in immutable maps Map allParams = params == null ? new HashMap() : new HashMap(params); for (Map.Entry entryMap: allParams.entrySet()) { String key = entryMap.getKey(); Object value = entryMap.getValue(); if (key != null && value != null) { uriBuilder = URIBuilderUtil.applyQueryParam(uriBuilder, key, value); } } GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = apiClient.new JacksonJsonHttpContent(id); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } /** * Export * Exports the human users into a CSV file. The file will contain the properties defined in the request. *

200 - This status code indicates that a client request was successfully received, understood, and accepted. *

442 - This status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error. *

542 - This status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the client request. * @param request The request controls the entries which are exported. * @return byte[] * @throws IOException if an error occurs while attempting to invoke the API * For more information visit this link. * @see Export Documentation **/ public byte[] export(EntityExportRequest request) throws IOException { HttpResponse response = exportForHttpResponse(request); String returnType = "byte[]"; if(returnType.equals("String")){ return (byte[]) (Object) response.parseAsString(); } TypeReference typeRef = new TypeReference() {}; if (isNoBodyResponse(response)) { throw new WalleeSdkException(ErrorCode.ENTITY_NOT_FOUND, "Entity was not found for: " + typeRef.getType().getTypeName()); } return (byte[])apiClient.getObjectMapper().readValue(response.getContent(), typeRef); } /** * Export * Exports the human users into a CSV file. The file will contain the properties defined in the request. *

200 - This status code indicates that a client request was successfully received, understood, and accepted. *

442 - This status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error. *

542 - This status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the client request. * @param request The request controls the entries which are exported. * @param params Map of query params. A collection will be interpreted as passing in multiple instances of the same query param. * @return byte[] * @throws IOException if an error occurs while attempting to invoke the API * For more information visit this link. * @see Export Documentation **/ public byte[] export(EntityExportRequest request, Map params) throws IOException { HttpResponse response = exportForHttpResponse(request, params); String returnType = "byte[]"; if(returnType.equals("String")){ return (byte[]) (Object) response.parseAsString(); } TypeReference typeRef = new TypeReference() {}; if (isNoBodyResponse(response)) { throw new WalleeSdkException(ErrorCode.ENTITY_NOT_FOUND, "Entity was not found for: " + typeRef.getType().getTypeName()); } return (byte[])apiClient.getObjectMapper().readValue(response.getContent(), typeRef); } public HttpResponse exportForHttpResponse(EntityExportRequest request) throws IOException { // verify the required parameter 'request' is set if (request == null) { throw new IllegalArgumentException("Missing the required parameter 'request' when calling export"); } URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/export"); GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = apiClient.new JacksonJsonHttpContent(request); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } public HttpResponse exportForHttpResponse(java.io.InputStream request, String mediaType) throws IOException { // verify the required parameter 'request' is set if (request == null) { throw new IllegalArgumentException("Missing the required parameter 'request' when calling export"); } URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/export"); GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = request == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, request); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } public HttpResponse exportForHttpResponse(EntityExportRequest request, Map params) throws IOException { // verify the required parameter 'request' is set if (request == null) { throw new IllegalArgumentException("Missing the required parameter 'request' when calling export"); } URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/export"); // Copy the params argument if present, to allow passing in immutable maps Map allParams = params == null ? new HashMap() : new HashMap(params); for (Map.Entry entryMap: allParams.entrySet()) { String key = entryMap.getKey(); Object value = entryMap.getValue(); if (key != null && value != null) { uriBuilder = URIBuilderUtil.applyQueryParam(uriBuilder, key, value); } } GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = apiClient.new JacksonJsonHttpContent(request); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } /** * Read * Reads the entity with the given 'id' and returns it. *

200 - This status code indicates that a client request was successfully received, understood, and accepted. *

442 - This status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error. *

542 - This status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the client request. * @param id The id of the human user which should be returned. * @return HumanUser * @throws IOException if an error occurs while attempting to invoke the API * For more information visit this link. * @see Read Documentation **/ public HumanUser read(Long id) throws IOException { HttpResponse response = readForHttpResponse(id); String returnType = "HumanUser"; if(returnType.equals("String")){ return (HumanUser) (Object) response.parseAsString(); } TypeReference typeRef = new TypeReference() {}; if (isNoBodyResponse(response)) { throw new WalleeSdkException(ErrorCode.ENTITY_NOT_FOUND, "Entity was not found for: " + typeRef.getType().getTypeName()); } return (HumanUser)apiClient.getObjectMapper().readValue(response.getContent(), typeRef); } /** * Read * Reads the entity with the given 'id' and returns it. *

200 - This status code indicates that a client request was successfully received, understood, and accepted. *

442 - This status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error. *

542 - This status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the client request. * @param id The id of the human user which should be returned. * @param params Map of query params. A collection will be interpreted as passing in multiple instances of the same query param. * @return HumanUser * @throws IOException if an error occurs while attempting to invoke the API * For more information visit this link. * @see Read Documentation **/ public HumanUser read(Long id, Map params) throws IOException { HttpResponse response = readForHttpResponse(id, params); String returnType = "HumanUser"; if(returnType.equals("String")){ return (HumanUser) (Object) response.parseAsString(); } TypeReference typeRef = new TypeReference() {}; if (isNoBodyResponse(response)) { throw new WalleeSdkException(ErrorCode.ENTITY_NOT_FOUND, "Entity was not found for: " + typeRef.getType().getTypeName()); } return (HumanUser)apiClient.getObjectMapper().readValue(response.getContent(), typeRef); } public HttpResponse readForHttpResponse(Long id) throws IOException { // verify the required parameter 'id' is set if (id == null) { throw new IllegalArgumentException("Missing the required parameter 'id' when calling read"); } URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/read"); if (id != null) { String key = "id"; Object value = id; uriBuilder = URIBuilderUtil.applyQueryParam(uriBuilder, key, value); } GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = null; HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); httpRequest.getHeaders().setContentType("*/*"); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } public HttpResponse readForHttpResponse(Long id, Map params) throws IOException { // verify the required parameter 'id' is set if (id == null) { throw new IllegalArgumentException("Missing the required parameter 'id' when calling read"); } URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/read"); // Copy the params argument if present, to allow passing in immutable maps Map allParams = params == null ? new HashMap() : new HashMap(params); // Add the required query param 'id' to the map of query params allParams.put("id", id); for (Map.Entry entryMap: allParams.entrySet()) { String key = entryMap.getKey(); Object value = entryMap.getValue(); if (key != null && value != null) { uriBuilder = URIBuilderUtil.applyQueryParam(uriBuilder, key, value); } } GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = null; HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content); httpRequest.getHeaders().setContentType("*/*"); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } /** * Search * Searches for the entities as specified by the given query. *

200 - This status code indicates that a client request was successfully received, understood, and accepted. *

442 - This status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error. *

542 - This status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the client request. * @param query The query restricts the human users which are returned by the search. * @return List<HumanUser> * @throws IOException if an error occurs while attempting to invoke the API * For more information visit this link. * @see Search Documentation **/ public List search(EntityQuery query) throws IOException { HttpResponse response = searchForHttpResponse(query); String returnType = "List<HumanUser>"; if(returnType.equals("String")){ return (List) (Object) response.parseAsString(); } TypeReference typeRef = new TypeReference>() {}; if (isNoBodyResponse(response)) { throw new WalleeSdkException(ErrorCode.ENTITY_NOT_FOUND, "Entity was not found for: " + typeRef.getType().getTypeName()); } return (List)apiClient.getObjectMapper().readValue(response.getContent(), typeRef); } /** * Search * Searches for the entities as specified by the given query. *

200 - This status code indicates that a client request was successfully received, understood, and accepted. *

442 - This status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error. *

542 - This status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the client request. * @param query The query restricts the human users which are returned by the search. * @param params Map of query params. A collection will be interpreted as passing in multiple instances of the same query param. * @return List<HumanUser> * @throws IOException if an error occurs while attempting to invoke the API * For more information visit this link. * @see Search Documentation **/ public List search(EntityQuery query, Map params) throws IOException { HttpResponse response = searchForHttpResponse(query, params); String returnType = "List<HumanUser>"; if(returnType.equals("String")){ return (List) (Object) response.parseAsString(); } TypeReference typeRef = new TypeReference>() {}; if (isNoBodyResponse(response)) { throw new WalleeSdkException(ErrorCode.ENTITY_NOT_FOUND, "Entity was not found for: " + typeRef.getType().getTypeName()); } return (List)apiClient.getObjectMapper().readValue(response.getContent(), typeRef); } public HttpResponse searchForHttpResponse(EntityQuery query) throws IOException { // verify the required parameter 'query' is set if (query == null) { throw new IllegalArgumentException("Missing the required parameter 'query' when calling search"); } URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/search"); GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = apiClient.new JacksonJsonHttpContent(query); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } public HttpResponse searchForHttpResponse(java.io.InputStream query, String mediaType) throws IOException { // verify the required parameter 'query' is set if (query == null) { throw new IllegalArgumentException("Missing the required parameter 'query' when calling search"); } URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/search"); GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = query == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, query); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } public HttpResponse searchForHttpResponse(EntityQuery query, Map params) throws IOException { // verify the required parameter 'query' is set if (query == null) { throw new IllegalArgumentException("Missing the required parameter 'query' when calling search"); } URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/search"); // Copy the params argument if present, to allow passing in immutable maps Map allParams = params == null ? new HashMap() : new HashMap(params); for (Map.Entry entryMap: allParams.entrySet()) { String key = entryMap.getKey(); Object value = entryMap.getValue(); if (key != null && value != null) { uriBuilder = URIBuilderUtil.applyQueryParam(uriBuilder, key, value); } } GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = apiClient.new JacksonJsonHttpContent(query); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } /** * Update * This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity. *

200 - This status code indicates that a client request was successfully received, understood, and accepted. *

409 - This status code indicates that there was a conflict with the current version of the data in the database and the provided data in the request. *

442 - This status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error. *

542 - This status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the client request. * @param entity The object with all the properties which should be updated. The id and the version are required properties. * @return HumanUser * @throws IOException if an error occurs while attempting to invoke the API * For more information visit this link. * @see Update Documentation **/ public HumanUser update(HumanUserUpdate entity) throws IOException { HttpResponse response = updateForHttpResponse(entity); String returnType = "HumanUser"; if(returnType.equals("String")){ return (HumanUser) (Object) response.parseAsString(); } TypeReference typeRef = new TypeReference() {}; if (isNoBodyResponse(response)) { throw new WalleeSdkException(ErrorCode.ENTITY_NOT_FOUND, "Entity was not found for: " + typeRef.getType().getTypeName()); } return (HumanUser)apiClient.getObjectMapper().readValue(response.getContent(), typeRef); } /** * Update * This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity. *

200 - This status code indicates that a client request was successfully received, understood, and accepted. *

409 - This status code indicates that there was a conflict with the current version of the data in the database and the provided data in the request. *

442 - This status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error. *

542 - This status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the client request. * @param entity The object with all the properties which should be updated. The id and the version are required properties. * @param params Map of query params. A collection will be interpreted as passing in multiple instances of the same query param. * @return HumanUser * @throws IOException if an error occurs while attempting to invoke the API * For more information visit this link. * @see Update Documentation **/ public HumanUser update(HumanUserUpdate entity, Map params) throws IOException { HttpResponse response = updateForHttpResponse(entity, params); String returnType = "HumanUser"; if(returnType.equals("String")){ return (HumanUser) (Object) response.parseAsString(); } TypeReference typeRef = new TypeReference() {}; if (isNoBodyResponse(response)) { throw new WalleeSdkException(ErrorCode.ENTITY_NOT_FOUND, "Entity was not found for: " + typeRef.getType().getTypeName()); } return (HumanUser)apiClient.getObjectMapper().readValue(response.getContent(), typeRef); } public HttpResponse updateForHttpResponse(HumanUserUpdate entity) throws IOException { // verify the required parameter 'entity' is set if (entity == null) { throw new IllegalArgumentException("Missing the required parameter 'entity' when calling update"); } URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/update"); GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = apiClient.new JacksonJsonHttpContent(entity); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } public HttpResponse updateForHttpResponse(java.io.InputStream entity, String mediaType) throws IOException { // verify the required parameter 'entity' is set if (entity == null) { throw new IllegalArgumentException("Missing the required parameter 'entity' when calling update"); } URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/update"); GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = entity == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, entity); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } public HttpResponse updateForHttpResponse(HumanUserUpdate entity, Map params) throws IOException { // verify the required parameter 'entity' is set if (entity == null) { throw new IllegalArgumentException("Missing the required parameter 'entity' when calling update"); } URIBuilder uriBuilder = URIBuilderUtil.create(apiClient.getBasePath() + "/human-user/update"); // Copy the params argument if present, to allow passing in immutable maps Map allParams = params == null ? new HashMap() : new HashMap(params); for (Map.Entry entryMap: allParams.entrySet()) { String key = entryMap.getKey(); Object value = entryMap.getValue(); if (key != null && value != null) { uriBuilder = URIBuilderUtil.applyQueryParam(uriBuilder, key, value); } } GenericUrl genericUrl = new GenericUrl(URIBuilderUtil.build(uriBuilder)); HttpContent content = apiClient.new JacksonJsonHttpContent(entity); HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); int readTimeOut = apiClient.getReadTimeOut() * 1000; httpRequest.setReadTimeout(readTimeOut); return httpRequest.execute(); } private boolean isNoBodyResponse(HttpResponse response) throws IOException { java.io.InputStream content = response.getContent(); return content.available() == 0; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy