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:
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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user