Fix mobile app: AccessToken for voice, Agent Manager for status, caller ID support
All checks were successful
Create Release / build (push) Successful in 3s
All checks were successful
Create Release / build (push) Successful in 3s
- Voice token: use AccessToken + VoiceGrant instead of browser-only ClientToken - Agent status: delegate to TWP_Agent_Manager matching browser phone behavior - Queue loading: add missing require_once for TWP_User_Queue_Manager - Add /phone-numbers endpoint for caller ID selection - Webhook: support CallerId param from mobile extraOptions - Flutter: caller ID dropdown in dialer, error logging in all catch blocks Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,16 @@ import '../models/queue_state.dart';
|
||||
import '../services/api_client.dart';
|
||||
import '../services/sse_service.dart';
|
||||
|
||||
class PhoneNumber {
|
||||
final String phoneNumber;
|
||||
final String friendlyName;
|
||||
PhoneNumber({required this.phoneNumber, required this.friendlyName});
|
||||
factory PhoneNumber.fromJson(Map<String, dynamic> json) => PhoneNumber(
|
||||
phoneNumber: json['phone_number'] as String,
|
||||
friendlyName: json['friendly_name'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
class AgentProvider extends ChangeNotifier {
|
||||
final ApiClient _api;
|
||||
final SseService _sse;
|
||||
@@ -12,12 +22,14 @@ class AgentProvider extends ChangeNotifier {
|
||||
AgentStatus? _status;
|
||||
List<QueueInfo> _queues = [];
|
||||
bool _sseConnected = false;
|
||||
List<PhoneNumber> _phoneNumbers = [];
|
||||
StreamSubscription? _sseSub;
|
||||
StreamSubscription? _connSub;
|
||||
|
||||
AgentStatus? get status => _status;
|
||||
List<QueueInfo> get queues => _queues;
|
||||
bool get sseConnected => _sseConnected;
|
||||
List<PhoneNumber> get phoneNumbers => _phoneNumbers;
|
||||
|
||||
AgentProvider(this._api, this._sse) {
|
||||
_connSub = _sse.connectionState.listen((connected) {
|
||||
@@ -33,7 +45,7 @@ class AgentProvider extends ChangeNotifier {
|
||||
final response = await _api.dio.get('/agent/status');
|
||||
_status = AgentStatus.fromJson(response.data);
|
||||
notifyListeners();
|
||||
} catch (_) {}
|
||||
} catch (e) { debugPrint('AgentProvider.fetchStatus error: $e'); }
|
||||
}
|
||||
|
||||
Future<void> updateStatus(AgentStatusValue newStatus) async {
|
||||
@@ -49,7 +61,7 @@ class AgentProvider extends ChangeNotifier {
|
||||
currentCallSid: _status?.currentCallSid,
|
||||
);
|
||||
notifyListeners();
|
||||
} catch (_) {}
|
||||
} catch (e) { debugPrint('AgentProvider.updateStatus error: $e'); }
|
||||
}
|
||||
|
||||
Future<void> fetchQueues() async {
|
||||
@@ -60,11 +72,24 @@ class AgentProvider extends ChangeNotifier {
|
||||
.map((q) => QueueInfo.fromJson(q as Map<String, dynamic>))
|
||||
.toList();
|
||||
notifyListeners();
|
||||
} catch (_) {}
|
||||
} catch (e) { debugPrint('AgentProvider.fetchQueues error: $e'); }
|
||||
}
|
||||
|
||||
Future<void> fetchPhoneNumbers() async {
|
||||
try {
|
||||
final response = await _api.dio.get('/phone-numbers');
|
||||
final data = response.data;
|
||||
_phoneNumbers = (data['phone_numbers'] as List)
|
||||
.map((p) => PhoneNumber.fromJson(p as Map<String, dynamic>))
|
||||
.toList();
|
||||
notifyListeners();
|
||||
} catch (e) {
|
||||
debugPrint('AgentProvider.fetchPhoneNumbers error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> refresh() async {
|
||||
await Future.wait([fetchStatus(), fetchQueues()]);
|
||||
await Future.wait([fetchStatus(), fetchQueues(), fetchPhoneNumbers()]);
|
||||
}
|
||||
|
||||
void _handleSseEvent(SseEvent event) {
|
||||
|
||||
Reference in New Issue
Block a user