iws_http_model 0.2.0 copy "iws_http_model: ^0.2.0" to clipboard
iws_http_model: ^0.2.0 copied to clipboard

unlistedoutdated

Library for HTTP requests with the common operations CRUD, pagination and error handling.

Library for HTTP requests with the common CRUD operations, pagination and error handling.

Features #

  • Authentication with JWT.
  • HTTP error handling.
  • Helper for building REST routes.
  • Ready-to-use CRUD methods:
    • Get by ID (GET).
    • Paginated query (GET).
    • Paginated search (POST).
    • Add (POST).
    • Update (PUT).
    • Delete (DELETE).

Getting started #

Initialize the IwsHttp library:

  IwsHttp.setup(
      authority: 'mydomain.com',
      apiKey: 'my_secret_api_key',
      basePath: 'api/',
      secureConnection: true,
      bearerToken: 'my_secret_token');

Usage #

instantiate IwsHttpModel

final myModelProvider = IwsHttpModel<MyModelClass>(
    path: 'myModels',
    iwsHttp: IwsHttp(),
    fromJson: MyModelClass.fromJson,
    toJson: MyModelClass.toJson);

Make HTTP requests

int id = 120;
MyModelClass myModel = await myModelProvider.get(id);

await myModelProvider.update(myModel, id);

JSON structure for pagination #

Paging queries expect a specific response format:

{
    "data": [],
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 2,
        "per_page": 10,
        "to": 10,
        "total": 15
    } 
}

and the parameters for paging are sent in the request route as follows:

https://exmapledomain.com?page=1&orderBy=name&orderType=asc
0
likes
0
points
31
downloads

Publisher

unverified uploader

Weekly Downloads

Library for HTTP requests with the common operations CRUD, pagination and error handling.

Homepage

License

unknown (license)

Dependencies

flutter, iws_http

More

Packages that depend on iws_http_model