Package za.co.wethinkcode.robots.api
Class ClientAPI
java.lang.Object
za.co.wethinkcode.robots.api.ClientAPI
The Client API class provides generic methods for interacting with the Robot Worlds API as a client
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringClean a raw string input and validate it to be sent over the networkstatic com.google.gson.JsonObjectcreateRequest(InputParser parser, Memory memory) Create a formatted api request as a clientstatic StringcreateRequestRaw(String roboName, InputParser parser) Deprecated.static StringextractMessage(String jsonResponse) static StringformatResponse(String jsonResponse) static com.google.gson.JsonObjectTake in the raw response from a server and format it as a JSON object
-
Constructor Details
-
ClientAPI
public ClientAPI()
-
-
Method Details
-
createRequestRaw
Deprecated.builds a JSON request for the server. // format : { "robot": "name", "command": "cmd", "arguments": ["arg1"] } -
createRequest
public static com.google.gson.JsonObject createRequest(InputParser parser, Memory memory) throws ClientMemoryException Create a formatted api request as a client- Throws:
ClientMemoryException
-
extractMessage
-
formatResponse
-
rawToJson
Take in the raw response from a server and format it as a JSON object- Parameters:
rawInput- the raw input received from the server- Returns:
- a constructed JSON output
-
cleanRawInput
Clean a raw string input and validate it to be sent over the networkNew line characters are typically replaced with
ServerAPI.DELIMITER- Parameters:
s- the string being cleaned- Returns:
- the clean version of the string
-