Class ClientAPI

java.lang.Object
za.co.wethinkcode.robots.api.ClientAPI

public class ClientAPI extends Object
The Client API class provides generic methods for interacting with the Robot Worlds API as a client
  • Constructor Details

    • ClientAPI

      public ClientAPI()
  • Method Details

    • createRequestRaw

      @Deprecated public static String createRequestRaw(String roboName, InputParser parser)
      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

      public static String extractMessage(String jsonResponse)
    • formatResponse

      public static String formatResponse(String jsonResponse)
    • rawToJson

      public static com.google.gson.JsonObject rawToJson(String rawInput)
      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

      public static String cleanRawInput(String s)
      Clean a raw string input and validate it to be sent over the network

      New line characters are typically replaced with ServerAPI.DELIMITER

      Parameters:
      s - the string being cleaned
      Returns:
      the clean version of the string