| 37651 |
vikas |
1 |
package com.spice.profitmandi.dao.entity.auth;
|
|
|
2 |
|
|
|
3 |
import javax.persistence.Column;
|
|
|
4 |
import javax.persistence.Entity;
|
|
|
5 |
import javax.persistence.GeneratedValue;
|
|
|
6 |
import javax.persistence.GenerationType;
|
|
|
7 |
import javax.persistence.Id;
|
|
|
8 |
import javax.persistence.Table;
|
|
|
9 |
import javax.persistence.UniqueConstraint;
|
|
|
10 |
import java.time.LocalDateTime;
|
|
|
11 |
|
|
|
12 |
/**
|
|
|
13 |
* Maps one of our {@code auth.auth_user} rows to its Vonage Application user.
|
|
|
14 |
*
|
|
|
15 |
* <p>The Client SDK authenticates a <em>Vonage user</em>, not our user: the JWT's {@code sub} claim
|
|
|
16 |
* must be the {@code vonage_user_name} created against the Vonage Application. Without a row here an
|
|
|
17 |
* agent simply cannot be issued a token, which is why the dialer disables its call button rather than
|
|
|
18 |
* failing at {@code createSession}.
|
|
|
19 |
*
|
|
|
20 |
* <p>Deliberately a separate table from {@code auth.sip_master} even though both are "agent telephony
|
|
|
21 |
* identity". {@code sip_master} is Knowlarity's, is keyed on {@code email_id}/{@code caller_id}, and is
|
|
|
22 |
* read by {@code KnowlarityAgentResolver} on every live-call event — widening it for a second provider
|
|
|
23 |
* would put the LMS dialer in the blast radius of the call-centre monitor.
|
|
|
24 |
*/
|
|
|
25 |
@Entity
|
|
|
26 |
@Table(name = "auth.vonage_agent",
|
|
|
27 |
uniqueConstraints = {@UniqueConstraint(columnNames = "auth_id")})
|
|
|
28 |
public class VonageAgent {
|
|
|
29 |
|
|
|
30 |
@Id
|
|
|
31 |
@Column(name = "id", unique = true, updatable = false)
|
|
|
32 |
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
|
33 |
private int id;
|
|
|
34 |
|
|
|
35 |
@Column(name = "auth_id")
|
|
|
36 |
private int authId;
|
|
|
37 |
|
|
|
38 |
/** Vonage's own id for the user, e.g. {@code USR-xxxxxxxx-...}. Provenance; not used in the JWT. */
|
|
|
39 |
@Column(name = "vonage_user_id")
|
|
|
40 |
private String vonageUserId;
|
|
|
41 |
|
|
|
42 |
/** The name the JWT's {@code sub} claim carries. This is the one that must be right. */
|
|
|
43 |
@Column(name = "vonage_user_name")
|
|
|
44 |
private String vonageUserName;
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* The Vonage virtual number this agent calls out from, presented to the retailer as caller ID.
|
|
|
48 |
* E.164 digits, no plus. Per-agent rather than one number for the company: agents are assigned
|
|
|
49 |
* their own numbers, and the retailer's callback should reach the person who rang them.
|
|
|
50 |
*
|
|
|
51 |
* <p>Must be a number on the Vonage account — the Voice API rejects a {@code from} it does not
|
|
|
52 |
* own. Null falls back to the {@code vonage.from.number} default.
|
|
|
53 |
*/
|
|
|
54 |
@Column(name = "from_number")
|
|
|
55 |
private String fromNumber;
|
|
|
56 |
|
|
|
57 |
/**
|
|
|
58 |
* The agent's VBC extension, e.g. {@code 1042}. This is what click2dial originates <em>from</em>:
|
|
|
59 |
* VBC rings this extension's registered device and only then dials the retailer.
|
|
|
60 |
*
|
|
|
61 |
* <p>Distinct from {@link #fromNumber}, which is a caller-ID phone number on the Communications
|
|
|
62 |
* APIs path. An extension is not a phone number and the two are not interchangeable.
|
|
|
63 |
*/
|
|
|
64 |
@Column(name = "vbc_extension")
|
|
|
65 |
private String vbcExtension;
|
|
|
66 |
|
|
|
67 |
/**
|
|
|
68 |
* A registered VBC device id, used when {@code vonage.vbc.from.type=device}.
|
|
|
69 |
*
|
|
|
70 |
* <p>Separate from {@link #vbcExtension} because they are different address spaces: an
|
|
|
71 |
* extension is a short dialable number, a device id is an opaque handle from
|
|
|
72 |
* {@code GET /telephony/v3/registration/accounts/{id}/devices}. Which one click2dial should
|
|
|
73 |
* originate from is an account-shaped question, hence the config switch rather than a guess.
|
|
|
74 |
*/
|
|
|
75 |
@Column(name = "vbc_device_id")
|
|
|
76 |
private String vbcDeviceId;
|
|
|
77 |
|
|
|
78 |
/**
|
|
|
79 |
* Lets an agent be switched off without deleting the mapping — revoking dialer access while
|
|
|
80 |
* keeping the audit trail's ability to explain who placed historic calls.
|
|
|
81 |
*/
|
|
|
82 |
@Column(name = "active")
|
|
|
83 |
private boolean active = true;
|
|
|
84 |
|
|
|
85 |
@Column(name = "created_timestamp")
|
|
|
86 |
private LocalDateTime createdTimestamp;
|
|
|
87 |
|
|
|
88 |
@Column(name = "updated_timestamp")
|
|
|
89 |
private LocalDateTime updatedTimestamp;
|
|
|
90 |
|
|
|
91 |
public int getId() {
|
|
|
92 |
return id;
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
public void setId(int id) {
|
|
|
96 |
this.id = id;
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
public int getAuthId() {
|
|
|
100 |
return authId;
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
public void setAuthId(int authId) {
|
|
|
104 |
this.authId = authId;
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
public String getVonageUserId() {
|
|
|
108 |
return vonageUserId;
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
public void setVonageUserId(String vonageUserId) {
|
|
|
112 |
this.vonageUserId = vonageUserId;
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
public String getVonageUserName() {
|
|
|
116 |
return vonageUserName;
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
public void setVonageUserName(String vonageUserName) {
|
|
|
120 |
this.vonageUserName = vonageUserName;
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
public String getFromNumber() {
|
|
|
124 |
return fromNumber;
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
public void setFromNumber(String fromNumber) {
|
|
|
128 |
this.fromNumber = fromNumber;
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
public String getVbcExtension() {
|
|
|
132 |
return vbcExtension;
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
public void setVbcExtension(String vbcExtension) {
|
|
|
136 |
this.vbcExtension = vbcExtension;
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
public String getVbcDeviceId() {
|
|
|
140 |
return vbcDeviceId;
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
public void setVbcDeviceId(String vbcDeviceId) {
|
|
|
144 |
this.vbcDeviceId = vbcDeviceId;
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
public boolean isActive() {
|
|
|
148 |
return active;
|
|
|
149 |
}
|
|
|
150 |
|
|
|
151 |
public void setActive(boolean active) {
|
|
|
152 |
this.active = active;
|
|
|
153 |
}
|
|
|
154 |
|
|
|
155 |
public LocalDateTime getCreatedTimestamp() {
|
|
|
156 |
return createdTimestamp;
|
|
|
157 |
}
|
|
|
158 |
|
|
|
159 |
public void setCreatedTimestamp(LocalDateTime createdTimestamp) {
|
|
|
160 |
this.createdTimestamp = createdTimestamp;
|
|
|
161 |
}
|
|
|
162 |
|
|
|
163 |
public LocalDateTime getUpdatedTimestamp() {
|
|
|
164 |
return updatedTimestamp;
|
|
|
165 |
}
|
|
|
166 |
|
|
|
167 |
public void setUpdatedTimestamp(LocalDateTime updatedTimestamp) {
|
|
|
168 |
this.updatedTimestamp = updatedTimestamp;
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
@Override
|
|
|
172 |
public String toString() {
|
|
|
173 |
return "VonageAgent [authId=" + authId + ", vonageUserName=" + vonageUserName
|
|
|
174 |
+ ", fromNumber=" + fromNumber + ", active=" + active + "]";
|
|
|
175 |
}
|
|
|
176 |
}
|