kinfolk 0.0.3 kinfolk: ^0.0.3 copied to clipboard
A new Flutter package for integration with CUBA Platform based backend.
core #
A new Flutter package for integration with CUBA Platform based backend.
Features #
- Authorization via the Rest Api using your username and password
- Storing and reusing Access Token
- Compliance with the CUBA documentation for the REST API. (at the moment partial)
Installation #
in your pubspec.yaml add dependency
dependencies:
flutter:
sdk: flutter
core:
git:
url: git://github.com/yeras-is/core
then run. packages get
Example #
/// initialize service
Kinfolk kinfolk = Kinfolk();
/// setting server url and security keys (identifier,secter)
kinfolk.initializeBaseVariables("http://localhost:8080/test", "client", "secret");
/// getting client (service with Access Token) in first time with login,password
oauth2.Client client = await kinfolk.getToken("admin", "admin");
/// url to service
/// test_SomeService - service name
/// getToDoList - method name
/// Types - enum
String url =
Kinfolk.createRestUrl("test_SomeService", "getToDoList", Types.services);
// getting response from server. GET method
var response = await client.get(url, headers: Kinfolk.appJsonHeader);
/// printing body of response
print("${response.body}");
/// url to service
String url2 =
Kinfolk.createRestUrl("test_SomeService", "setToDoList", Types.services);
/// request body
String body = """
{
"monday":"work",
"sunday":"relax"
}
""";
/// getting client from saved Access Token
oauth2.Client client2 = await Kinfolk.getClient();
// getting response from server. POST method
var response2 =
await client2.post(url, body: body, headers: Kinfolk.appJsonHeader);
/// printing body of response
print("1 ${response2.body}");
Author #
Yerassyl Maikhanov - Enterprise Applications Developer. My Linkedin