/
api_op_fetch.go
89 lines (78 loc) · 3.21 KB
/
api_op_fetch.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
// This is an autogenerated file. DO NOT MODIFY
package statistics
import (
"context"
"net/http"
"time"
"github.com/RJPearson94/twilio-sdk-go/client"
"github.com/RJPearson94/twilio-sdk-go/utils"
)
// FetchStatisticsOptions defines the query options for the api operation
type FetchStatisticsOptions struct {
Minutes *int
StartDate *time.Time
EndDate *time.Time
TaskChannel *string
TaskQueueSid *string
TaskQueueName *string
FriendlyName *string
}
type FetchActivityDuration struct {
Avg int `json:"avg"`
FriendlyName string `json:"friendly_name"`
Max int `json:"max"`
Min int `json:"min"`
Sid string `json:"sid"`
Total int `json:"total"`
}
type FetchActivityStatistic struct {
FriendlyName string `json:"friendly_name"`
Sid string `json:"sid"`
Workers int `json:"workers"`
}
type FetchCumulativeStatistics struct {
ActivityDurations []FetchActivityDuration `json:"activity_durations"`
EndTime time.Time `json:"end_time"`
ReservationsAccepted int `json:"reservations_accepted"`
ReservationsCanceled int `json:"reservations_canceled"`
ReservationsCreated int `json:"reservations_created"`
ReservationsRejected int `json:"reservations_rejected"`
ReservationsRescinded int `json:"reservations_rescinded"`
ReservationsTimedOut int `json:"reservations_timed_out"`
StartTime time.Time `json:"start_time"`
}
type FetchRealTimeStatistics struct {
ActivityStatistics []FetchActivityStatistic `json:"activity_statistics"`
TotalWorkers int `json:"total_workers"`
}
// FetchStatisticsResponse defines the response fields for the retrieved statistics
type FetchStatisticsResponse struct {
AccountSid string `json:"account_sid"`
Cumulative FetchCumulativeStatistics `json:"cumulative"`
RealTime FetchRealTimeStatistics `json:"realtime"`
URL string `json:"url"`
WorkspaceSid string `json:"workspace_sid"`
}
// Fetch retrieves statistics
// See https://www.twilio.com/docs/taskrouter/api/worker/statistics#fetch-all-worker-statistics for more details
// Context is defaulted to Background. See https://golang.org/pkg/context/#Background for more information
func (c Client) Fetch(options *FetchStatisticsOptions) (*FetchStatisticsResponse, error) {
return c.FetchWithContext(context.Background(), options)
}
// FetchWithContext retrieves statistics
// See https://www.twilio.com/docs/taskrouter/api/worker/statistics#fetch-all-worker-statistics for more details
func (c Client) FetchWithContext(context context.Context, options *FetchStatisticsOptions) (*FetchStatisticsResponse, error) {
op := client.Operation{
Method: http.MethodGet,
URI: "/Workspaces/{workspaceSid}/Workers/Statistics",
PathParams: map[string]string{
"workspaceSid": c.workspaceSid,
},
QueryParams: utils.StructToStringMap(options),
}
response := &FetchStatisticsResponse{}
if err := c.client.Send(context, op, nil, response); err != nil {
return nil, err
}
return response, nil
}