Synchronise API calls

This commit is contained in:
Les De Ridder 2017-02-14 23:13:04 +01:00
parent 79425abc05
commit fdf78de626
No known key found for this signature in database
GPG Key ID: 5EC132DFA85DB372
1 changed files with 21 additions and 0 deletions

View File

@ -137,6 +137,8 @@ class ApiClient
private string _sessionId;
private int _requestCounter;
private bool _busy;
this(string locale)
{
_locale = locale;
@ -196,6 +198,13 @@ class ApiClient
string getAccountAvailable()
{
while(_busy)
{
sleep(10.msecs);
}
_busy = true;
auto clickImageEvent = createClickImageEvent("Container@reuse_Screen@img_Account");
auto widgetEventsRequest = new WidgetEvents("Container", [clickImageEvent]);
@ -210,6 +219,8 @@ class ApiClient
goHome();
_busy = false;
foreach(widgetUpdate; response.responseSets[0].responses[0]["ScreenUpdate"])
{
if(widgetUpdate["widgetId"] == "Container@reuse_flowApplication@repeater_1292926459910")
@ -225,8 +236,16 @@ class ApiClient
string getCardAvailable()
{
while(_busy)
{
sleep(10.msecs);
}
_busy = true;
auto clickImageEvent = createClickImageEvent("Container@reuse_Screen@img_card");
auto widgetEventsRequest = new WidgetEvents("Container", [clickImageEvent]);
sendRequest("sequential", widgetEventsRequest);
@ -239,6 +258,8 @@ class ApiClient
goHome();
_busy = false;
foreach(widgetUpdate; response.responseSets[0].responses[0]["ScreenUpdate"])
{
if(widgetUpdate["widgetId"] == "Container@reuse_flowApplication@reuse_CreditCardCommonData@lbl_available_amount_value")