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

Perform "addstock" action

This commit is contained in:
Oliver Walters
2020-04-09 22:56:28 +10:00
parent 1ec0b13479
commit 4cafa668a5
4 changed files with 90 additions and 11 deletions

View File

@ -59,7 +59,7 @@ class InvenTreeAPI {
String makeApiUrl(String endpoint) {
return apiUrl + endpoint;
return _makeUrl("/api/" + endpoint);
}
String makeUrl(String endpoint) {
@ -272,20 +272,18 @@ class InvenTreeAPI {
}
// Perform a POST request
Future<http.Response> post(String url, {Map<String, String> body}) async {
Future<http.Response> post(String url, {Map<String, dynamic> body}) async {
var _url = makeApiUrl(url);
var _headers = defaultHeaders();
var _body = Map<String, String>();
// Copy across provided data
body.forEach((K, V) => _body[K] = V);
var _headers = jsonHeaders();
print("POST: " + _url);
var data = jsonEncode(body);
return http.post(_url,
headers: _headers,
body: _body,
body: data,
);
}
@ -324,6 +322,13 @@ class InvenTreeAPI {
return headers;
}
Map<String, String> jsonHeaders() {
var headers = defaultHeaders();
headers['Content-Type'] = 'application/json';
return headers;
}
String _authorizationHeader () {
if (_token.isNotEmpty) {
return "Token $_token";