Class: Twilio::REST::Memory::V1::ConversationSummaryList

Inherits:
ListResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/memory/v1/conversation_summary.rb

Defined Under Namespace

Classes: CreateSummariesRequest, SummaryCore, SummaryCorePatch

Instance Method Summary collapse

Constructor Details

#initialize(version, store_id: nil, profile_id: nil) ⇒ ConversationSummaryList

Initialize the ConversationSummaryList

Parameters:

  • version (Version)

    Version that contains the resource



142
143
144
145
146
147
148
149
150
# File 'lib/twilio-ruby/rest/memory/v1/conversation_summary.rb', line 142

def initialize(version, store_id: nil, profile_id: nil)
    
    apiV1Version = ApiV1Version.new version.domain, version
    super(apiV1Version)
    # Path Solution
    @solution = { store_id: store_id, profile_id: profile_id }
    @uri = "/Stores/#{@solution[:store_id]}/Profiles/#{@solution[:profile_id]}/ConversationSummaries"
    
end

Instance Method Details

#create(accept_encoding: :unset, content_encoding: :unset, create_summaries_request: nil) ⇒ ConversationSummaryInstance

Create the ConversationSummaryInstance

Parameters:

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

    Compression algorithms supported by the client (e.g., gzip, deflate, br)

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

    Compression algorithm used for the request body (e.g., gzip, deflate, br)

  • create_summaries_request (CreateSummariesRequest) (defaults to: nil)

Returns:



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/twilio-ruby/rest/memory/v1/conversation_summary.rb', line 157

def create(
  accept_encoding: :unset, 
  content_encoding: :unset,
  create_summaries_request: nil
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Accept-Encoding' => accept_encoding, 'Content-Encoding' => content_encoding, })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    payload = @version.create('POST', @uri, headers: headers, data: create_summaries_request.to_json)
    ConversationSummaryInstance.new(
        @version,
        payload,
        store_id: @solution[:store_id],
        profile_id: @solution[:profile_id],
    )
end

#create_with_metadata(accept_encoding: :unset, content_encoding: :unset, create_summaries_request: nil) ⇒ ConversationSummaryInstance

Create the ConversationSummaryInstanceMetadata

Parameters:

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

    Compression algorithms supported by the client (e.g., gzip, deflate, br)

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

    Compression algorithm used for the request body (e.g., gzip, deflate, br)

  • create_summaries_request (CreateSummariesRequest) (defaults to: nil)

Returns:



184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/twilio-ruby/rest/memory/v1/conversation_summary.rb', line 184

def (
  accept_encoding: :unset, 
  content_encoding: :unset,
create_summaries_request: nil
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Accept-Encoding' => accept_encoding, 'Content-Encoding' => content_encoding, })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    response = @version.('POST', @uri, headers: headers, data: create_summaries_request.to_json)
    conversation_summary_instance = ConversationSummaryInstance.new(
        @version,
        response.body,
        store_id: @solution[:store_id],
        profile_id: @solution[:profile_id],
    )
    ConversationSummaryInstanceMetadata.new(
        @version,
        conversation_summary_instance,
        response.headers,
        response.status_code
    )
end

#eachObject

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



292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/twilio-ruby/rest/memory/v1/conversation_summary.rb', line 292

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 ConversationSummaryInstance records from the API. Request is executed immediately.

Parameters:

  • target_url (String)

    API-generated URL for the requested results page

Returns:

  • (Page)

    Page of ConversationSummaryInstance



333
334
335
336
337
338
339
# File 'lib/twilio-ruby/rest/memory/v1/conversation_summary.rb', line 333

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

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

Lists ConversationSummaryInstance 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)

    The token for the page of results to retrieve.

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

    Compression algorithms supported by the client (e.g., gzip, deflate, br)

  • 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



225
226
227
228
229
230
231
232
# File 'lib/twilio-ruby/rest/memory/v1/conversation_summary.rb', line 225

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

#list_with_metadata(page_token: :unset, accept_encoding: :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



273
274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/twilio-ruby/rest/memory/v1/conversation_summary.rb', line 273

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

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

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

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

Returns Page of ConversationSummaryInstance.

Returns:

  • (Page)

    Page of ConversationSummaryInstance



313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/twilio-ruby/rest/memory/v1/conversation_summary.rb', line 313

def page(page_token: :unset, accept_encoding: :unset, page_size: :unset)
    params = Twilio::Values.of({
        'pageToken' => page_token,
        'Accept-Encoding' => accept_encoding,
                                    'PageSize' => page_size,
    })
    headers = Twilio::Values.of({})
    
    

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

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

#stream(page_token: :unset, accept_encoding: :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)

    The token for the page of results to retrieve.

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

    Compression algorithms supported by the client (e.g., gzip, deflate, br)

  • 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



247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/twilio-ruby/rest/memory/v1/conversation_summary.rb', line 247

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

    page = self.page(
        page_token: page_token,
        accept_encoding: accept_encoding,
        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



344
345
346
# File 'lib/twilio-ruby/rest/memory/v1/conversation_summary.rb', line 344

def to_s
    '#<Twilio.Memory.V1.ConversationSummaryList>'
end