Package com.github.copilot.sdk.json
Class JsonRpcResponse
java.lang.Object
com.github.copilot.sdk.json.JsonRpcResponse
JSON-RPC 2.0 response structure.
This is an internal class representing the wire format of a JSON-RPC response. It follows the JSON-RPC 2.0 specification. A response contains either a result or an error, but not both.
- Since:
- 1.0.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetError()Gets the error if the RPC call failed.getId()Gets the response ID.Gets the JSON-RPC version.Gets the result of the RPC call.voidsetError(JsonRpcError error) Sets the error for a failed RPC call.voidSets the response ID.voidsetJsonrpc(String jsonrpc) Sets the JSON-RPC version.voidSets the result of the RPC call.
-
Constructor Details
-
JsonRpcResponse
public JsonRpcResponse()
-
-
Method Details
-
getJsonrpc
Gets the JSON-RPC version.- Returns:
- the version string (should be "2.0")
-
setJsonrpc
Sets the JSON-RPC version.- Parameters:
jsonrpc- the version string
-
getId
Gets the response ID.- Returns:
- the request identifier this response corresponds to
-
setId
Sets the response ID.- Parameters:
id- the response identifier
-
getResult
Gets the result of the RPC call.- Returns:
- the result object, or
nullif there was an error
-
setResult
Sets the result of the RPC call.- Parameters:
result- the result object
-
getError
Gets the error if the RPC call failed.- Returns:
- the error object, or
nullif successful
-
setError
Sets the error for a failed RPC call.- Parameters:
error- the error object
-