ApexClient class
This is the main class which wires converters, middlewares and request executors together. To create an instance of ApexClient use the ApexClient.builder method and provide a RestRequestExecutor's implementation, the "rest" library ships with a default implementation DefaultRestRequestExecutor, you can use it or create your own implementation of RestRequestExecutor. After calling the ApexClient.builder provide request/response converters and middlewares.
Here is an example on how to build a ApexClient final RestClient client = RestClient.builder(DefaultRestRequestExecutor(Client())) .addRequestConverter(MapToJsonRequestConverter()) .addResponseConverter(JsonToMapResponseConverter()) .addResponseMiddleware(ResponseLogger()) .addRequestMiddleware(RequestLogger()) .build();
Library ships with the most required request/response converters such as
JSON to Map [JsonToMapResponseConverter] and Map to JSON [MapToJsonRequestConverter] converters
for more check the [rest_converter].
There are default logging middlewares for requests and responses which ships with
the library, see [RequestLogger] and [ResponseLogger].
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
execute(
ApexRequest restRequest) → Future< ApexResponse> - Use this method to execute requests, Receives a single argument of ApexRequest, which represents the requests parameters, and returns ApexResponse as a result. When you are calling the ApexClient.execute method the ordering of the request pipeline is the following,
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
builder(
RestRequestExecutor requestExecutor) → ApexClientBuilder - This method is the entry point to start create a ApexClient, RestRequestExecutor should be provided as a parameter, which mainly executes the requests, DefaultRestRequestExecutor can be used for that which handles most of the cases for regular and multipart requests. Returns ApexClientBuilder which provide a methods to add middlewares and request/response converters to ApexClient instance.