github.com/twilio/twilio-go@v1.20.1/rest/taskrouter/v1/workspaces_workflows_real_time_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  	"net/url"
    20  	"strings"
    21  )
    22  
    23  // Optional parameters for the method 'FetchWorkflowRealTimeStatistics'
    24  type FetchWorkflowRealTimeStatisticsParams struct {
    25  	// Only calculate real-time statistics on this TaskChannel. Can be the TaskChannel's SID or its `unique_name`, such as `voice`, `sms`, or `default`.
    26  	TaskChannel *string `json:"TaskChannel,omitempty"`
    27  }
    28  
    29  func (params *FetchWorkflowRealTimeStatisticsParams) SetTaskChannel(TaskChannel string) *FetchWorkflowRealTimeStatisticsParams {
    30  	params.TaskChannel = &TaskChannel
    31  	return params
    32  }
    33  
    34  //
    35  func (c *ApiService) FetchWorkflowRealTimeStatistics(WorkspaceSid string, WorkflowSid string, params *FetchWorkflowRealTimeStatisticsParams) (*TaskrouterV1WorkflowRealTimeStatistics, error) {
    36  	path := "/v1/Workspaces/{WorkspaceSid}/Workflows/{WorkflowSid}/RealTimeStatistics"
    37  	path = strings.Replace(path, "{"+"WorkspaceSid"+"}", WorkspaceSid, -1)
    38  	path = strings.Replace(path, "{"+"WorkflowSid"+"}", WorkflowSid, -1)
    39  
    40  	data := url.Values{}
    41  	headers := make(map[string]interface{})
    42  
    43  	if params != nil && params.TaskChannel != nil {
    44  		data.Set("TaskChannel", *params.TaskChannel)
    45  	}
    46  
    47  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
    48  	if err != nil {
    49  		return nil, err
    50  	}
    51  
    52  	defer resp.Body.Close()
    53  
    54  	ps := &TaskrouterV1WorkflowRealTimeStatistics{}
    55  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    56  		return nil, err
    57  	}
    58  
    59  	return ps, err
    60  }