ApiHttp<I, O, Q extends BaseRequest, S extends BaseResponse> class

A single API.

For example

Api api = ApiHttp<DataSet,DataSet,Request,Response>(
  name: "get user",
  serverName: "local server",
  method:HttpMethod.POST
  path:"/users",
  inputCreator: (context){
    DataSet ds = DataSet("Condition");
    ds.setHeaderSchema(
      RecordSchema([FieldSchema<String>("id")])
    );
    return ds;
  },
  outputCreator: (context){
    DataSet ds = DataSet("User");
    ds.setHeaderSchema(
      RecordSchema(
        [
          FieldSchema<String>("name"),
          FieldSchema<int>("age"),
          FieldSchema<String>("tel")
        ]
      )
    );
    return ds;
  }
);

RequestContext context = RequestContext();
DataSet requestDs = api.getInput(context);
requestDs.getHeader()["id"] = "0000001";

DataSet responseDs = await api.request(requestDs, context);

Record userRecord = responseDs.getHeader();
Inheritance
Annotations

Constructors

ApiHttp({required String name, required String serverName, required HttpMethod method, required String path, ApiInOutCreator<I>? inputCreator, ApiInOutCreator<O>? outputCreator, UriBuilder<I>? uriBuilder, ApiHttpRequestBuilder<I, Q>? requestBuilder, ApiHttpResponseParser<O, S>? responseParser})
Construct API.

Properties

hashCode int
The hash code for this object.
no setterinherited
name → dynamic
A logical name of API.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

getInput(RequestContext context) → I?
Get the input DTO that is the source of the request to the server.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
request(I? input, RequestContext context) Future<O?>
Request to the server.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited