Class: Twilio::REST::Insights::V3::CustomFieldMappingContext

Inherits:
Twilio::REST::InstanceContext show all
Defined in:
lib/twilio-ruby/rest/insights/v3/custom_field_mapping.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, mapping_id) ⇒ CustomFieldMappingContext

Initialize the CustomFieldMappingContext

Parameters:

  • version (Version) —

    Version that contains the resource

  • mapping_id (String) —

    The unique identifier of the custom field mapping, as returned in id when the mapping was created.



386
387
388
389
390
391
392
393
394
395
396
# File 'lib/twilio-ruby/rest/insights/v3/custom_field_mapping.rb', line 386

def initialize(version, mapping_id)
    
    apiV1Version = ApiV1Version.new version.domain, version
    super(apiV1Version)

    # Path Solution
    @solution = { mapping_id: mapping_id,  }
    @uri = "/ControlPlane/ConversationInsights/CustomFieldMappings/#{@solution[:mapping_id]}"

    
end

Instance Method Details

#fetch ⇒ CustomFieldMappingInstance

Fetch the CustomFieldMappingInstance

Returns:



400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
# File 'lib/twilio-ruby/rest/insights/v3/custom_field_mapping.rb', line 400

def fetch

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

#fetch_with_metadata ⇒ CustomFieldMappingInstance

Fetch the CustomFieldMappingInstanceMetadata

Returns:



419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/twilio-ruby/rest/insights/v3/custom_field_mapping.rb', line 419

def 

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

#inspect ⇒ Object

Provide a detailed, user friendly representation



505
506
507
508
# File 'lib/twilio-ruby/rest/insights/v3/custom_field_mapping.rb', line 505

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

#patch(if_match: :unset, custom_field_mapping_update_request: nil) ⇒ CustomFieldMappingInstance

Patch the CustomFieldMappingInstance

Parameters:

  • if_match (String) (defaults to: :unset) —

    ETag of the custom field mapping, as returned in the ETag response header. When supplied, the update is applied only if the mapping has not changed since that ETag was issued; otherwise 412 is returned.

  • custom_field_mapping_update_request (CustomFieldMappingUpdateRequest) (defaults to: nil)

Returns:



446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
# File 'lib/twilio-ruby/rest/insights/v3/custom_field_mapping.rb', line 446

def patch(
  if_match: :unset,
  custom_field_mapping_update_request: nil
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    payload = @version.patch('PATCH', @uri, headers: headers, data: custom_field_mapping_update_request.to_json)
    CustomFieldMappingInstance.new(
        @version,
        payload,
        mapping_id: @solution[:mapping_id],
    )
end

#patch_with_metadata(if_match: :unset, custom_field_mapping_update_request: nil) ⇒ CustomFieldMappingInstance

Patch the CustomFieldMappingInstanceMetadata

Parameters:

  • if_match (String) (defaults to: :unset) —

    ETag of the custom field mapping, as returned in the ETag response header. When supplied, the update is applied only if the mapping has not changed since that ETag was issued; otherwise 412 is returned.

  • custom_field_mapping_update_request (CustomFieldMappingUpdateRequest) (defaults to: nil)

Returns:



470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
# File 'lib/twilio-ruby/rest/insights/v3/custom_field_mapping.rb', line 470

def (
  if_match: :unset,
custom_field_mapping_update_request: nil
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    response = @version.('PATCH', @uri, headers: headers, data: custom_field_mapping_update_request.to_json)
    custom_field_mapping_instance = CustomFieldMappingInstance.new(
        @version,
        response.body,
        mapping_id: @solution[:mapping_id],
    )
    CustomFieldMappingInstanceMetadata.new(
        @version,
        custom_field_mapping_instance,
        response.headers,
        response.status_code
    )
end

#to_s ⇒ Object

Provide a user friendly representation



498
499
500
501
# File 'lib/twilio-ruby/rest/insights/v3/custom_field_mapping.rb', line 498

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