Class: Twilio::REST::Preview::Understand::AssistantContext::TaskContext::SampleContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview/understand/assistant/task/sample.rb

Overview

PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact [email protected].

Instance Method Summary collapse

Constructor Details

#initialize(version, assistant_sid, task_sid, sid) ⇒ SampleContext

Initialize the SampleContext

Parameters:

  • version (Version)

    Version that contains the resource

  • assistant_sid (String)

    The unique ID of the Assistant.

  • task_sid (String)

    The unique ID of the Task associated with this Sample.

  • sid (String)

    A 34 character string that uniquely identifies this resource.



172
173
174
175
176
177
178
179
180
# File 'lib/twilio-ruby/rest/preview/understand/assistant/task/sample.rb', line 172

def initialize(version, assistant_sid, task_sid, sid)
    super(version)

    # Path Solution
    @solution = { assistant_sid: assistant_sid, task_sid: task_sid, sid: sid,  }
    @uri = "/Assistants/#{@solution[:assistant_sid]}/Tasks/#{@solution[:task_sid]}/Samples/#{@solution[:sid]}"

    
end

Instance Method Details

#deleteBoolean

Delete the SampleInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



184
185
186
187
# File 'lib/twilio-ruby/rest/preview/understand/assistant/task/sample.rb', line 184

def delete

    @version.delete('DELETE', @uri)
end

#fetchSampleInstance

Fetch the SampleInstance

Returns:



192
193
194
195
196
197
198
199
200
201
202
# File 'lib/twilio-ruby/rest/preview/understand/assistant/task/sample.rb', line 192

def fetch

    payload = @version.fetch('GET', @uri)
    SampleInstance.new(
        @version,
        payload,
        assistant_sid: @solution[:assistant_sid],
        task_sid: @solution[:task_sid],
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



242
243
244
245
# File 'lib/twilio-ruby/rest/preview/understand/assistant/task/sample.rb', line 242

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

#to_sObject

Provide a user friendly representation



235
236
237
238
# File 'lib/twilio-ruby/rest/preview/understand/assistant/task/sample.rb', line 235

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

#update(language: :unset, tagged_text: :unset, source_channel: :unset) ⇒ SampleInstance

Update the SampleInstance

Parameters:

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

    An ISO language-country string of the sample.

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

    The text example of how end-users may express this task. The sample may contain Field tag blocks.

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

    The communication channel the sample was captured. It can be: voice, sms, chat, alexa, google-assistant, or slack. If not included the value will be null

Returns:



210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/twilio-ruby/rest/preview/understand/assistant/task/sample.rb', line 210

def update(
    language: :unset, 
    tagged_text: :unset, 
    source_channel: :unset
)

    data = Twilio::Values.of({
        'Language' => language,
        'TaggedText' => tagged_text,
        'SourceChannel' => source_channel,
    })

    payload = @version.update('POST', @uri, data: data)
    SampleInstance.new(
        @version,
        payload,
        assistant_sid: @solution[:assistant_sid],
        task_sid: @solution[:task_sid],
        sid: @solution[:sid],
    )
end