Class: Twilio::REST::Insights::V1::CallContext::AnnotationContext

Inherits:
Twilio::REST::InstanceContext show all
Defined in:
lib/twilio-ruby/rest/insights/v1/call/annotation.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, call_sid) ⇒ AnnotationContext

Initialize the AnnotationContext

Parameters:

  • version (Version)

    Version that contains the resource

  • call_sid (String)

    The unique string that Twilio created to identify this Call resource. It always starts with a CA.



52
53
54
55
56
57
58
59
60
61
# File 'lib/twilio-ruby/rest/insights/v1/call/annotation.rb', line 52

def initialize(version, call_sid)
    super(version)
    

    # Path Solution
    @solution = { call_sid: call_sid,  }
    @uri = "/Voice/#{@solution[:call_sid]}/Annotation"

    
end

Instance Method Details

#fetchAnnotationInstance

Fetch the AnnotationInstance

Returns:



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/twilio-ruby/rest/insights/v1/call/annotation.rb', line 65

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    AnnotationInstance.new(
        @version,
        payload,
        call_sid: @solution[:call_sid],
    )
end

#fetch_with_metadataAnnotationInstance

Fetch the AnnotationInstanceMetadata

Returns:



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/twilio-ruby/rest/insights/v1/call/annotation.rb', line 84

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    annotation_instance = AnnotationInstance.new(
        @version,
        response.body,
        call_sid: @solution[:call_sid],
    )
    AnnotationInstanceMetadata.new(
        @version,
        annotation_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



210
211
212
213
# File 'lib/twilio-ruby/rest/insights/v1/call/annotation.rb', line 210

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Insights.V1.AnnotationContext #{context}>"
end

#to_sObject

Provide a user friendly representation



203
204
205
206
# File 'lib/twilio-ruby/rest/insights/v1/call/annotation.rb', line 203

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Insights.V1.AnnotationContext #{context}>"
end

#update(answered_by: :unset, connectivity_issue: :unset, quality_issues: :unset, spam: :unset, call_score: :unset, comment: :unset, incident: :unset) ⇒ AnnotationInstance

Update the AnnotationInstance

Parameters:

  • answered_by (AnsweredBy) (defaults to: :unset)
  • connectivity_issue (ConnectivityIssue) (defaults to: :unset)
  • quality_issues (String) (defaults to: :unset)

    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.

  • spam (Boolean) (defaults to: :unset)

    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.

  • call_score (String) (defaults to: :unset)

    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].

  • comment (String) (defaults to: :unset)

    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.

  • incident (String) (defaults to: :unset)

    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.

Returns:



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/twilio-ruby/rest/insights/v1/call/annotation.rb', line 116

def update(
    answered_by: :unset, 
    connectivity_issue: :unset, 
    quality_issues: :unset, 
    spam: :unset, 
    call_score: :unset, 
    comment: :unset, 
    incident: :unset
)

    data = Twilio::Values.of({
        'AnsweredBy' => answered_by,
        'ConnectivityIssue' => connectivity_issue,
        'QualityIssues' => quality_issues,
        'Spam' => spam,
        'CallScore' => call_score,
        'Comment' => comment,
        'Incident' => incident,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    AnnotationInstance.new(
        @version,
        payload,
        call_sid: @solution[:call_sid],
    )
end

#update_with_metadata(answered_by: :unset, connectivity_issue: :unset, quality_issues: :unset, spam: :unset, call_score: :unset, comment: :unset, incident: :unset) ⇒ AnnotationInstance

Update the AnnotationInstanceMetadata

Parameters:

  • answered_by (AnsweredBy) (defaults to: :unset)
  • connectivity_issue (ConnectivityIssue) (defaults to: :unset)
  • quality_issues (String) (defaults to: :unset)

    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.

  • spam (Boolean) (defaults to: :unset)

    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.

  • call_score (String) (defaults to: :unset)

    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].

  • comment (String) (defaults to: :unset)

    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.

  • incident (String) (defaults to: :unset)

    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.

Returns:



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/twilio-ruby/rest/insights/v1/call/annotation.rb', line 160

def (
  answered_by: :unset, 
  connectivity_issue: :unset, 
  quality_issues: :unset, 
  spam: :unset, 
  call_score: :unset, 
  comment: :unset, 
  incident: :unset
)

    data = Twilio::Values.of({
        'AnsweredBy' => answered_by,
        'ConnectivityIssue' => connectivity_issue,
        'QualityIssues' => quality_issues,
        'Spam' => spam,
        'CallScore' => call_score,
        'Comment' => comment,
        'Incident' => incident,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    annotation_instance = AnnotationInstance.new(
        @version,
        response.body,
        call_sid: @solution[:call_sid],
    )
    AnnotationInstanceMetadata.new(
        @version,
        annotation_instance,
        response.headers,
        response.status_code
    )
end