-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCall.java
More file actions
82 lines (68 loc) · 2.24 KB
/
Call.java
File metadata and controls
82 lines (68 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package builder.task;
import java.util.Date;
import java.util.Random;
import java.util.UUID;
public class Call {
private Request.RequestBuilder builder;
public void callPop(Agent agent) {
String requestId = "" + (new Date()).getTime();
builder = new Request.RequestBuilder(requestId, agent);
String callerNumber = getCallerNumber();
Customer customer = getOrCreateCustomer(callerNumber);
builder.setRequester(customer);
String requestContent = getRequestContent();
builder.setReqContent(requestContent);
String responseContent = getResponseContent();
if (requestContent == null) {
responseContent = getResponseFromSuperVisorContent();
if (responseContent == null) {
builder.setSaleLead(true);
}
}
builder.setRespContent(responseContent);
builder.setAnswered(responseContent != null);
builder.setNeedCallBack(needCallBack());
saveData(builder.build());
}
private void saveData(Request build) {
//Here you sould store data into DB.
}
private boolean needCallBack() {
Random r = new Random(2);
if (r.nextInt() > 1) {
return true;
}
return false;
}
/**
* This method simulates retriving or creating new customer
* Method returns CustomerFlyweight if there is any customer with this phone number in DataBase. Otherwise it will create
* new record in DB and returns newly created data
*
* @param callerNumber
* @return
*/
private Customer getOrCreateCustomer(String callerNumber) {
return new Customer();
}
public String getCallerNumber() {
return UUID.randomUUID().toString();
}
public String getRequestContent() {
return UUID.randomUUID().toString();
}
public String getResponseContent() {
Random r = new Random(2);
if (r.nextInt() > 1) {
return UUID.randomUUID().toString();
}
return null;
}
public String getResponseFromSuperVisorContent() {
Random r = new Random(2);
if (r.nextInt() > 1) {
return UUID.randomUUID().toString();
}
return null;
}
}