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, PatchConfigurationRequest, PatchConfigurationRequestChannelSettingsValue, PatchConfigurationRequestConversationsV1Bridge, 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



995
996
997
998
999
1000
1001
1002
1003
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 995

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:



1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 1009

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:



1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 1032

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

#each ⇒ Object

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



1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 1137

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



1178
1179
1180
1181
1182
1183
1184
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 1178

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



1070
1071
1072
1073
1074
1075
1076
1077
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 1070

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



1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 1118

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



1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 1158

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



1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 1092

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_s ⇒ Object

Provide a user friendly representation



1189
1190
1191
# File 'lib/twilio-ruby/rest/conversations/v2/configuration.rb', line 1189

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