Add TWP Softphone Flutter app and complete mobile backend API
All checks were successful
Create Release / build (push) Successful in 4s
All checks were successful
Create Release / build (push) Successful in 4s
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for mobile VoIP, implement unhold_call() with call leg detection, wire FCM push notifications into call queue and webhook missed call handlers, add data-only FCM message support for Android background wake, and add Twilio API Key / Push Credential settings fields. Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth with auto-refresh, SSE real-time queue updates, FCM push notifications, Material 3 UI with dashboard, active call screen, dialpad, and call controls (mute/speaker/hold/transfer). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
38
mobile/lib/models/agent_status.dart
Normal file
38
mobile/lib/models/agent_status.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
enum AgentStatusValue { available, busy, offline }
|
||||
|
||||
class AgentStatus {
|
||||
final AgentStatusValue status;
|
||||
final bool isLoggedIn;
|
||||
final String? currentCallSid;
|
||||
final String? lastActivity;
|
||||
final bool availableForQueues;
|
||||
|
||||
AgentStatus({
|
||||
required this.status,
|
||||
required this.isLoggedIn,
|
||||
this.currentCallSid,
|
||||
this.lastActivity,
|
||||
this.availableForQueues = true,
|
||||
});
|
||||
|
||||
factory AgentStatus.fromJson(Map<String, dynamic> json) {
|
||||
return AgentStatus(
|
||||
status: _parseStatus(json['status'] as String),
|
||||
isLoggedIn: json['is_logged_in'] as bool,
|
||||
currentCallSid: json['current_call_sid'] as String?,
|
||||
lastActivity: json['last_activity'] as String?,
|
||||
availableForQueues: json['available_for_queues'] as bool? ?? true,
|
||||
);
|
||||
}
|
||||
|
||||
static AgentStatusValue _parseStatus(String s) {
|
||||
switch (s) {
|
||||
case 'available':
|
||||
return AgentStatusValue.available;
|
||||
case 'busy':
|
||||
return AgentStatusValue.busy;
|
||||
default:
|
||||
return AgentStatusValue.offline;
|
||||
}
|
||||
}
|
||||
}
|
||||
46
mobile/lib/models/call_info.dart
Normal file
46
mobile/lib/models/call_info.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
enum CallState { idle, ringing, connecting, connected, disconnected }
|
||||
|
||||
class CallInfo {
|
||||
final CallState state;
|
||||
final String? callSid;
|
||||
final String? callerNumber;
|
||||
final Duration duration;
|
||||
final bool isMuted;
|
||||
final bool isSpeakerOn;
|
||||
final bool isOnHold;
|
||||
|
||||
const CallInfo({
|
||||
this.state = CallState.idle,
|
||||
this.callSid,
|
||||
this.callerNumber,
|
||||
this.duration = Duration.zero,
|
||||
this.isMuted = false,
|
||||
this.isSpeakerOn = false,
|
||||
this.isOnHold = false,
|
||||
});
|
||||
|
||||
CallInfo copyWith({
|
||||
CallState? state,
|
||||
String? callSid,
|
||||
String? callerNumber,
|
||||
Duration? duration,
|
||||
bool? isMuted,
|
||||
bool? isSpeakerOn,
|
||||
bool? isOnHold,
|
||||
}) {
|
||||
return CallInfo(
|
||||
state: state ?? this.state,
|
||||
callSid: callSid ?? this.callSid,
|
||||
callerNumber: callerNumber ?? this.callerNumber,
|
||||
duration: duration ?? this.duration,
|
||||
isMuted: isMuted ?? this.isMuted,
|
||||
isSpeakerOn: isSpeakerOn ?? this.isSpeakerOn,
|
||||
isOnHold: isOnHold ?? this.isOnHold,
|
||||
);
|
||||
}
|
||||
|
||||
bool get isActive =>
|
||||
state == CallState.ringing ||
|
||||
state == CallState.connecting ||
|
||||
state == CallState.connected;
|
||||
}
|
||||
54
mobile/lib/models/queue_state.dart
Normal file
54
mobile/lib/models/queue_state.dart
Normal file
@@ -0,0 +1,54 @@
|
||||
class QueueInfo {
|
||||
final int id;
|
||||
final String name;
|
||||
final String type;
|
||||
final String? extension;
|
||||
final int waitingCount;
|
||||
|
||||
QueueInfo({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.type,
|
||||
this.extension,
|
||||
required this.waitingCount,
|
||||
});
|
||||
|
||||
factory QueueInfo.fromJson(Map<String, dynamic> json) {
|
||||
return QueueInfo(
|
||||
id: json['id'] as int,
|
||||
name: json['name'] as String,
|
||||
type: json['type'] as String,
|
||||
extension: json['extension'] as String?,
|
||||
waitingCount: json['waiting_count'] as int,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class QueueCall {
|
||||
final String callSid;
|
||||
final String fromNumber;
|
||||
final String toNumber;
|
||||
final int position;
|
||||
final String status;
|
||||
final int waitTime;
|
||||
|
||||
QueueCall({
|
||||
required this.callSid,
|
||||
required this.fromNumber,
|
||||
required this.toNumber,
|
||||
required this.position,
|
||||
required this.status,
|
||||
required this.waitTime,
|
||||
});
|
||||
|
||||
factory QueueCall.fromJson(Map<String, dynamic> json) {
|
||||
return QueueCall(
|
||||
callSid: json['call_sid'] as String,
|
||||
fromNumber: json['from_number'] as String,
|
||||
toNumber: json['to_number'] as String,
|
||||
position: json['position'] as int,
|
||||
status: json['status'] as String,
|
||||
waitTime: json['wait_time'] as int,
|
||||
);
|
||||
}
|
||||
}
|
||||
22
mobile/lib/models/user.dart
Normal file
22
mobile/lib/models/user.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
class User {
|
||||
final int id;
|
||||
final String login;
|
||||
final String displayName;
|
||||
final String? email;
|
||||
|
||||
User({
|
||||
required this.id,
|
||||
required this.login,
|
||||
required this.displayName,
|
||||
this.email,
|
||||
});
|
||||
|
||||
factory User.fromJson(Map<String, dynamic> json) {
|
||||
return User(
|
||||
id: json['user_id'] as int,
|
||||
login: json['user_login'] as String,
|
||||
displayName: json['display_name'] as String,
|
||||
email: json['email'] as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user