/
api_op_fetch.go
91 lines (81 loc) · 4.08 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
90
91
// Package cumulative_statistics contains auto-generated files. DO NOT MODIFY
package cumulative_statistics
import (
"context"
"net/http"
"time"
"github.com/RJPearson94/twilio-sdk-go/client"
"github.com/RJPearson94/twilio-sdk-go/utils"
)
// FetchCumulativeStatisticsOptions defines the query options for the api operation
type FetchCumulativeStatisticsOptions struct {
Minutes *int
StartDate *time.Time
EndDate *time.Time
TaskChannel *string
SplitByWaitTime *string
}
type FetchStatisticsBreakdown struct {
Avg int `json:"avg"`
Max int `json:"max"`
Min int `json:"min"`
Total int `json:"total"`
}
type FetchWaitTime struct {
Above FetchWaitTimeTasks `json:"above"`
Below FetchWaitTimeTasks `json:"below"`
}
type FetchWaitTimeTasks struct {
ReservationsAccepted int `json:"reservations_accepted"`
TasksCanceled int `json:"tasks_canceled"`
}
// FetchCumulativeStatisticsResponse defines the response fields for the retrieved cumulative statistics
type FetchCumulativeStatisticsResponse struct {
AccountSid string `json:"account_sid"`
AvgTaskAcceptanceTime int `json:"avg_task_acceptance_time"`
EndTime time.Time `json:"end_time"`
ReservationsAccepted int `json:"reservations_accepted"`
ReservationsCanceled int `json:"reservations_canceled"`
ReservationsCompleted *int `json:"reservations_completed,omitempty"`
ReservationsCreated int `json:"reservations_created"`
ReservationsRejected int `json:"reservations_rejected"`
ReservationsRescinded int `json:"reservations_rescinded"`
ReservationsTimedOut int `json:"reservations_timed_out"`
ReservationsWrapUp int `json:"reservations_wrapup"`
SplitByWaitTime *map[string]FetchWaitTime `json:"split_by_wait_time,omitempty"`
StartTime time.Time `json:"start_time"`
TasksAssigned *int `json:"tasks_assigned,omitempty"`
TasksCanceled int `json:"tasks_canceled"`
TasksCompleted int `json:"tasks_completed"`
TasksCreated int `json:"tasks_created"`
TasksDeleted int `json:"tasks_deleted"`
TasksMoved int `json:"tasks_moved"`
TasksTimedOutInWorkflow int `json:"tasks_timed_out_in_workflow"`
URL string `json:"url"`
WaitDurationUntilAccepted FetchStatisticsBreakdown `json:"wait_duration_until_accepted"`
WaitDurationUntilCanceled FetchStatisticsBreakdown `json:"wait_duration_until_canceled"`
WorkspaceSid string `json:"workspace_sid"`
}
// Fetch retrieves cumulative statistics
// See https://www.twilio.com/docs/taskrouter/api/workspace-statistics#workspace-cumulative-statistics for more details
// Context is defaulted to Background. See https://golang.org/pkg/context/#Background for more information
func (c Client) Fetch(options *FetchCumulativeStatisticsOptions) (*FetchCumulativeStatisticsResponse, error) {
return c.FetchWithContext(context.Background(), options)
}
// FetchWithContext retrieves cumulative statistics
// See https://www.twilio.com/docs/taskrouter/api/workspace-statistics#workspace-cumulative-statistics for more details
func (c Client) FetchWithContext(context context.Context, options *FetchCumulativeStatisticsOptions) (*FetchCumulativeStatisticsResponse, error) {
op := client.Operation{
Method: http.MethodGet,
URI: "/Workspaces/{workspaceSid}/CumulativeStatistics",
PathParams: map[string]string{
"workspaceSid": c.workspaceSid,
},
QueryParams: utils.StructToURLValues(options),
}
response := &FetchCumulativeStatisticsResponse{}
if err := c.client.Send(context, op, nil, response); err != nil {
return nil, err
}
return response, nil
}