mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-01-13 03:26:24 +00:00
Add InvenTreeObject class for getting API data
This commit is contained in:
parent
3da5adca28
commit
ef09b024e6
2 changed files with 157 additions and 3 deletions
16
lib/api.dart
16
lib/api.dart
|
|
@ -6,16 +6,24 @@ import 'package:path/path.dart' as path;
|
|||
import 'package:http/http.dart' as http;
|
||||
|
||||
|
||||
/**
|
||||
* InvenTree API - Access to the InvenTree REST interface.
|
||||
*
|
||||
* InvenTree implements token-based authentication, which is
|
||||
* initialised using a username:password combination.
|
||||
*/
|
||||
|
||||
|
||||
class InvenTreeAPI {
|
||||
|
||||
// Endpoint for requesting an API token
|
||||
static const _URL_GET_TOKEN = "user/token/";
|
||||
static const _URL_GET_VERSION = "";
|
||||
|
||||
// Ensure we only ever create a single instance of the API class
|
||||
static final InvenTreeAPI _api = new InvenTreeAPI._internal();
|
||||
|
||||
factory InvenTreeAPI() {
|
||||
return _api;
|
||||
}
|
||||
factory InvenTreeAPI() { return _api; }
|
||||
|
||||
InvenTreeAPI._internal();
|
||||
|
||||
|
|
@ -77,6 +85,8 @@ class InvenTreeAPI {
|
|||
url = url.substring(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return path.join(_base_url, url);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue