apex library

Classes

ApexClient
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.
ApexClientBuilder
ApexRequest
This class represents the properties of rest request it allows to configure request's method, URL path by url, headers, requestConverterType which will convert the ApexRequest to RowRequest, responseConverterType which will convert the RowResponse to ApexResponse, and request encoding.
ApexResponse
This class represents the response, get returned by RestClient.execute method. It contains the original request, the rowResponse instance of RowResponse, which contains all the response info, like the response headers, code, body bytes, and more (see RowResponse). The response parameter is converted response, which get created by provided RestResponseConverter, as an example the JsonToMapResponseConverter get the RowResponse.bodyBytes and convert them to Map.
CommonEntry
PATH, QUERY
DefaultRestRequestExecutor
This class is a default implementation of the RestRequestExecutor, and uses Client from the "http" library (link:https://pub.dev/packages/http) for request execution. DefaultRestRequestExecutor supports regular Rest method requests and as well as multipart requests, see MultipartRestRequestBody for multipart request example.
JsonToMapResponseConverter
JsonToMapResponseConverter converts the received body bytes from RowResponse.bodyBytes to Map representation of JSON result.class, it uses the JsonCodec from dart.convert library to decode the json result.
MapToJsonRequestConverter
MapToJsonRequestConverter, which converts the body Map provided by ApexRequest.body to JSON String, it uses the JsonCodec from dart.convert library to encode the provided ApexRequest.body to JSON string.
Middleware<R>
The descendant of this class can be used as a request or response middleware. For the request middleware specify the R generic type as aRestRowRequest, for the response middleware specify the R generic type as a RestRowResponse After extending from the Middleware override the onNext async method and implement your custom logic, after call the next method
MultipartRestRequestBody
This class is used to make a multipart request. The instance of this class need to be passed to RestRequest.body. This class also provides progressListener which can be used to track the progress.
Path
PathEntryHandler
PATH, QUERY handlers
Query
QueryEntryHandler
RequestConverter
This class is a base request converter definition, derive from this class and implement the toRow method, which responsibility is to convert the ApexRequest to RowResponse. The library ships with pre defined request converters such as MapToJsonRequestConverter, which converts the body Map provided by ApexRequest.body to JSON String.
RequestLogger
The RequestLogger is a default logger implementation for the requests. Here is how the logged request's structure looks like.
ResponseConverter
This class is a base response converter definition, derive from this class and implement the fromRow method, which responsibility is to convert the RowResponse to ApexResponse. The library ships with pre defined response converters such as JsonToMapResponseConverter, which converts the received body bytes from RowResponse.bodyBytes to Map representation of JSON result.
ResponseLogger
The ResponseLogger is a default logger implementation for the responses. Here is how the logged response's structure looks like.
RestRequestExecutor
This abstract class is the main handler for http calls. Derive from this class and implement the execute method, which receives the RowRequest as an argument and returns RowResponse as a result. The actual http call should happen in the execute method's body. To create a RestClient instance, first and foremost you will need to provide an implementation of RestRequestExecutor to RestClient.builder as shown in the example below.
RestUrlBuilder
RestUrlEntry
RestUrlEntryHandler<E extends RestUrlEntry>
RowRequest
This class represents more row level of ApexRequest, which means it contains the converted Rest request's body and initial request. The rowBody get defined by the RestRequestConverter, for example the MapToJsonRequestConverter converts the Map body to JSON String, and get assigned to rowBody, then the converted JSON String file get used by RestRequestExecutor
RowResponse
This class represents the rest row response, which contains original request, the response code, response body bytes bodyBytes, headers, contentLength, and more meta info related to response. The instance of RowResponse get passed throughout to response middlewares and then to provided to RestResponseConverter from the ApexRequest's instance.
StringResponseConverter
This response converter converts the response RowResponse.bodyBytes to utf8 encoded string.
UrlBuilder
This class is a helper for URL path manipulations. It provides a way to keep the base url, then add a request path to it and apply some query and path params to it. Here is the example usage of it.

Enums

LogParts
This enum can be used to specify which part of the request need to logged by RequestLogger and ResponseLogger
Methods
Represents the rest methods

Constants

divider → const String

Functions

logDivider() → void
tabbedLog(String message) → void

Typedefs

HttpMultipartRequestProgressListener = void Function(int bytes, int totalBytes)
Used to provide multipart request's progress.