| 37651 |
vikas |
1 |
package com.spice.profitmandi.dao.enumuration.dtr;
|
|
|
2 |
|
|
|
3 |
/**
|
|
|
4 |
* Lifecycle of one LMS dial attempt, normalised across dialer providers.
|
|
|
5 |
*
|
|
|
6 |
* <p>Providers use their own vocabularies (Vonage: {@code ringing/answered/completed/busy/unanswered/
|
|
|
7 |
* rejected/failed}; Knowlarity pushes a free-text {@code call_status}). Each
|
|
|
8 |
* {@code LmsDialerProvider} maps its vendor status onto this set so the LMS — the trail, the SLA
|
|
|
9 |
* clock, the BGC Daily report — never has to know which dialer placed the call.
|
|
|
10 |
*
|
|
|
11 |
* <p>{@link #ANSWERED} is the one that matters for the 5-hr first-contact SLA (SOP §11): a call that
|
|
|
12 |
* merely rang is not contact.
|
|
|
13 |
*/
|
|
|
14 |
public enum LeadCallStatus {
|
|
|
15 |
|
|
|
16 |
/** Placed with the provider; the retailer's phone has not rung yet. */
|
|
|
17 |
INITIATED,
|
|
|
18 |
/** Ringing at the retailer. */
|
|
|
19 |
RINGING,
|
|
|
20 |
/** Retailer picked up — this is what closes the first-contact SLA. */
|
|
|
21 |
ANSWERED,
|
|
|
22 |
/** Answered and then hung up normally. Terminal. */
|
|
|
23 |
COMPLETED,
|
|
|
24 |
/** Rang out with no answer. Terminal. */
|
|
|
25 |
UNANSWERED,
|
|
|
26 |
/** Retailer's line was busy. Terminal. */
|
|
|
27 |
BUSY,
|
|
|
28 |
/** Actively declined. Terminal. */
|
|
|
29 |
REJECTED,
|
|
|
30 |
/** Never connected — carrier/provider error, bad number, agent leg died. Terminal. */
|
|
|
31 |
FAILED,
|
|
|
32 |
/** Agent abandoned before the retailer answered. Terminal. */
|
|
|
33 |
CANCELLED;
|
|
|
34 |
|
|
|
35 |
/** No further provider events are expected for this call. */
|
|
|
36 |
public boolean isTerminal() {
|
|
|
37 |
return this != INITIATED && this != RINGING && this != ANSWERED;
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
/** Did the retailer actually pick up? Only these may stamp {@code Lead.firstContactedAt}. */
|
|
|
41 |
public boolean isConnected() {
|
|
|
42 |
return this == ANSWERED || this == COMPLETED;
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
/**
|
|
|
46 |
* How far through the call this state is. Providers do not guarantee webhook ordering, so a
|
|
|
47 |
* {@code ringing} event can land after {@code answered}; comparing ranks is what stops a
|
|
|
48 |
* late-arriving earlier event from walking the call backwards.
|
|
|
49 |
*/
|
|
|
50 |
public int progressRank() {
|
|
|
51 |
switch (this) {
|
|
|
52 |
case INITIATED:
|
|
|
53 |
return 0;
|
|
|
54 |
case RINGING:
|
|
|
55 |
return 1;
|
|
|
56 |
case ANSWERED:
|
|
|
57 |
return 2;
|
|
|
58 |
default:
|
|
|
59 |
// Every terminal state sits at the end.
|
|
|
60 |
return 3;
|
|
|
61 |
}
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
/** Would moving from {@code current} to this state be a forward step? Null current always is. */
|
|
|
65 |
public boolean advancesFrom(LeadCallStatus current) {
|
|
|
66 |
return current == null || progressRank() >= current.progressRank();
|
|
|
67 |
}
|
|
|
68 |
}
|