Class: Twilio::REST::Conversations::V2::ConfigurationList

Inherits:
ListResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/conversations/v2/configuration.rb

Defined Under Namespace

Classes: ConversationsV2CaptureRule, ConversationsV2StatusTimeouts, CreateConfigurationRequest, CreateConfigurationRequestChannelSettingsValue, CreateConfigurationRequestChannelSettingsValueCaptureRules, CreateConfigurationRequestChannelSettingsValueStatusTimeouts, CreateConfigurationRequestStatusCallbacks, UpdateConfigurationRequest, UpdateConfigurationRequestChannelSettingsValue, UpdateConfigurationRequestChannelSettingsValueCaptureRules, UpdateConfigurationRequestChannelSettingsValueStatusTimeouts, UpdateConfigurationRequestStatusCallbacks

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ ConfigurationList

Initialize the ConfigurationList

Parameters:

  • version (Version)

    Version that contains the resource



502
503
504
505
506
507
508
509
510
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 502

def initialize(version)
    
    apiV1Version = ApiV1Version.new version.domain, version
    super(apiV1Version)
    # Path Solution
    @solution = {  }
    @uri = "/ControlPlane/Configurations"
    
end

Instance Method Details

#create(idempotency_key: :unset, create_configuration_request: :unset) ⇒ ConfigurationInstance

Create the ConfigurationInstance

Parameters:

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

    Client-generated UUID key to ensure idempotent behavior. Submitting the same key returns the original response without creating a duplicate operation. Keys are scoped to account + region with a 24-hour TTL.

  • create_configuration_request (CreateConfigurationRequest) (defaults to: :unset)

    The configuration to create

Returns:



516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 516

def create(
  idempotency_key: :unset,
  create_configuration_request: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Idempotency-Key' => idempotency_key, })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    payload = @version.create('POST', @uri, headers: headers, data: create_configuration_request.to_json)
    ConfigurationInstance.new(
        @version,
        payload,
    )
end

#create_with_metadata(idempotency_key: :unset, create_configuration_request: :unset) ⇒ ConfigurationInstance

Create the ConfigurationInstanceMetadata

Parameters:

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

    Client-generated UUID key to ensure idempotent behavior. Submitting the same key returns the original response without creating a duplicate operation. Keys are scoped to account + region with a 24-hour TTL.

  • create_configuration_request (CreateConfigurationRequest) (defaults to: :unset)

    The configuration to create

Returns:



539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 539

def (
  idempotency_key: :unset,
create_configuration_request: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Idempotency-Key' => idempotency_key, })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    response = @version.('POST', @uri, headers: headers, data: create_configuration_request.to_json)
    configuration_instance = ConfigurationInstance.new(
        @version,
        response.body,
    )
    ConfigurationInstanceMetadata.new(
        @version,
        configuration_instance,
        response.headers,
        response.status_code
    )
end

#eachObject

When passed a block, yields ConfigurationInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.



644
645
646
647
648
649
650
651
652
653
654
655
656
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 644

def each
    limits = @version.read_limits

    page = self.page(page_size: limits[:page_size], )

    return [].each if page.nil?

    result = @version.stream(page,
        limit: limits[:limit],
        page_limit: limits[:page_limit])
    return [].each if result.nil?
    result.each {|x| yield x}
end

#get_page(target_url) ⇒ Page

Retrieve a single page of ConfigurationInstance records from the API. Request is executed immediately.

Parameters:

  • target_url (String)

    API-generated URL for the requested results page

Returns:

  • (Page)

    Page of ConfigurationInstance



685
686
687
688
689
690
691
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 685

def get_page(target_url)
    response = @version.domain.request(
        'GET',
        target_url
    )
ConfigurationPage.new(@version, response, @solution)
end

#list(page_token: :unset, memory_store_id: :unset, limit: nil, page_size: nil) ⇒ Array

Lists ConfigurationInstance records from the API as a list. Unlike stream(), this operation is eager and will load ‘limit` records into memory before returning.

Parameters:

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

    A URL-safe, base64-encoded token representing the page of results to return

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

    Filter configurations by Memory Store ID

  • limit (Integer) (defaults to: nil)

    Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit

  • page_size (Integer) (defaults to: nil)

    Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)

Returns:

  • (Array)

    Array of up to limit results



577
578
579
580
581
582
583
584
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 577

def list(page_token: :unset, memory_store_id: :unset, limit: nil, page_size: nil)
    self.stream(
        page_token: page_token,
        memory_store_id: memory_store_id,
        limit: limit,
        page_size: page_size
    ).entries
end

#list_with_metadata(page_token: :unset, memory_store_id: :unset, limit: nil, page_size: nil) ⇒ Array

Returns Array of up to limit results.

Parameters:

  • limit (Integer) (defaults to: nil)

    Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit

  • page_size (Integer) (defaults to: nil)

    Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)

Returns:

  • (Array)

    Array of up to limit results



625
626
627
628
629
630
631
632
633
634
635
636
637
638
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 625

def (page_token: :unset, memory_store_id: :unset, limit: nil, page_size: nil)
    limits = @version.read_limits(limit, page_size)
    params = Twilio::Values.of({
        'pageToken' => page_token,
        'memoryStoreId' => memory_store_id,
        
        'PageSize' => limits[:page_size],
    });
    headers = Twilio::Values.of({})

    response = @version.page('GET', @uri, params: params, headers: headers)

    ConfigurationPageMetadata.new(@version, response, @solution, limits[:limit])
end

#page(page_token: :unset, memory_store_id: :unset, page_size: :unset) ⇒ Page

Returns Page of ConfigurationInstance.

Returns:

  • (Page)

    Page of ConfigurationInstance



665
666
667
668
669
670
671
672
673
674
675
676
677
678
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 665

def page(page_token: :unset, memory_store_id: :unset, page_size: :unset)
    params = Twilio::Values.of({
        'pageToken' => page_token,
        'memoryStoreId' => memory_store_id,
                                    'PageSize' => page_size,
    })
    headers = Twilio::Values.of({})
    
    

    response = @version.page('GET', @uri, params: params, headers: headers)

    ConfigurationPage.new(@version, response, @solution)
end

#stream(page_token: :unset, memory_store_id: :unset, limit: nil, page_size: nil) ⇒ Enumerable

Streams Instance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached.

Parameters:

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

    A URL-safe, base64-encoded token representing the page of results to return

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

    Filter configurations by Memory Store ID

  • limit (Integer) (defaults to: nil)

    Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit

  • page_size (Integer) (defaults to: nil)

    Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)

Returns:

  • (Enumerable)

    Enumerable that will yield up to limit results



599
600
601
602
603
604
605
606
607
608
609
610
611
612
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 599

def stream(page_token: :unset, memory_store_id: :unset, limit: nil, page_size: nil)
    limits = @version.read_limits(limit, page_size)

    page = self.page(
        page_token: page_token,
        memory_store_id: memory_store_id,
        page_size: limits[:page_size], )

    return [].each if page.nil?

    result = @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
    return [].each if result.nil?
    result
end

#to_sObject

Provide a user friendly representation



696
697
698
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 696

def to_s
    '#<Twilio.Conversations.V2.ConfigurationList>'
end