|
4 | 4 | import android.content.pm.ApplicationInfo; |
5 | 5 | import android.util.Log; |
6 | 6 |
|
| 7 | +import com.facebook.react.bridge.Promise; |
7 | 8 | import com.facebook.react.bridge.ReactApplicationContext; |
8 | 9 | import com.facebook.react.bridge.ReactContext; |
9 | 10 | import com.facebook.react.bridge.ReactContextBaseJavaModule; |
|
12 | 13 | import com.facebook.react.bridge.ReadableMap; |
13 | 14 | import com.facebook.react.bridge.ReadableType; |
14 | 15 | import com.facebook.react.bridge.WritableNativeMap; |
| 16 | + |
| 17 | +import zendesk.chat.Account; |
| 18 | +import zendesk.chat.AccountStatus; |
15 | 19 | import zendesk.chat.Chat; |
16 | 20 | import zendesk.chat.ChatConfiguration; |
| 21 | +import zendesk.chat.ChatEngine; |
17 | 22 | import zendesk.chat.ChatSessionStatus; |
18 | 23 | import zendesk.chat.ChatState; |
19 | 24 | import zendesk.chat.ObservationScope; |
20 | 25 | import zendesk.chat.Observer; |
21 | 26 | import zendesk.chat.ProfileProvider; |
22 | 27 | import zendesk.chat.PreChatFormFieldStatus; |
23 | 28 | import zendesk.chat.PushNotificationsProvider; |
24 | | -import zendesk.chat.ChatEngine; |
25 | | -import zendesk.chat.PushNotificationsProvider; |
26 | 29 | import zendesk.chat.VisitorInfo; |
27 | | -import zendesk.chat.AccountStatus; |
28 | 30 | import zendesk.messaging.MessagingActivity; |
29 | 31 | import zendesk.messaging.MessagingConfiguration; |
| 32 | +import com.zendesk.service.ErrorResponse; |
| 33 | +import com.zendesk.service.ZendeskCallback; |
30 | 34 |
|
31 | 35 | import java.lang.String; |
32 | 36 | import java.util.ArrayList; |
@@ -380,28 +384,28 @@ public void update(ChatState chatState) { |
380 | 384 | }); |
381 | 385 | } |
382 | 386 |
|
383 | | - @ReactMethod |
384 | | - public void areAgentsOnline(Promise promise) { |
385 | | - Chat.INSTANCE.providers().accountProvider().getAccount(new ZendeskCallback<Account>() { |
386 | | - @Override |
387 | | - public void onSuccess(Account account) { |
388 | | - AccountStatus status = account.getStatus(); |
389 | | - |
390 | | - switch (status) { |
391 | | - case AccountStatus.ONLINE: |
392 | | - promise.resolve(true); |
393 | | - break; |
394 | | - |
395 | | - default: |
396 | | - promise.resolve(false); |
397 | | - break; |
398 | | - } |
399 | | - } |
400 | | - |
401 | | - @Override |
402 | | - public void onError(ErrorResponse errorResponse) { |
403 | | - reject(); |
404 | | - } |
405 | | - }); |
406 | | - } |
| 387 | + @ReactMethod |
| 388 | + public void areAgentsOnline(final Promise promise) { |
| 389 | + Chat.INSTANCE.providers().accountProvider().getAccount(new ZendeskCallback<Account>() { |
| 390 | + @Override |
| 391 | + public void onSuccess(Account account) { |
| 392 | + AccountStatus status = account.getStatus(); |
| 393 | + |
| 394 | + switch (status) { |
| 395 | + case ONLINE: |
| 396 | + promise.resolve(true); |
| 397 | + break; |
| 398 | + |
| 399 | + default: |
| 400 | + promise.resolve(false); |
| 401 | + break; |
| 402 | + } |
| 403 | + } |
| 404 | + |
| 405 | + @Override |
| 406 | + public void onError(ErrorResponse errorResponse) { |
| 407 | + promise.reject("no-available-zendesk-account", "DevError: Not connected to Zendesk or network issue"); |
| 408 | + } |
| 409 | + }); |
| 410 | + } |
407 | 411 | } |
0 commit comments