Package com.techcognita.javachatx.api
Class EchoApiConnector
java.lang.Object
com.techcognita.javachatx.api.BaseApiConnector
com.techcognita.javachatx.api.EchoApiConnector
- All Implemented Interfaces:
ApiConnector
A simple echo API connector for demonstration purposes.
This connector simply echoes back the request as the response.
-
Field Summary
Fields inherited from class com.techcognita.javachatx.api.BaseApiConnector
configuration, name, ready -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigure(com.google.gson.JsonObject configuration) Configure the API connector with necessary credentials and settings.com.google.gson.JsonObjectsendRequest(com.google.gson.JsonObject request) Send a request to the external API and get a response.Methods inherited from class com.techcognita.javachatx.api.BaseApiConnector
getName, isReady, toString
-
Constructor Details
-
EchoApiConnector
public EchoApiConnector()
-
-
Method Details
-
sendRequest
public com.google.gson.JsonObject sendRequest(com.google.gson.JsonObject request) throws ApiException Description copied from interface:ApiConnectorSend a request to the external API and get a response.- Parameters:
request- The request data as a JSON object- Returns:
- The API response as a JSON object
- Throws:
ApiException- If there's an error communicating with the API
-
configure
public void configure(com.google.gson.JsonObject configuration) Description copied from interface:ApiConnectorConfigure the API connector with necessary credentials and settings.- Specified by:
configurein interfaceApiConnector- Overrides:
configurein classBaseApiConnector- Parameters:
configuration- The configuration parameters as a JSON object
-