/
api_op_fetch.go
70 lines (62 loc) · 2.85 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
// 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
}
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"`
}
// FetchCumulativeStatisticsResponse defines the response fields for the retrieved cumulative statistics
type FetchCumulativeStatisticsResponse struct {
AccountSid string `json:"account_sid"`
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"`
URL string `json:"url"`
WorkspaceSid string `json:"workspace_sid"`
}
// Fetch retrieves cumulative statistics
// See https://www.twilio.com/docs/taskrouter/api/worker/statistics#fetch-cumulative-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 *FetchCumulativeStatisticsOptions) (*FetchCumulativeStatisticsResponse, error) {
return c.FetchWithContext(context.Background(), options)
}
// FetchWithContext retrieves cumulative statistics
// See https://www.twilio.com/docs/taskrouter/api/worker/statistics#fetch-cumulative-worker-statistics for more details
func (c Client) FetchWithContext(context context.Context, options *FetchCumulativeStatisticsOptions) (*FetchCumulativeStatisticsResponse, error) {
op := client.Operation{
Method: http.MethodGet,
URI: "/Workspaces/{workspaceSid}/Workers/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
}