call-control-sdk 5.4.8 → 6.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +234 -351
- package/dist/index.d.ts +234 -351
- package/dist/index.js +84 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +84 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,75 @@
|
|
|
1
1
|
import { SxProps } from '@mui/material';
|
|
2
|
-
import { AxiosResponse, AxiosError, AxiosRequestConfig } from 'axios';
|
|
3
2
|
import * as react from 'react';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
5
|
+
* 🚪 Logout Custom Hook
|
|
6
|
+
*
|
|
7
|
+
* @function useLogout
|
|
8
|
+
* @description 🎯 Custom React hook that provides comprehensive agent logout functionality
|
|
9
|
+
* for the CTI SDK. It handles secure logout procedures, complete state cleanup,
|
|
10
|
+
* and storage management with intelligent error handling and proper cleanup.
|
|
11
|
+
*
|
|
12
|
+
* @returns {Object} Hook return object containing:
|
|
13
|
+
* - `logout: () => Promise<any>` - 🚪 Logout function
|
|
14
|
+
* - `isLoading: boolean` - ⏳ Loading state indicator
|
|
15
|
+
* - `isSuccess: boolean` - ✅ Success state indicator
|
|
16
|
+
* - `isError: boolean` - ❌ Error state indicator
|
|
17
|
+
* - `error: any` - 🛡️ Error object when logout fails
|
|
18
|
+
* - `data: any` - 📊 Response data from successful logout
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // Basic usage in a component
|
|
23
|
+
* const LogoutButton = () => {
|
|
24
|
+
* const {
|
|
25
|
+
* logout,
|
|
26
|
+
* isLoading,
|
|
27
|
+
* isSuccess,
|
|
28
|
+
* isError,
|
|
29
|
+
* error
|
|
30
|
+
* } = useLogout();
|
|
31
|
+
*
|
|
32
|
+
* const handleLogout = async () => {
|
|
33
|
+
* try {
|
|
34
|
+
* const result = await logout();
|
|
35
|
+
* console.log('🚪 Logout successful:', result);
|
|
36
|
+
* // Redirect to login page or handle success
|
|
37
|
+
* } catch (err) {
|
|
38
|
+
* console.error('❌ Logout failed:', err);
|
|
39
|
+
* }
|
|
40
|
+
* };
|
|
41
|
+
*
|
|
42
|
+
* return (
|
|
43
|
+
* <button
|
|
44
|
+
* onClick={handleLogout}
|
|
45
|
+
* disabled={isLoading}
|
|
46
|
+
* >
|
|
47
|
+
* {isLoading ? 'Logging out...' : 'Logout'}
|
|
48
|
+
* </button>
|
|
49
|
+
* );
|
|
50
|
+
* };
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @features
|
|
54
|
+
* - 🚪 Secure agent logout with API validation
|
|
55
|
+
* - 🗑️ Complete state cleanup and reset
|
|
56
|
+
* - 💾 Storage management (localStorage & sessionStorage)
|
|
57
|
+
* - ⏳ Comprehensive loading state management
|
|
58
|
+
* - 🛡️ Robust error handling and recovery
|
|
59
|
+
* - 📊 Real-time state updates via SDK manager
|
|
60
|
+
* - 🔄 Automatic storage cleanup
|
|
61
|
+
*
|
|
62
|
+
* @logic
|
|
63
|
+
* - 🔍 Retrieves agent state from localStorage
|
|
64
|
+
* - 📦 Constructs logout API payload
|
|
65
|
+
* - 📡 Makes API call to logout agent
|
|
66
|
+
* - 🗑️ Clears SDK state manager
|
|
67
|
+
* - 💾 Clears all storage (localStorage & sessionStorage)
|
|
68
|
+
* - 📊 Handles success/error states
|
|
69
|
+
* - ⏳ Manages loading states
|
|
70
|
+
*
|
|
71
|
+
* @since 1.0.0
|
|
72
|
+
* @author CTI SDK Team
|
|
9
73
|
*/
|
|
10
74
|
declare const useLogout: () => {
|
|
11
75
|
logout: () => Promise<any>;
|
|
@@ -17,9 +81,75 @@ declare const useLogout: () => {
|
|
|
17
81
|
};
|
|
18
82
|
|
|
19
83
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* @
|
|
84
|
+
* 📞 End Call Custom Hook
|
|
85
|
+
*
|
|
86
|
+
* @function useEndCall
|
|
87
|
+
* @description 🎯 Custom React hook that provides comprehensive call termination functionality
|
|
88
|
+
* for the CTI SDK. It handles call disposition capture, callback scheduling,
|
|
89
|
+
* and proper call cleanup with intelligent state management and error handling.
|
|
90
|
+
*
|
|
91
|
+
* @returns {Object} Hook return object containing:
|
|
92
|
+
* - `handleEndCall: (data: EndCallData) => Promise<any>` - 📞 Call termination function
|
|
93
|
+
* - `isLoading: boolean` - ⏳ Loading state indicator
|
|
94
|
+
* - `isSuccess: boolean` - ✅ Success state indicator
|
|
95
|
+
* - `isError: boolean` - ❌ Error state indicator
|
|
96
|
+
* - `error: any` - 🛡️ Error object when call fails
|
|
97
|
+
* - `data: any` - 📊 Response data from successful calls
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* // Basic usage in a component
|
|
102
|
+
* const EndCallButton = () => {
|
|
103
|
+
* const {
|
|
104
|
+
* handleEndCall,
|
|
105
|
+
* isLoading,
|
|
106
|
+
* isSuccess,
|
|
107
|
+
* isError,
|
|
108
|
+
* error
|
|
109
|
+
* } = useEndCall();
|
|
110
|
+
*
|
|
111
|
+
* const endCall = async () => {
|
|
112
|
+
* try {
|
|
113
|
+
* const result = await handleEndCall({
|
|
114
|
+
* disposition: "RES",
|
|
115
|
+
* followUp: "N"
|
|
116
|
+
* });
|
|
117
|
+
* console.log('📞 Call ended:', result);
|
|
118
|
+
* } catch (err) {
|
|
119
|
+
* console.error('❌ End call failed:', err);
|
|
120
|
+
* }
|
|
121
|
+
* };
|
|
122
|
+
*
|
|
123
|
+
* return (
|
|
124
|
+
* <button
|
|
125
|
+
* onClick={endCall}
|
|
126
|
+
* disabled={isLoading}
|
|
127
|
+
* >
|
|
128
|
+
* {isLoading ? 'Ending...' : 'End Call'}
|
|
129
|
+
* </button>
|
|
130
|
+
* );
|
|
131
|
+
* };
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @features
|
|
135
|
+
* - 🎯 Comprehensive call termination with disposition tracking
|
|
136
|
+
* - 📅 Callback scheduling and follow-up management
|
|
137
|
+
* - 🔄 Intelligent state cleanup and reset
|
|
138
|
+
* - ⏳ Comprehensive loading state management
|
|
139
|
+
* - 🛡️ Robust error handling and recovery
|
|
140
|
+
* - 📊 Real-time state updates via SDK manager
|
|
141
|
+
* - 🔄 Automatic call state management
|
|
142
|
+
*
|
|
143
|
+
* @logic
|
|
144
|
+
* - 🔍 Retrieves agent state from localStorage
|
|
145
|
+
* - 📦 Constructs comprehensive API payload
|
|
146
|
+
* - 📡 Makes API call to end call
|
|
147
|
+
* - 🔄 Updates SDK state manager
|
|
148
|
+
* - 📊 Handles success/error states
|
|
149
|
+
* - ⏳ Manages loading states
|
|
150
|
+
*
|
|
151
|
+
* @since 1.0.0
|
|
152
|
+
* @author CTI SDK Team
|
|
23
153
|
*/
|
|
24
154
|
declare const useEndCall: () => {
|
|
25
155
|
handleEndCall: (data: {
|
|
@@ -391,370 +521,123 @@ interface SDKState {
|
|
|
391
521
|
/** Array of conference lines and their states */
|
|
392
522
|
conferenceLine: ConferenceLineTypes[];
|
|
393
523
|
}
|
|
524
|
+
|
|
394
525
|
/**
|
|
395
|
-
* @
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
* @
|
|
410
|
-
*
|
|
411
|
-
* @
|
|
412
|
-
* ```typescript
|
|
413
|
-
* const requestOptions: RequestOptions = {
|
|
414
|
-
* onSuccess: (response, request) => {
|
|
415
|
-
* console.log('Request successful:', response.data);
|
|
416
|
-
* // Handle successful response
|
|
417
|
-
* },
|
|
418
|
-
* onError: (error, request) => {
|
|
419
|
-
* console.error('Request failed:', error.message);
|
|
420
|
-
* // Handle error
|
|
421
|
-
* }
|
|
422
|
-
* };
|
|
423
|
-
* ```
|
|
424
|
-
*
|
|
425
|
-
* @return Interface definition for request callback options
|
|
426
|
-
*
|
|
427
|
-
* @conclusion Essential interface for implementing robust error handling and success callbacks in API operations.
|
|
526
|
+
* @fileoverview 📞 Click-to-Call Hook for CTI SDK
|
|
527
|
+
*
|
|
528
|
+
* This file contains the useClickToCall custom hook that provides comprehensive call initiation
|
|
529
|
+
* functionality for the CTI SDK. It handles both regular calls and conference calls with
|
|
530
|
+
* intelligent state management and error handling.
|
|
531
|
+
*
|
|
532
|
+
* 🎯 Key Features:
|
|
533
|
+
* - 📱 Regular call initiation for idle agents
|
|
534
|
+
* - 👥 Conference call initiation for agents on calls
|
|
535
|
+
* - 🔄 Intelligent state detection and routing
|
|
536
|
+
* - ⏳ Loading states and error handling
|
|
537
|
+
* - 📊 Real-time state updates
|
|
538
|
+
* - 🛡️ Comprehensive error management
|
|
539
|
+
*
|
|
540
|
+
* @author CTI SDK Team
|
|
541
|
+
* @version 5.4.8
|
|
542
|
+
* @since 1.0.0
|
|
428
543
|
*/
|
|
429
|
-
interface RequestOptions {
|
|
430
|
-
/**
|
|
431
|
-
* Callback function triggered when the request succeeds.
|
|
432
|
-
* @param response - The successful Axios response object
|
|
433
|
-
* @param request - The original request configuration
|
|
434
|
-
*/
|
|
435
|
-
onSuccess?: (response: AxiosResponse, request: any) => void;
|
|
436
|
-
/**
|
|
437
|
-
* Callback function triggered when the request fails.
|
|
438
|
-
* @param error - The error object containing failure details
|
|
439
|
-
* @param request - The original request configuration
|
|
440
|
-
*/
|
|
441
|
-
onError?: (error: any, request: any) => void;
|
|
442
|
-
disabledSuccessToast?: boolean;
|
|
443
|
-
}
|
|
444
544
|
/**
|
|
445
|
-
*
|
|
446
|
-
* @description Interface defining the return type of API hook state management.
|
|
447
|
-
* Provides comprehensive state tracking for HTTP requests including loading, success, error states, and data.
|
|
448
|
-
*
|
|
449
|
-
* @declaration
|
|
450
|
-
* ```typescript
|
|
451
|
-
* interface RequestResult<T> {
|
|
452
|
-
* isLoading: boolean;
|
|
453
|
-
* isSuccess: boolean;
|
|
454
|
-
* isError: boolean;
|
|
455
|
-
* error: AxiosError | null;
|
|
456
|
-
* data: AxiosResponse<T> | null;
|
|
457
|
-
* }
|
|
458
|
-
* ```
|
|
545
|
+
* 📱 Start Call Payload Interface
|
|
459
546
|
*
|
|
460
|
-
* @
|
|
547
|
+
* @interface StartCallPayload
|
|
548
|
+
* @description 📊 Defines the structure for call initiation payload data
|
|
549
|
+
* Contains the mobile number required to initiate a call
|
|
461
550
|
*
|
|
462
|
-
* @
|
|
551
|
+
* @properties
|
|
552
|
+
* - `mobileNumber: string` - 📱 The phone number to call (required)
|
|
463
553
|
*
|
|
464
554
|
* @example
|
|
465
555
|
* ```typescript
|
|
466
|
-
*
|
|
467
|
-
*
|
|
468
|
-
*
|
|
469
|
-
*
|
|
470
|
-
* return <LoadingSpinner />;
|
|
471
|
-
* }
|
|
472
|
-
*
|
|
473
|
-
* if (requestState.isError) {
|
|
474
|
-
* return <ErrorMessage error={requestState.error} />;
|
|
475
|
-
* }
|
|
476
|
-
*
|
|
477
|
-
* if (requestState.isSuccess) {
|
|
478
|
-
* return <UserData user={requestState.data?.data} />;
|
|
479
|
-
* }
|
|
480
|
-
* ```
|
|
481
|
-
*
|
|
482
|
-
* @return Interface definition for request state management
|
|
483
|
-
*
|
|
484
|
-
* @conclusion Essential interface for consistent state management across all API operations.
|
|
485
|
-
*/
|
|
486
|
-
interface RequestResult<T> {
|
|
487
|
-
/** Boolean flag indicating if the request is currently in progress */
|
|
488
|
-
isLoading: boolean;
|
|
489
|
-
/** Boolean flag indicating the request completed successfully */
|
|
490
|
-
isSuccess: boolean;
|
|
491
|
-
/** Boolean flag indicating an error occurred during the request */
|
|
492
|
-
isError: boolean;
|
|
493
|
-
/** Holds the Axios error object if an error occurred, null otherwise */
|
|
494
|
-
error: AxiosError | null;
|
|
495
|
-
/** Holds the successful Axios response data, null if no successful request yet */
|
|
496
|
-
data: AxiosResponse<T> | null;
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* @interface UseApiRequest
|
|
500
|
-
* @description Generic interface for custom API hooks that perform HTTP operations with comprehensive state tracking.
|
|
501
|
-
* Provides a standardized pattern for API request functions with built-in state management.
|
|
502
|
-
*
|
|
503
|
-
* @declaration
|
|
504
|
-
* ```typescript
|
|
505
|
-
* interface UseApiRequest<T = {}, P = void> {
|
|
506
|
-
* (url: string, payloadOrConfig?: P, config?: AxiosRequestConfig): void;
|
|
507
|
-
* state: RequestResult<T>;
|
|
508
|
-
* }
|
|
509
|
-
* ```
|
|
510
|
-
*
|
|
511
|
-
* @requiredParams None (interface definition)
|
|
512
|
-
*
|
|
513
|
-
* @returnType Interface definition
|
|
514
|
-
*
|
|
515
|
-
* @example
|
|
516
|
-
* ```typescript
|
|
517
|
-
* const fetchUser: UseApiRequest<User, { id: number }> = useApi({
|
|
518
|
-
* onSuccess: (response) => console.log('User fetched:', response.data),
|
|
519
|
-
* onError: (error) => console.error('Failed to fetch user:', error)
|
|
520
|
-
* });
|
|
521
|
-
*
|
|
522
|
-
* // Usage
|
|
523
|
-
* fetchUser('/api/users', { id: 123 });
|
|
556
|
+
* // Basic call initiation payload
|
|
557
|
+
* const callPayload: StartCallPayload = {
|
|
558
|
+
* mobileNumber: "1234567890"
|
|
559
|
+
* };
|
|
524
560
|
*
|
|
525
|
-
* //
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
* }
|
|
561
|
+
* // Usage in component
|
|
562
|
+
* const { handleStartCall } = useClickToCall();
|
|
563
|
+
* await handleStartCall({ mobileNumber: "9876543210" });
|
|
529
564
|
* ```
|
|
530
565
|
*
|
|
531
|
-
* @
|
|
532
|
-
*
|
|
533
|
-
* @conclusion Provides a consistent pattern for all API operations with built-in state management and error handling.
|
|
566
|
+
* @since 1.0.0
|
|
567
|
+
* @author CTI SDK Team
|
|
534
568
|
*/
|
|
535
|
-
interface
|
|
536
|
-
|
|
537
|
-
* Executes the API request with the provided parameters
|
|
538
|
-
* @param url - The API endpoint URL
|
|
539
|
-
* @param payloadOrConfig - Request payload or configuration object
|
|
540
|
-
* @param config - Additional Axios configuration options
|
|
541
|
-
*/
|
|
542
|
-
(url: string, payloadOrConfig?: P, config?: AxiosRequestConfig): void;
|
|
543
|
-
/** Current state of the request including loading, success, error, and data */
|
|
544
|
-
state: RequestResult<T>;
|
|
569
|
+
interface StartCallPayload {
|
|
570
|
+
mobileNumber: string;
|
|
545
571
|
}
|
|
546
572
|
/**
|
|
547
|
-
*
|
|
548
|
-
* @description Tuple type for HTTP GET request hooks with comprehensive state management.
|
|
549
|
-
* Provides a clean API for making GET requests with built-in loading, success, and error states.
|
|
550
|
-
*
|
|
551
|
-
* @declaration
|
|
552
|
-
* ```typescript
|
|
553
|
-
* type UseGetRequest<T = {}> = [
|
|
554
|
-
* (url: string, config?: AxiosRequestConfig) => void,
|
|
555
|
-
* RequestResult<T>
|
|
556
|
-
* ];
|
|
557
|
-
* ```
|
|
558
|
-
*
|
|
559
|
-
* @requiredParams None (type definition)
|
|
560
|
-
*
|
|
561
|
-
* @returnType Tuple type definition
|
|
562
|
-
*
|
|
563
|
-
* @example
|
|
564
|
-
* ```typescript
|
|
565
|
-
* const [getUser, userState] = useGetRequest<User>();
|
|
566
|
-
*
|
|
567
|
-
* // Execute request
|
|
568
|
-
* getUser("/api/users/123");
|
|
569
|
-
*
|
|
570
|
-
* // Access state
|
|
571
|
-
* if (userState.isLoading) return <LoadingSpinner />;
|
|
572
|
-
* if (userState.isError) return <ErrorMessage error={userState.error} />;
|
|
573
|
-
* if (userState.isSuccess) return <UserProfile user={userState.data?.data} />;
|
|
574
|
-
* ```
|
|
575
|
-
*
|
|
576
|
-
* @return Tuple type: [request function, state object]
|
|
577
|
-
*
|
|
578
|
-
* @conclusion Provides a consistent pattern for GET requests with comprehensive state management.
|
|
579
|
-
*/
|
|
580
|
-
type UseGetRequest<T = {}> = [
|
|
581
|
-
(url: string, config?: AxiosRequestConfig) => void,
|
|
582
|
-
RequestResult<T>
|
|
583
|
-
];
|
|
584
|
-
/**
|
|
585
|
-
* @type UsePostRequest
|
|
586
|
-
* @description Tuple type for HTTP POST request hooks with typed payload and state management.
|
|
587
|
-
* Ideal for creating new resources with comprehensive error handling and state tracking.
|
|
588
|
-
*
|
|
589
|
-
* @declaration
|
|
590
|
-
* ```typescript
|
|
591
|
-
* type UsePostRequest<T = {}> = [
|
|
592
|
-
* (url: string, payload: T, config?: AxiosRequestConfig) => void,
|
|
593
|
-
* RequestResult<T>
|
|
594
|
-
* ];
|
|
595
|
-
* ```
|
|
596
|
-
*
|
|
597
|
-
* @requiredParams None (type definition)
|
|
598
|
-
*
|
|
599
|
-
* @returnType Tuple type definition
|
|
600
|
-
*
|
|
601
|
-
* @example
|
|
602
|
-
* ```typescript
|
|
603
|
-
* const [createUser, createState] = usePostRequest<User>();
|
|
604
|
-
*
|
|
605
|
-
* // Execute request
|
|
606
|
-
* createUser("/api/users", {
|
|
607
|
-
* name: "John Doe",
|
|
608
|
-
* email: "john@example.com"
|
|
609
|
-
* });
|
|
610
|
-
*
|
|
611
|
-
* // Access state
|
|
612
|
-
* if (createState.isLoading) return <LoadingSpinner />;
|
|
613
|
-
* if (createState.isSuccess) {
|
|
614
|
-
* console.log("User created:", createState.data?.data);
|
|
615
|
-
* }
|
|
616
|
-
* ```
|
|
617
|
-
*
|
|
618
|
-
* @return Tuple type: [request function, state object]
|
|
619
|
-
*
|
|
620
|
-
* @conclusion Essential type for POST operations with robust state management and error handling.
|
|
621
|
-
*/
|
|
622
|
-
type UsePostRequest<T = {}> = [
|
|
623
|
-
(url: string, payload: T, config?: AxiosRequestConfig) => void,
|
|
624
|
-
RequestResult<T>
|
|
625
|
-
];
|
|
626
|
-
/**
|
|
627
|
-
* @type UsePutRequest
|
|
628
|
-
* @description Tuple type for HTTP PUT request hooks with typed payload and comprehensive state tracking.
|
|
629
|
-
* Perfect for updating existing resources with full state management capabilities.
|
|
573
|
+
* 📞 Click-to-Call Custom Hook
|
|
630
574
|
*
|
|
631
|
-
* @
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
635
|
-
* RequestResult<T>
|
|
636
|
-
* ];
|
|
637
|
-
* ```
|
|
575
|
+
* @function useClickToCall
|
|
576
|
+
* @description 🎯 Custom React hook that provides comprehensive call initiation functionality
|
|
577
|
+
* for the CTI SDK. It intelligently handles both regular calls and conference calls
|
|
578
|
+
* based on the current agent state, with proper loading states and error handling.
|
|
638
579
|
*
|
|
639
|
-
* @
|
|
640
|
-
*
|
|
641
|
-
*
|
|
580
|
+
* @returns {Object} Hook return object containing:
|
|
581
|
+
* - `handleStartCall: (data: StartCallPayload) => Promise<any>` - 📞 Call initiation function
|
|
582
|
+
* - `isLoading: boolean` - ⏳ Loading state indicator
|
|
583
|
+
* - `isSuccess: boolean` - ✅ Success state indicator
|
|
584
|
+
* - `isError: boolean` - ❌ Error state indicator
|
|
585
|
+
* - `error: any` - 🛡️ Error object when call fails
|
|
586
|
+
* - `data: any` - 📊 Response data from successful calls
|
|
642
587
|
*
|
|
643
588
|
* @example
|
|
644
589
|
* ```typescript
|
|
645
|
-
*
|
|
646
|
-
*
|
|
647
|
-
*
|
|
648
|
-
*
|
|
649
|
-
*
|
|
650
|
-
*
|
|
651
|
-
*
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
*
|
|
655
|
-
*
|
|
656
|
-
*
|
|
657
|
-
*
|
|
658
|
-
*
|
|
659
|
-
*
|
|
660
|
-
*
|
|
661
|
-
*
|
|
662
|
-
*
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
*
|
|
670
|
-
*
|
|
671
|
-
*
|
|
672
|
-
*
|
|
673
|
-
*
|
|
674
|
-
*
|
|
675
|
-
* type UseDeleteRequest<T = {}> = [
|
|
676
|
-
* (url: string, config?: AxiosRequestConfig) => void,
|
|
677
|
-
* RequestResult<T>
|
|
678
|
-
* ];
|
|
679
|
-
* ```
|
|
680
|
-
*
|
|
681
|
-
* @requiredParams None (type definition)
|
|
682
|
-
*
|
|
683
|
-
* @returnType Tuple type definition
|
|
684
|
-
*
|
|
685
|
-
* @example
|
|
686
|
-
* ```typescript
|
|
687
|
-
* const [deleteUser, deleteState] = useDeleteRequest<void>();
|
|
688
|
-
*
|
|
689
|
-
* // Execute request
|
|
690
|
-
* deleteUser("/api/users/123");
|
|
691
|
-
*
|
|
692
|
-
* // Access state
|
|
693
|
-
* if (deleteState.isLoading) return <LoadingSpinner />;
|
|
694
|
-
* if (deleteState.isSuccess) {
|
|
695
|
-
* console.log("User deleted successfully");
|
|
696
|
-
* }
|
|
697
|
-
* ```
|
|
698
|
-
*
|
|
699
|
-
* @return Tuple type: [request function, state object]
|
|
700
|
-
*
|
|
701
|
-
* @conclusion Essential type for DELETE operations with robust state management.
|
|
702
|
-
*/
|
|
703
|
-
type UseDeleteRequest<T = {}> = [
|
|
704
|
-
(url: string, config?: AxiosRequestConfig) => void,
|
|
705
|
-
RequestResult<T>
|
|
706
|
-
];
|
|
707
|
-
/**
|
|
708
|
-
* @type UsePatchRequest
|
|
709
|
-
* @description Tuple type for HTTP PATCH request hooks with typed payload and comprehensive state tracking.
|
|
710
|
-
* Ideal for partial updates with built-in state management and error handling.
|
|
711
|
-
*
|
|
712
|
-
* @declaration
|
|
713
|
-
* ```typescript
|
|
714
|
-
* type UsePatchRequest<T = {}> = [
|
|
715
|
-
* (url: string, payload: T, config?: AxiosRequestConfig) => void,
|
|
716
|
-
* RequestResult<T>
|
|
717
|
-
* ];
|
|
718
|
-
* ```
|
|
719
|
-
*
|
|
720
|
-
* @requiredParams None (type definition)
|
|
721
|
-
*
|
|
722
|
-
* @returnType Tuple type definition
|
|
723
|
-
*
|
|
724
|
-
* @example
|
|
725
|
-
* ```typescript
|
|
726
|
-
* const [patchUser, patchState] = usePatchRequest<Partial<User>>();
|
|
727
|
-
*
|
|
728
|
-
* // Execute request
|
|
729
|
-
* patchUser("/api/users/123", {
|
|
730
|
-
* email: "newemail@example.com"
|
|
731
|
-
* });
|
|
732
|
-
*
|
|
733
|
-
* // Access state
|
|
734
|
-
* if (patchState.isLoading) return <LoadingSpinner />;
|
|
735
|
-
* if (patchState.isSuccess) {
|
|
736
|
-
* console.log("User patched:", patchState.data?.data);
|
|
737
|
-
* }
|
|
590
|
+
* // Basic usage in a component
|
|
591
|
+
* const CallButton = () => {
|
|
592
|
+
* const {
|
|
593
|
+
* handleStartCall,
|
|
594
|
+
* isLoading,
|
|
595
|
+
* isSuccess,
|
|
596
|
+
* isError,
|
|
597
|
+
* error
|
|
598
|
+
* } = useClickToCall();
|
|
599
|
+
*
|
|
600
|
+
* const makeCall = async () => {
|
|
601
|
+
* try {
|
|
602
|
+
* const result = await handleStartCall({
|
|
603
|
+
* mobileNumber: "1234567890"
|
|
604
|
+
* });
|
|
605
|
+
* console.log('📞 Call initiated:', result);
|
|
606
|
+
* } catch (err) {
|
|
607
|
+
* console.error('❌ Call failed:', err);
|
|
608
|
+
* }
|
|
609
|
+
* };
|
|
610
|
+
*
|
|
611
|
+
* return (
|
|
612
|
+
* <button
|
|
613
|
+
* onClick={makeCall}
|
|
614
|
+
* disabled={isLoading}
|
|
615
|
+
* >
|
|
616
|
+
* {isLoading ? 'Calling...' : 'Make Call'}
|
|
617
|
+
* </button>
|
|
618
|
+
* );
|
|
619
|
+
* };
|
|
738
620
|
* ```
|
|
739
621
|
*
|
|
740
|
-
* @
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
*
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
757
|
-
*
|
|
622
|
+
* @features
|
|
623
|
+
* - 🎯 Intelligent call routing based on agent state
|
|
624
|
+
* - 📱 Regular call initiation for idle agents
|
|
625
|
+
* - 👥 Conference call initiation for busy agents
|
|
626
|
+
* - ⏳ Comprehensive loading state management
|
|
627
|
+
* - 🛡️ Robust error handling and recovery
|
|
628
|
+
* - 📊 Real-time state updates via SDK manager
|
|
629
|
+
* - 🔄 Automatic conference dialog management
|
|
630
|
+
*
|
|
631
|
+
* @logic
|
|
632
|
+
* - 🔍 Checks agent status from localStorage state
|
|
633
|
+
* - 📞 Initiates regular call if agent is IDLE
|
|
634
|
+
* - 👥 Initiates conference call if agent is ONCALL
|
|
635
|
+
* - ⚠️ Shows alert if agent is not ready
|
|
636
|
+
* - 🔄 Updates conference line state for conference calls
|
|
637
|
+
* - 🎭 Opens conference dialog for conference calls
|
|
638
|
+
*
|
|
639
|
+
* @since 1.0.0
|
|
640
|
+
* @author CTI SDK Team
|
|
758
641
|
*/
|
|
759
642
|
declare const useClickToCall: () => {
|
|
760
643
|
handleStartCall: (data: StartCallPayload) => Promise<any>;
|
|
@@ -959,4 +842,4 @@ declare function getSDKVersion(): string;
|
|
|
959
842
|
*/
|
|
960
843
|
declare function isSDKInitialized(): boolean;
|
|
961
844
|
|
|
962
|
-
export { CallControlPanel, type CallControlPanelProps, type CallData, type CallStatus, type ConferenceLineTypes, type
|
|
845
|
+
export { CallControlPanel, type CallControlPanelProps, type CallData, type CallStatus, type ConferenceLineTypes, type SDKConfig, type SDKState, getSDKVersion, initSDK, isSDKInitialized, useClickToCall, useEndCall, useLogout };
|