class Twilio::REST::Verify::V2::ServiceContext::WebhookList

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Public Class Methods

new(version, service_sid: nil) click to toggle source

Initialize the WebhookList @param [Version] version Version that contains the resource @param [String] service_sid The unique SID identifier of the Service. @return [WebhookList] WebhookList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/verify/v2/service/webhook.rb
22 def initialize(version, service_sid: nil)
23   super(version)
24 
25   # Path Solution
26   @solution = {service_sid: service_sid}
27   @uri = "/Services/#{@solution[:service_sid]}/Webhooks"
28 end

Public Instance Methods

create(friendly_name: nil, event_types: nil, webhook_url: nil, status: :unset, version: :unset) click to toggle source

Create the WebhookInstance @param [String] friendly_name The string that you assigned to describe the

webhook. **This value should not contain PII.**

@param [Array] event_types The array of events that this Webhook is

subscribed to. Possible event types: `*, factor.deleted, factor.created,
factor.verified, challenge.approved, challenge.denied`

@param [String] webhook_url The URL associated with this Webhook. @param [webhook.Status] status The webhook status. Default value is `enabled`.

One of: `enabled` or `disabled`

@param [webhook.Version] version The webhook version. Default value is `v2`

which includes all the latest fields. Version `v1` is legacy and may be removed
in the future.

@return [WebhookInstance] Created WebhookInstance

   # File lib/twilio-ruby/rest/verify/v2/service/webhook.rb
44 def create(friendly_name: nil, event_types: nil, webhook_url: nil, status: :unset, version: :unset)
45   data = Twilio::Values.of({
46       'FriendlyName' => friendly_name,
47       'EventTypes' => Twilio.serialize_list(event_types) { |e| e },
48       'WebhookUrl' => webhook_url,
49       'Status' => status,
50       'Version' => version,
51   })
52 
53   payload = @version.create('POST', @uri, data: data)
54 
55   WebhookInstance.new(@version, payload, service_sid: @solution[:service_sid], )
56 end
each() { |x| ... } click to toggle source

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

    # File lib/twilio-ruby/rest/verify/v2/service/webhook.rb
 96 def each
 97   limits = @version.read_limits
 98 
 99   page = self.page(page_size: limits[:page_size], )
100 
101   @version.stream(page,
102                   limit: limits[:limit],
103                   page_limit: limits[:page_limit]).each {|x| yield x}
104 end
get_page(target_url) click to toggle source

Retrieve a single page of WebhookInstance records from the API. Request is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page of WebhookInstance

    # File lib/twilio-ruby/rest/verify/v2/service/webhook.rb
130 def get_page(target_url)
131   response = @version.domain.request(
132       'GET',
133       target_url
134   )
135   WebhookPage.new(@version, response, @solution)
136 end
list(limit: nil, page_size: nil) click to toggle source

Lists WebhookInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit.  Default is no limit

@param [Integer] page_size 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)

@return [Array] Array of up to limit results

   # File lib/twilio-ruby/rest/verify/v2/service/webhook.rb
69 def list(limit: nil, page_size: nil)
70   self.stream(limit: limit, page_size: page_size).entries
71 end
page(page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of WebhookInstance records from the API. Request is executed immediately. @param [String] page_token PageToken provided by the API @param [Integer] page_number Page Number, this value is simply for client state @param [Integer] page_size Number of records to return, defaults to 50 @return [Page] Page of WebhookInstance

    # File lib/twilio-ruby/rest/verify/v2/service/webhook.rb
113 def page(page_token: :unset, page_number: :unset, page_size: :unset)
114   params = Twilio::Values.of({
115       'PageToken' => page_token,
116       'Page' => page_number,
117       'PageSize' => page_size,
118   })
119 
120   response = @version.page('GET', @uri, params: params)
121 
122   WebhookPage.new(@version, response, @solution)
123 end
stream(limit: nil, page_size: nil) click to toggle source

Streams WebhookInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit. Default is no limit.

@param [Integer] page_size 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)

@return [Enumerable] Enumerable that will yield up to limit results

   # File lib/twilio-ruby/rest/verify/v2/service/webhook.rb
84 def stream(limit: nil, page_size: nil)
85   limits = @version.read_limits(limit, page_size)
86 
87   page = self.page(page_size: limits[:page_size], )
88 
89   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
90 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/verify/v2/service/webhook.rb
140 def to_s
141   '#<Twilio.Verify.V2.WebhookList>'
142 end