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, CreateConfigurationRequestConversationsV1Bridge, 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



540
541
542
543
544
545
546
547
548
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 540

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:



554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 554

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:



577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 577

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.



682
683
684
685
686
687
688
689
690
691
692
693
694
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 682

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



723
724
725
726
727
728
729
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 723

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



615
616
617
618
619
620
621
622
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 615

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



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

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



703
704
705
706
707
708
709
710
711
712
713
714
715
716
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 703

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



637
638
639
640
641
642
643
644
645
646
647
648
649
650
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 637

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



734
735
736
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 734

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