github.com/twilio/twilio-go@v1.20.1/rest/insights/v1/voice_annotation.go (about)

     1  /*
     2   * This code was generated by
     3   * ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
     4   *  |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
     5   *  |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \
     6   *
     7   * Twilio - Insights
     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  )
    23  
    24  // Get the Annotation for a specific Call.
    25  func (c *ApiService) FetchAnnotation(CallSid string) (*InsightsV1Annotation, error) {
    26  	path := "/v1/Voice/{CallSid}/Annotation"
    27  	path = strings.Replace(path, "{"+"CallSid"+"}", CallSid, -1)
    28  
    29  	data := url.Values{}
    30  	headers := make(map[string]interface{})
    31  
    32  	resp, err := c.requestHandler.Get(c.baseURL+path, data, headers)
    33  	if err != nil {
    34  		return nil, err
    35  	}
    36  
    37  	defer resp.Body.Close()
    38  
    39  	ps := &InsightsV1Annotation{}
    40  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
    41  		return nil, err
    42  	}
    43  
    44  	return ps, err
    45  }
    46  
    47  // Optional parameters for the method 'UpdateAnnotation'
    48  type UpdateAnnotationParams struct {
    49  	//
    50  	AnsweredBy *string `json:"AnsweredBy,omitempty"`
    51  	//
    52  	ConnectivityIssue *string `json:"ConnectivityIssue,omitempty"`
    53  	// Specify if the call had any subjective quality issues. Possible values, one or more of `no_quality_issue`, `low_volume`, `choppy_robotic`, `echo`, `dtmf`, `latency`, `owa`, `static_noise`. Use comma separated values to indicate multiple quality issues for the same call.
    54  	QualityIssues *string `json:"QualityIssues,omitempty"`
    55  	// A boolean flag to indicate if the call was a spam call. Use this to provide feedback on whether calls placed from your account were marked as spam, or if inbound calls received by your account were unwanted spam. Use `true` if the call was a spam call.
    56  	Spam *bool `json:"Spam,omitempty"`
    57  	// Specify the call score. This is of type integer. Use a range of 1-5 to indicate the call experience score, with the following mapping as a reference for rating the call [5: Excellent, 4: Good, 3 : Fair, 2 : Poor, 1: Bad].
    58  	CallScore *int `json:"CallScore,omitempty"`
    59  	// Specify any comments pertaining to the call. `comment` has a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in the `comment`.
    60  	Comment *string `json:"Comment,omitempty"`
    61  	// Associate this call with an incident or support ticket. The `incident` parameter is of type string with a maximum character limit of 100. Twilio does not treat this field as PII, so no PII should be included in `incident`.
    62  	Incident *string `json:"Incident,omitempty"`
    63  }
    64  
    65  func (params *UpdateAnnotationParams) SetAnsweredBy(AnsweredBy string) *UpdateAnnotationParams {
    66  	params.AnsweredBy = &AnsweredBy
    67  	return params
    68  }
    69  func (params *UpdateAnnotationParams) SetConnectivityIssue(ConnectivityIssue string) *UpdateAnnotationParams {
    70  	params.ConnectivityIssue = &ConnectivityIssue
    71  	return params
    72  }
    73  func (params *UpdateAnnotationParams) SetQualityIssues(QualityIssues string) *UpdateAnnotationParams {
    74  	params.QualityIssues = &QualityIssues
    75  	return params
    76  }
    77  func (params *UpdateAnnotationParams) SetSpam(Spam bool) *UpdateAnnotationParams {
    78  	params.Spam = &Spam
    79  	return params
    80  }
    81  func (params *UpdateAnnotationParams) SetCallScore(CallScore int) *UpdateAnnotationParams {
    82  	params.CallScore = &CallScore
    83  	return params
    84  }
    85  func (params *UpdateAnnotationParams) SetComment(Comment string) *UpdateAnnotationParams {
    86  	params.Comment = &Comment
    87  	return params
    88  }
    89  func (params *UpdateAnnotationParams) SetIncident(Incident string) *UpdateAnnotationParams {
    90  	params.Incident = &Incident
    91  	return params
    92  }
    93  
    94  // Update an Annotation for a specific Call.
    95  func (c *ApiService) UpdateAnnotation(CallSid string, params *UpdateAnnotationParams) (*InsightsV1Annotation, error) {
    96  	path := "/v1/Voice/{CallSid}/Annotation"
    97  	path = strings.Replace(path, "{"+"CallSid"+"}", CallSid, -1)
    98  
    99  	data := url.Values{}
   100  	headers := make(map[string]interface{})
   101  
   102  	if params != nil && params.AnsweredBy != nil {
   103  		data.Set("AnsweredBy", *params.AnsweredBy)
   104  	}
   105  	if params != nil && params.ConnectivityIssue != nil {
   106  		data.Set("ConnectivityIssue", *params.ConnectivityIssue)
   107  	}
   108  	if params != nil && params.QualityIssues != nil {
   109  		data.Set("QualityIssues", *params.QualityIssues)
   110  	}
   111  	if params != nil && params.Spam != nil {
   112  		data.Set("Spam", fmt.Sprint(*params.Spam))
   113  	}
   114  	if params != nil && params.CallScore != nil {
   115  		data.Set("CallScore", fmt.Sprint(*params.CallScore))
   116  	}
   117  	if params != nil && params.Comment != nil {
   118  		data.Set("Comment", *params.Comment)
   119  	}
   120  	if params != nil && params.Incident != nil {
   121  		data.Set("Incident", *params.Incident)
   122  	}
   123  
   124  	resp, err := c.requestHandler.Post(c.baseURL+path, data, headers)
   125  	if err != nil {
   126  		return nil, err
   127  	}
   128  
   129  	defer resp.Body.Close()
   130  
   131  	ps := &InsightsV1Annotation{}
   132  	if err := json.NewDecoder(resp.Body).Decode(ps); err != nil {
   133  		return nil, err
   134  	}
   135  
   136  	return ps, err
   137  }