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

com.salesforce.einsteinbot.sdk.api.MessagesApi Maven / Gradle / Ivy

Go to download

Java SDK to interact with Einstein Bots Runtime. This SDK is a wrapper around the Einstein Bots Runtime API that provides a few added features out of the box like Auth support, Session management

There is a newer version: 2.3.0
Show newest version
package com.salesforce.einsteinbot.sdk.api;

import com.salesforce.einsteinbot.sdk.handler.ApiClient;

import com.salesforce.einsteinbot.sdk.model.Error;
import com.salesforce.einsteinbot.sdk.model.RequestEnvelope;
import com.salesforce.einsteinbot.sdk.model.ResponseEnvelope;

import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.web.reactive.function.client.WebClient.ResponseSpec;
import org.springframework.web.reactive.function.client.WebClientResponseException;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import reactor.core.publisher.Mono;
import reactor.core.publisher.Flux;

@javax.annotation.Generated(value = "com.salesforce.einsteinbot.openapi.codegen.EinsteinBotCodeGenerator", date = "2022-03-24T00:55:11.933462Z[Etc/UTC]")
public class MessagesApi {
    private ApiClient apiClient;

    public MessagesApi() {
        this(new ApiClient());
    }

    @Autowired
    public MessagesApi(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    public ApiClient getApiClient() {
        return apiClient;
    }

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

    /**
     * Send messages to the bot
     * Send messages to the bot
     * 

200 - OK *

400 - Bad Request *

401 - Access bearer token is missing or invalid *

403 - User Forbidden from accessing the resource *

404 - Resource not found *

410 - Resource not available at the time of the request *

422 - Any (potentially retryable) exception that occurred during the request execution *

423 - Server is busy and cannot process the request at this time *

429 - Too many requests for the server to handle *

503 - Service is unavailable possibly because Apex/Flow calls timed out *

0 - Something went wrong * @param xOrgId Org id for the request * @param xRequestID Client supplied unique id to identify request for distributed tracing * @param requestEnvelope Messages request payload * @param xRuntimeCRC X-Runtime-CRC value from previous response * @return ResponseEnvelope * @throws WebClientResponseException if an error occurs while attempting to invoke the API */ private ResponseSpec sendMessagesRequestCreation(String xOrgId, String xRequestID, RequestEnvelope requestEnvelope, String xRuntimeCRC) throws WebClientResponseException { Object postBody = requestEnvelope; // verify the required parameter 'xOrgId' is set if (xOrgId == null) { throw new WebClientResponseException("Missing the required parameter 'xOrgId' when calling sendMessages", HttpStatus.BAD_REQUEST.value(), HttpStatus.BAD_REQUEST.getReasonPhrase(), null, null, null); } // verify the required parameter 'xRequestID' is set if (xRequestID == null) { throw new WebClientResponseException("Missing the required parameter 'xRequestID' when calling sendMessages", HttpStatus.BAD_REQUEST.value(), HttpStatus.BAD_REQUEST.getReasonPhrase(), null, null, null); } // verify the required parameter 'requestEnvelope' is set if (requestEnvelope == null) { throw new WebClientResponseException("Missing the required parameter 'requestEnvelope' when calling sendMessages", HttpStatus.BAD_REQUEST.value(), HttpStatus.BAD_REQUEST.getReasonPhrase(), null, null, null); } // create path and map variables final Map pathParams = new HashMap(); final MultiValueMap queryParams = new LinkedMultiValueMap(); final HttpHeaders headerParams = new HttpHeaders(); final MultiValueMap cookieParams = new LinkedMultiValueMap(); final MultiValueMap formParams = new LinkedMultiValueMap(); if (xOrgId != null) headerParams.add("X-Org-Id", apiClient.parameterToString(xOrgId)); if (xRequestID != null) headerParams.add("X-Request-ID", apiClient.parameterToString(xRequestID)); if (xRuntimeCRC != null) headerParams.add("X-Runtime-CRC", apiClient.parameterToString(xRuntimeCRC)); final String[] localVarAccepts = { "application/json" }; final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { "application/json" }; final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { "chatbotAuth", "chatbotAuth", "jwtBearer" }; ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; return apiClient.invokeAPI("/v4.0.0/messages", HttpMethod.POST, pathParams, queryParams, postBody, headerParams, cookieParams, formParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); } /** * Send messages to the bot * Send messages to the bot *

200 - OK *

400 - Bad Request *

401 - Access bearer token is missing or invalid *

403 - User Forbidden from accessing the resource *

404 - Resource not found *

410 - Resource not available at the time of the request *

422 - Any (potentially retryable) exception that occurred during the request execution *

423 - Server is busy and cannot process the request at this time *

429 - Too many requests for the server to handle *

503 - Service is unavailable possibly because Apex/Flow calls timed out *

0 - Something went wrong * @param xOrgId Org id for the request * @param xRequestID Client supplied unique id to identify request for distributed tracing * @param requestEnvelope Messages request payload * @param xRuntimeCRC X-Runtime-CRC value from previous response * @return ResponseEnvelope * @throws WebClientResponseException if an error occurs while attempting to invoke the API */ public Mono sendMessages(String xOrgId, String xRequestID, RequestEnvelope requestEnvelope, String xRuntimeCRC) throws WebClientResponseException { ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; return sendMessagesRequestCreation(xOrgId, xRequestID, requestEnvelope, xRuntimeCRC).bodyToMono(localVarReturnType); } public Mono> sendMessagesWithHttpInfo(String xOrgId, String xRequestID, RequestEnvelope requestEnvelope, String xRuntimeCRC) throws WebClientResponseException { ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; return sendMessagesRequestCreation(xOrgId, xRequestID, requestEnvelope, xRuntimeCRC).toEntity(localVarReturnType); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy