github.com/twilio/twilio-go@v1.20.1/rest/taskrouter/v1/workspaces_task_queues_cumulative_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 'FetchTaskQueueCumulativeStatistics' 26 type FetchTaskQueueCumulativeStatisticsParams struct { 27 // 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. 28 EndDate *time.Time `json:"EndDate,omitempty"` 29 // Only calculate statistics since this many minutes in the past. The default is 15 minutes. 30 Minutes *int `json:"Minutes,omitempty"` 31 // Only calculate statistics from this date and time and later, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. 32 StartDate *time.Time `json:"StartDate,omitempty"` 33 // Only calculate cumulative 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. TaskRouter will calculate statistics on up to 10,000 Tasks/Reservations for any given threshold. 36 SplitByWaitTime *string `json:"SplitByWaitTime,omitempty"` 37 } 38 39 func (params *FetchTaskQueueCumulativeStatisticsParams) SetEndDate(EndDate time.Time) *FetchTaskQueueCumulativeStatisticsParams { 40 params.EndDate = &EndDate 41 return params 42 } 43 func (params *FetchTaskQueueCumulativeStatisticsParams) SetMinutes(Minutes int) *FetchTaskQueueCumulativeStatisticsParams { 44 params.Minutes = &Minutes 45 return params 46 } 47 func (params *FetchTaskQueueCumulativeStatisticsParams) SetStartDate(StartDate time.Time) *FetchTaskQueueCumulativeStatisticsParams { 48 params.StartDate = &StartDate 49 return params 50 } 51 func (params *FetchTaskQueueCumulativeStatisticsParams) SetTaskChannel(TaskChannel string) *FetchTaskQueueCumulativeStatisticsParams { 52 params.TaskChannel = &TaskChannel 53 return params 54 } 55 func (params *FetchTaskQueueCumulativeStatisticsParams) SetSplitByWaitTime(SplitByWaitTime string) *FetchTaskQueueCumulativeStatisticsParams { 56 params.SplitByWaitTime = &SplitByWaitTime 57 return params 58 } 59 60 // 61 func (c *ApiService) FetchTaskQueueCumulativeStatistics(WorkspaceSid string, TaskQueueSid string, params *FetchTaskQueueCumulativeStatisticsParams) (*TaskrouterV1TaskQueueCumulativeStatistics, error) { 62 path := "/v1/Workspaces/{WorkspaceSid}/TaskQueues/{TaskQueueSid}/CumulativeStatistics" 63 path = strings.Replace(path, "{"+"WorkspaceSid"+"}", WorkspaceSid, -1) 64 path = strings.Replace(path, "{"+"TaskQueueSid"+"}", TaskQueueSid, -1) 65 66 data := url.Values{} 67 headers := make(map[string]interface{}) 68 69 if params != nil && params.EndDate != nil { 70 data.Set("EndDate", fmt.Sprint((*params.EndDate).Format(time.RFC3339))) 71 } 72 if params != nil && params.Minutes != nil { 73 data.Set("Minutes", fmt.Sprint(*params.Minutes)) 74 } 75 if params != nil && params.StartDate != nil { 76 data.Set("StartDate", fmt.Sprint((*params.StartDate).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 := &TaskrouterV1TaskQueueCumulativeStatistics{} 93 if err := json.NewDecoder(resp.Body).Decode(ps); err != nil { 94 return nil, err 95 } 96 97 return ps, err 98 }