Web service requests

The Android Apps Panel SDK provides easy way to communicate with web services.

Sample

Future<List<Model>?> getListOfItems() async {
  final response = await AppsPanel.request(
    action: "/path",
    method: AppsPanelMethod.get,
    sendUserToken: true,
  );
  if (response is RequestSuccessArray) {
    return List.castFrom(req.data).map((e) => Model.fromJson(e)).toList();
  } else if (response is RequestError) {
    log("ERROR : ${response.message}, ${response.statusCode}, ${response.data}");
    return null;
  } else {
    log("ERROR : ${response.runtimeType}");
  }
}

Possible returned types :
RequestSuccessArray : When the api request returns an object list as result RequestSuccessObject : When the api request returns an object as result RequestSuccessEmpty : When the api request return san empty body result RequestError: When the api request returns an error


See https://appspanel.readme.io/docs/user-token-management for token management

Optional JWT (1.6.0+)

A JWT is included by default in the request, you can configure it to not send the JWT. This is less secure and should not be used unless you're sure of what you're doing

AppsPanel.request(
  action: "/path",
  method; AppsPanelMethod.get,
  sendJWTAuthorization: false,
);

Extra Configs (1.6.0+)

In some rare cases for some specific projects you might need to call APIs from another project, this is now possible

AppsPanel.request(
  action: "/path",
  method; AppsPanelMethod.get,
  sendJWTAuthorization: false,
);

Android details

https://appspanel.readme.io/docs/web-services

iOS details

https://appspanel.readme.io/docs/ios-webservices-v5