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

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview/understand/assistant/intent.rb,
lib/twilio-ruby/rest/preview/understand/assistant/intent/field.rb,
lib/twilio-ruby/rest/preview/understand/assistant/intent/sample.rb,
lib/twilio-ruby/rest/preview/understand/assistant/intent/intent_actions.rb,
lib/twilio-ruby/rest/preview/understand/assistant/intent/intent_statistics.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].

Defined Under Namespace

Classes: FieldContext, FieldInstance, FieldList, FieldPage, IntentActionsContext, IntentActionsInstance, IntentActionsList, IntentActionsPage, IntentStatisticsContext, IntentStatisticsInstance, IntentStatisticsList, IntentStatisticsPage, SampleContext, SampleInstance, SampleList, SamplePage

Instance Method Summary collapse

Constructor Details

#initialize(version, assistant_sid, sid) ⇒ IntentContext

Initialize the IntentContext

Parameters:

  • version (Version)

    Version that contains the resource

  • assistant_sid (String)

    The assistant_sid

  • sid (String)

    The sid



184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/twilio-ruby/rest/preview/understand/assistant/intent.rb', line 184

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

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

  # Dependents
  @fields = nil
  @samples = nil
  @intent_actions = nil
  @statistics = nil
end

Instance Method Details

#deleteBoolean

Deletes the IntentInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



250
251
252
# File 'lib/twilio-ruby/rest/preview/understand/assistant/intent.rb', line 250

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

#fetchIntentInstance

Fetch a IntentInstance

Returns:



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/twilio-ruby/rest/preview/understand/assistant/intent.rb', line 201

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

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

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

#fields(sid = :unset) ⇒ FieldList, FieldContext

Access the fields

Returns:

Raises:

  • (ArgumentError)


258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/twilio-ruby/rest/preview/understand/assistant/intent.rb', line 258

def fields(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return FieldContext.new(@version, @solution[:assistant_sid], @solution[:sid], sid, )
  end

  unless @fields
    @fields = FieldList.new(
        @version,
        assistant_sid: @solution[:assistant_sid],
        intent_sid: @solution[:sid],
    )
  end

  @fields
end

#intent_actionsIntentActionsList, IntentActionsContext

Access the intent_actions



302
303
304
# File 'lib/twilio-ruby/rest/preview/understand/assistant/intent.rb', line 302

def intent_actions
  IntentActionsContext.new(@version, @solution[:assistant_sid], @solution[:sid], )
end

#samples(sid = :unset) ⇒ SampleList, SampleContext

Access the samples

Returns:

Raises:

  • (ArgumentError)


280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/twilio-ruby/rest/preview/understand/assistant/intent.rb', line 280

def samples(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return SampleContext.new(@version, @solution[:assistant_sid], @solution[:sid], sid, )
  end

  unless @samples
    @samples = SampleList.new(
        @version,
        assistant_sid: @solution[:assistant_sid],
        intent_sid: @solution[:sid],
    )
  end

  @samples
end

#statisticsIntentStatisticsList, IntentStatisticsContext

Access the statistics



310
311
312
# File 'lib/twilio-ruby/rest/preview/understand/assistant/intent.rb', line 310

def statistics
  IntentStatisticsContext.new(@version, @solution[:assistant_sid], @solution[:sid], )
end

#to_sObject

Provide a user friendly representation



316
317
318
319
# File 'lib/twilio-ruby/rest/preview/understand/assistant/intent.rb', line 316

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

#update(friendly_name: :unset, unique_name: :unset, actions: :unset) ⇒ IntentInstance

Update the IntentInstance

Parameters:

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

    A user-provided string that identifies this resource. It is non-unique and can up to 255 characters long.

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

    A user-provided string that uniquely identifies this resource as an alternative to the sid. Unique up to 64 characters long.

  • actions (Hash) (defaults to: :unset)

    The actions

Returns:



226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/twilio-ruby/rest/preview/understand/assistant/intent.rb', line 226

def update(friendly_name: :unset, unique_name: :unset, actions: :unset)
  data = Twilio::Values.of({
      'FriendlyName' => friendly_name,
      'UniqueName' => unique_name,
      'Actions' => Twilio.serialize_object(actions),
  })

  payload = @version.update(
      'POST',
      @uri,
      data: data,
  )

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