-
Notifications
You must be signed in to change notification settings - Fork 0
/
agent.go
113 lines (91 loc) · 2.51 KB
/
agent.go
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package five9
import (
"context"
"fmt"
"net/http"
"github.com/equalsgibson/five9-go/five9/five9types"
)
type AgentService struct {
authState *authenticationState
}
func (s AgentService) GetAllMaintenanceNoticesForSelf(ctx context.Context) ([]five9types.MaintenanceNoticeInfo, error) {
var target []five9types.MaintenanceNoticeInfo
request, err := http.NewRequestWithContext(
ctx,
http.MethodGet,
"/appsvcs/rs/svc/agents/:userID/maintenance_notices",
http.NoBody,
)
if err != nil {
return nil, err
}
if err := s.authState.requestWithAuthentication(request, &target); err != nil {
return nil, err
}
return target, nil
}
func (s AgentService) AcceptMaintenanceNoticeForSelf(
ctx context.Context,
maintenanceNoticeID five9types.MaintenanceNoticeID,
) (five9types.MaintenanceNoticeInfo, error) {
var target five9types.MaintenanceNoticeInfo
request, err := http.NewRequestWithContext(
ctx,
http.MethodPut,
fmt.Sprintf(
"/appsvcs/rs/svc/agents/:userID/maintenance_notices/%s/accept",
maintenanceNoticeID,
),
http.NoBody,
)
if err != nil {
return five9types.MaintenanceNoticeInfo{}, err
}
if err := s.authState.requestWithAuthentication(request, &target); err != nil {
return five9types.MaintenanceNoticeInfo{}, err
}
return target, nil
}
func (s *AgentService) GetAllReasonCodes(ctx context.Context) ([]five9types.ReasonCodeInfo, error) {
logoutCodes, err := s.getAllLogoutReasonCodes(ctx)
if err != nil {
return nil, err
}
notReadyCodes, err := s.getAllNotReadyReasonCodes(ctx)
if err != nil {
return nil, err
}
return append(logoutCodes, notReadyCodes...), nil
}
func (s *AgentService) getAllLogoutReasonCodes(ctx context.Context) ([]five9types.ReasonCodeInfo, error) {
var target []five9types.ReasonCodeInfo
request, err := http.NewRequestWithContext(
ctx,
http.MethodGet,
"/appsvcs/rs/svc/orgs/:organizationID/logout_reason_codes",
http.NoBody,
)
if err != nil {
return nil, err
}
if err := s.authState.requestWithAuthentication(request, &target); err != nil {
return nil, err
}
return target, nil
}
func (s *AgentService) getAllNotReadyReasonCodes(ctx context.Context) ([]five9types.ReasonCodeInfo, error) {
var target []five9types.ReasonCodeInfo
request, err := http.NewRequestWithContext(
ctx,
http.MethodGet,
"/appsvcs/rs/svc/orgs/:organizationID/not_ready_reason_codes",
http.NoBody,
)
if err != nil {
return nil, err
}
if err := s.authState.requestWithAuthentication(request, &target); err != nil {
return nil, err
}
return target, nil
}