Compare commits
2 Commits
32799f648c
...
7dea44d1e8
Author | SHA1 | Date | |
---|---|---|---|
7dea44d1e8 | |||
5f27956035 |
@@ -19,7 +19,7 @@ abstract class WebuntisApi extends ApiRequest {
|
|||||||
WebuntisApi(this.method, this.genericParam, {this.authenticatedResponse = true});
|
WebuntisApi(this.method, this.genericParam, {this.authenticatedResponse = true});
|
||||||
|
|
||||||
|
|
||||||
Future<String> query(WebuntisApi untis) async {
|
Future<String> query(WebuntisApi untis, {bool retry = false}) async {
|
||||||
var query = '{"id":"ID","method":"$method","params":${untis._body()},"jsonrpc":"2.0"}';
|
var query = '{"id":"ID","method":"$method","params":${untis._body()},"jsonrpc":"2.0"}';
|
||||||
|
|
||||||
var sessionId = '0';
|
var sessionId = '0';
|
||||||
@@ -32,8 +32,9 @@ abstract class WebuntisApi extends ApiRequest {
|
|||||||
dynamic jsonData = jsonDecode(data.body);
|
dynamic jsonData = jsonDecode(data.body);
|
||||||
if(jsonData['error'] != null) {
|
if(jsonData['error'] != null) {
|
||||||
if(jsonData['error']['code'] == -8520) {
|
if(jsonData['error']['code'] == -8520) {
|
||||||
|
if(retry) throw WebuntisError('Authentication was tried (probably session timeout), but was not successful!', 1);
|
||||||
await Authenticate.createSession();
|
await Authenticate.createSession();
|
||||||
this.query(untis);
|
return await this.query(untis, retry: true);
|
||||||
} else {
|
} else {
|
||||||
throw WebuntisError(jsonData['error']['message'], jsonData['error']['code']);
|
throw WebuntisError(jsonData['error']['message'], jsonData['error']['code']);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user