github.com/twilio/twilio-go@v1.20.1/rest/taskrouter/v1/workspaces_workflows_statistics.go (about) 1 /* 2 * This code was generated by 3 * ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ 4 * | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ 5 * | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ 6 * 7 * Twilio - Taskrouter 8 * This is the public Twilio REST API. 9 * 10 * NOTE: This class is auto generated by OpenAPI Generator. 11 * https://openapi-generator.tech 12 * Do not edit the class manually. 13 */ 14 15 package openapi 16 17 import ( 18 "encoding/json" 19 "fmt" 20 "net/url" 21 "strings" 22 "time" 23 ) 24 25 // Optional parameters for the method 'FetchWorkflowStatistics' 26 type FetchWorkflowStatisticsParams struct { 27 // 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. 28 Minutes *int `json:"Minutes,omitempty"` 29 // Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. 30 StartDate *time.Time `json:"StartDate,omitempty"` 31 // Only calculate statistics from this date and time and earlier, specified in GMT as an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date-time. 32 EndDate *time.Time `json:"EndDate,omitempty"` 33 // Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`. 34 TaskChannel *string `json:"TaskChannel,omitempty"` 35 // 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. 36 SplitByWaitTime *string `json:"SplitByWaitTime,omitempty"` 37 } 38 39 func (params *FetchWorkflowStatisticsParams) SetMinutes(Minutes int) *FetchWorkflowStatisticsParams { 40 params.Minutes = &Minutes 41 return params 42 } 43 func (params *FetchWorkflowStatisticsParams) SetStartDate(StartDate time.Time) *FetchWorkflowStatisticsParams { 44 params.StartDate = &StartDate 45 return params 46 } 47 func (params *FetchWorkflowStatisticsParams) SetEndDate(EndDate time.Time) *FetchWorkflowStatisticsParams { 48 params.EndDate = &EndDate 49 return params 50 } 51 func (params *FetchWorkflowStatisticsParams) SetTaskChannel(TaskChannel string) *FetchWorkflowStatisticsParams { 52 params.TaskChannel = &TaskChannel 53 return params 54 } 55 func (params *FetchWorkflowStatisticsParams) SetSplitByWaitTime(SplitByWaitTime string) *FetchWorkflowStatisticsParams { 56 params.SplitByWaitTime = &SplitByWaitTime 57 return params 58 } 59 60 // 61 func (c *ApiService) FetchWorkflowStatistics(WorkspaceSid string, WorkflowSid string, params *FetchWorkflowStatisticsParams) (*TaskrouterV1WorkflowStatistics, error) { 62 path := "/v1/Workspaces/{WorkspaceSid}/Workflows/{WorkflowSid}/Statistics" 63 path = strings.Replace(path, "{"+"WorkspaceSid"+"}", WorkspaceSid, -1) 64 path = strings.Replace(path, "{"+"WorkflowSid"+"}", WorkflowSid, -1) 65 66 data := url.Values{} 67 headers := make(map[string]interface{}) 68 69 if params != nil && params.Minutes != nil { 70 data.Set("Minutes", fmt.Sprint(*params.Minutes)) 71 } 72 if params != nil && params.StartDate != nil { 73 data.Set("StartDate", fmt.Sprint((*params.StartDate).Format(time.RFC3339))) 74 } 75 if params != nil && params.EndDate != nil { 76 data.Set("EndDate", fmt.Sprint((*params.EndDate).Format(time.RFC3339))) 77 } 78 if params != nil && params.TaskChannel != nil { 79 data.Set("TaskChannel", *params.TaskChannel) 80 } 81 if params != nil && params.SplitByWaitTime != nil { 82 data.Set("SplitByWaitTime", *params.SplitByWaitTime) 83 } 84 85 resp, err := c.requestHandler.Get(c.baseURL+path, data, headers) 86 if err != nil { 87 return nil, err 88 } 89 90 defer resp.Body.Close() 91 92 ps := &TaskrouterV1WorkflowStatistics{} 93 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 94 return nil, err 95 } 96 97 return ps, err 98 }