Class: Twilio::REST::Autopilot::V1::AssistantContext::FieldTypeContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/autopilot/v1/assistant/field_type.rb,
lib/twilio-ruby/rest/autopilot/v1/assistant/field_type/field_value.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: FieldValueContext, FieldValueInstance, FieldValueList, FieldValuePage

Instance Method Summary collapse

Constructor Details

#initialize(version, assistant_sid, sid) ⇒ FieldTypeContext

Initialize the FieldTypeContext

Parameters:

  • version (Version)

    Version that contains the resource

  • assistant_sid (String)

    The SID of the Assistant that is the parent of the resource to fetch.

  • sid (String)

    The Twilio-provided string that uniquely identifies the FieldType resource to fetch.


178
179
180
181
182
183
184
185
186
187
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/field_type.rb', line 178

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

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

  # Dependents
  @field_values = nil
end

Instance Method Details

#deleteBoolean

Delete the FieldTypeInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


227
228
229
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/field_type.rb', line 227

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

#fetchFieldTypeInstance

Fetch the FieldTypeInstance

Returns:


192
193
194
195
196
197
198
199
200
201
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/field_type.rb', line 192

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

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

#field_values(sid = :unset) ⇒ FieldValueList, FieldValueContext

Access the field_values

Returns:

Raises:

  • (ArgumentError)

235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/field_type.rb', line 235

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

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

  unless @field_values
    @field_values = FieldValueList.new(
        @version,
        assistant_sid: @solution[:assistant_sid],
        field_type_sid: @solution[:sid],
    )
  end

  @field_values
end

#inspectObject

Provide a detailed, user friendly representation


262
263
264
265
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/field_type.rb', line 262

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

#to_sObject

Provide a user friendly representation


255
256
257
258
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/field_type.rb', line 255

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

#update(friendly_name: :unset, unique_name: :unset) ⇒ FieldTypeInstance

Update the FieldTypeInstance

Parameters:

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

    A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.

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

    An application-defined string that uniquely identifies the resource. It can be used as an alternative to the `sid` in the URL path to address the resource. The first 64 characters must be unique.

Returns:


211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/field_type.rb', line 211

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

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

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