2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 10:15:32 +00:00

Add InvenTreeObject class for getting API data

This commit is contained in:
Oliver Walters
2020-03-31 00:05:54 +11:00
parent 3da5adca28
commit ef09b024e6
2 changed files with 157 additions and 3 deletions

View File

@ -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);
}