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

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview/understand/assistant/intent/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, intent_sid, sid) ⇒ SampleContext

Initialize the SampleContext

Parameters:

  • version (Version)

    Version that contains the resource

  • assistant_sid (String)

    The assistant_sid

  • intent_sid (String)

    The intent_sid

  • sid (String)

    The sid



199
200
201
202
203
204
205
# File 'lib/twilio-ruby/rest/preview/understand/assistant/intent/sample.rb', line 199

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

  # Path Solution
  @solution = {assistant_sid: assistant_sid, intent_sid: intent_sid, sid: sid, }
  @uri = "/Assistants/#{@solution[:assistant_sid]}/Intents/#{@solution[:intent_sid]}/Samples/#{@solution[:sid]}"
end

Instance Method Details

#deleteBoolean

Deletes the SampleInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



259
260
261
# File 'lib/twilio-ruby/rest/preview/understand/assistant/intent/sample.rb', line 259

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

#fetchSampleInstance

Fetch a SampleInstance

Returns:



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

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  SampleInstance.new(
      @version,
      payload,
      assistant_sid: @solution[:assistant_sid],
      intent_sid: @solution[:intent_sid],
      sid: @solution[:sid],
  )
end

#to_sObject

Provide a user friendly representation



265
266
267
268
# File 'lib/twilio-ruby/rest/preview/understand/assistant/intent/sample.rb', line 265

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)

    The language

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

    The tagged_text

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

    The source_channel

Returns:



234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/twilio-ruby/rest/preview/understand/assistant/intent/sample.rb', line 234

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],
      intent_sid: @solution[:intent_sid],
      sid: @solution[:sid],
  )
end