Class: Twilio::REST::Webhooks::V1::SettingList

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

Defined Under Namespace

Classes: InlineAuthValue, PatchSetting, PostAuthSetting, PostInlineAuthValue, PostSetting, RetryPolicy

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ SettingList

Initialize the SettingList

Parameters:

  • version (Version) —

    Version that contains the resource



334
335
336
337
338
339
340
341
342
# File 'lib/twilio-ruby/rest/webhooks/v1/setting.rb', line 334

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

Instance Method Details

#create(idempotency_key: :unset, post_setting: nil) ⇒ SettingInstance

Create the SettingInstance

Parameters:

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

    Idempotency key for mutation operations. Must be a UUIDv7 (other UUID versions are rejected with a 400).

  • post_setting (PostSetting) (defaults to: nil)

Returns:



348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# File 'lib/twilio-ruby/rest/webhooks/v1/setting.rb', line 348

def create(
  idempotency_key: :unset,
  post_setting: nil
)

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

#create_with_metadata(idempotency_key: :unset, post_setting: nil) ⇒ SettingInstance

Create the SettingInstanceMetadata

Parameters:

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

    Idempotency key for mutation operations. Must be a UUIDv7 (other UUID versions are rejected with a 400).

  • post_setting (PostSetting) (defaults to: nil)

Returns:



371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/twilio-ruby/rest/webhooks/v1/setting.rb', line 371

def (
  idempotency_key: :unset,
post_setting: nil
)

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

#each ⇒ Object

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



488
489
490
491
492
493
494
495
496
497
498
499
500
# File 'lib/twilio-ruby/rest/webhooks/v1/setting.rb', line 488

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

Parameters:

  • target_url (String) —

    API-generated URL for the requested results page

Returns:

  • (Page) —

    Page of SettingInstance



533
534
535
536
537
538
539
# File 'lib/twilio-ruby/rest/webhooks/v1/setting.rb', line 533

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

#list(page_token: :unset, auth_profile_id: :unset, shared_key_id: :unset, type: :unset, limit: nil, page_size: nil) ⇒ Array

Lists SettingInstance 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) —

    Token for pagination

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

    Filter Settings that reference this AuthProfile ID

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

    Filter Settings that reference this SharedKey ID

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

    Whether to list your own Settings or Twilio-managed system Settings. - CUSTOMER (default): Settings created by you - SYSTEM: Twilio-managed Settings, such as the account's default legacy configuration

  • 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



411
412
413
414
415
416
417
418
419
420
# File 'lib/twilio-ruby/rest/webhooks/v1/setting.rb', line 411

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

#list_with_metadata(page_token: :unset, auth_profile_id: :unset, shared_key_id: :unset, type: :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



467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
# File 'lib/twilio-ruby/rest/webhooks/v1/setting.rb', line 467

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

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

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

#page(page_token: :unset, auth_profile_id: :unset, shared_key_id: :unset, type: :unset, page_size: :unset) ⇒ Page

Returns Page of SettingInstance.

Returns:

  • (Page) —

    Page of SettingInstance



511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
# File 'lib/twilio-ruby/rest/webhooks/v1/setting.rb', line 511

def page(page_token: :unset, auth_profile_id: :unset, shared_key_id: :unset, type: :unset, page_size: :unset)
    params = Twilio::Values.of({
        'pageToken' => page_token,
        'authProfileId' => auth_profile_id,
        'sharedKeyId' => shared_key_id,
        'type' => type,
                                    'PageSize' => page_size,
    })
    headers = Twilio::Values.of({})
    
    

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

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

#stream(page_token: :unset, auth_profile_id: :unset, shared_key_id: :unset, type: :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) —

    Token for pagination

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

    Filter Settings that reference this AuthProfile ID

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

    Filter Settings that reference this SharedKey ID

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

    Whether to list your own Settings or Twilio-managed system Settings. - CUSTOMER (default): Settings created by you - SYSTEM: Twilio-managed Settings, such as the account's default legacy configuration

  • 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



437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# File 'lib/twilio-ruby/rest/webhooks/v1/setting.rb', line 437

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

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



544
545
546
# File 'lib/twilio-ruby/rest/webhooks/v1/setting.rb', line 544

def to_s
    '#<Twilio.Webhooks.V1.SettingList>'
end