/
workspaces_workflows_cumulative_statistics.go
98 lines (87 loc) · 4.32 KB
/
workspaces_workflows_cumulative_statistics.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
/*
* This code was generated by
* ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
* | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
* | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
*
* Twilio - Taskrouter
* This is the public Twilio REST API.
*
* NOTE: This class is auto generated by OpenAPI Generator.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package openapi
import (
"encoding/json"
"fmt"
"net/url"
"strings"
"time"
)
// Optional parameters for the method 'FetchWorkflowCumulativeStatistics'
type FetchWorkflowCumulativeStatisticsParams struct {
// Only include usage that occurred on or before this date, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time.
EndDate *time.Time `json:"EndDate,omitempty"`
// Only calculate statistics since this many minutes in the past. The default 15 minutes. This is helpful for displaying statistics for the last 15 minutes, 240 minutes (4 hours), and 480 minutes (8 hours) to see trends.
Minutes *int `json:"Minutes,omitempty"`
// Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
StartDate *time.Time `json:"StartDate,omitempty"`
// Only calculate cumulative statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
TaskChannel *string `json:"TaskChannel,omitempty"`
// A comma separated list of values that describes the thresholds, in seconds, to calculate statistics on. For each threshold specified, the number of Tasks canceled and reservations accepted above and below the specified thresholds in seconds are computed. For example, `5,30` would show splits of Tasks that were canceled or accepted before and after 5 seconds and before and after 30 seconds. This can be used to show short abandoned Tasks or Tasks that failed to meet an SLA. TaskRouter will calculate statistics on up to 10,000 Tasks for any given threshold.
SplitByWaitTime *string `json:"SplitByWaitTime,omitempty"`
}
func (params *FetchWorkflowCumulativeStatisticsParams) SetEndDate(EndDate time.Time) *FetchWorkflowCumulativeStatisticsParams {
params.EndDate = &EndDate
return params
}
func (params *FetchWorkflowCumulativeStatisticsParams) SetMinutes(Minutes int) *FetchWorkflowCumulativeStatisticsParams {
params.Minutes = &Minutes
return params
}
func (params *FetchWorkflowCumulativeStatisticsParams) SetStartDate(StartDate time.Time) *FetchWorkflowCumulativeStatisticsParams {
params.StartDate = &StartDate
return params
}
func (params *FetchWorkflowCumulativeStatisticsParams) SetTaskChannel(TaskChannel string) *FetchWorkflowCumulativeStatisticsParams {
params.TaskChannel = &TaskChannel
return params
}
func (params *FetchWorkflowCumulativeStatisticsParams) SetSplitByWaitTime(SplitByWaitTime string) *FetchWorkflowCumulativeStatisticsParams {
params.SplitByWaitTime = &SplitByWaitTime
return params
}
//
func (c *ApiService) FetchWorkflowCumulativeStatistics(WorkspaceSid string, WorkflowSid string, params *FetchWorkflowCumulativeStatisticsParams) (*TaskrouterV1WorkflowCumulativeStatistics, error) {
path := "/v1/Workspaces/{WorkspaceSid}/Workflows/{WorkflowSid}/CumulativeStatistics"
path = strings.Replace(path, "{"+"WorkspaceSid"+"}", WorkspaceSid, -1)
path = strings.Replace(path, "{"+"WorkflowSid"+"}", WorkflowSid, -1)
data := url.Values{}
headers := make(map[string]interface{})
if params != nil && params.EndDate != nil {
data.Set("EndDate", fmt.Sprint((*params.EndDate).Format(time.RFC3339)))
}
if params != nil && params.Minutes != nil {
data.Set("Minutes", fmt.Sprint(*params.Minutes))
}
if params != nil && params.StartDate != nil {
data.Set("StartDate", fmt.Sprint((*params.StartDate).Format(time.RFC3339)))
}
if params != nil && params.TaskChannel != nil {
data.Set("TaskChannel", *params.TaskChannel)
}
if params != nil && params.SplitByWaitTime != nil {
data.Set("SplitByWaitTime", *params.SplitByWaitTime)
}
resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
if err != nil {
return nil, err
}
defer resp.Body.Close()
ps := &TaskrouterV1WorkflowCumulativeStatistics{}
if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
return nil, err
}
return ps, err
}