class Twilio::REST::Conversations::V1::ConversationContext::WebhookList
Public Class Methods
Initialize the WebhookList
@param [Version] version Version
that contains the resource @param [String] conversation_sid The unique ID of the
{Conversation}[https://www.twilio.com/docs/conversations/api/conversation-resource] for this webhook.
@return [WebhookList] WebhookList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb 22 def initialize(version, conversation_sid: nil) 23 super(version) 24 25 # Path Solution 26 @solution = {conversation_sid: conversation_sid} 27 @uri = "/Conversations/#{@solution[:conversation_sid]}/Webhooks" 28 end
Public Instance Methods
Create the WebhookInstance
@param [webhook.Target] target The target of this webhook: `webhook`, `studio`,
`trigger`
@param [String] configuration_url The absolute url the webhook request should be
sent to.
@param [webhook.Method] configuration_method The HTTP
method to be used when
sending a webhook request.
@param [Array] configuration_filters The list of events, firing webhook
event for this Conversation.
@param [Array] configuration_triggers The list of keywords, firing
webhook event for this Conversation.
@param [String] configuration_flow_sid The studio flow SID, where the webhook
should be sent to.
@param [String] configuration_replay_after The message index for which and it's
successors the webhook will be replayed. Not set by default
@return [WebhookInstance] Created WebhookInstance
# File lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb 127 def create(target: nil, configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_replay_after: :unset) 128 data = Twilio::Values.of({ 129 'Target' => target, 130 'Configuration.Url' => configuration_url, 131 'Configuration.Method' => configuration_method, 132 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e }, 133 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e }, 134 'Configuration.FlowSid' => configuration_flow_sid, 135 'Configuration.ReplayAfter' => configuration_replay_after, 136 }) 137 138 payload = @version.create('POST', @uri, data: data) 139 140 WebhookInstance.new(@version, payload, conversation_sid: @solution[:conversation_sid], ) 141 end
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/conversations/v1/conversation/webhook.rb 68 def each 69 limits = @version.read_limits 70 71 page = self.page(page_size: limits[:page_size], ) 72 73 @version.stream(page, 74 limit: limits[:limit], 75 page_limit: limits[:page_limit]).each {|x| yield x} 76 end
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/conversations/v1/conversation/webhook.rb 102 def get_page(target_url) 103 response = @version.domain.request( 104 'GET', 105 target_url 106 ) 107 WebhookPage.new(@version, response, @solution) 108 end
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/conversations/v1/conversation/webhook.rb 41 def list(limit: nil, page_size: nil) 42 self.stream(limit: limit, page_size: page_size).entries 43 end
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/conversations/v1/conversation/webhook.rb 85 def page(page_token: :unset, page_number: :unset, page_size: :unset) 86 params = Twilio::Values.of({ 87 'PageToken' => page_token, 88 'Page' => page_number, 89 'PageSize' => page_size, 90 }) 91 92 response = @version.page('GET', @uri, params: params) 93 94 WebhookPage.new(@version, response, @solution) 95 end
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/conversations/v1/conversation/webhook.rb 56 def stream(limit: nil, page_size: nil) 57 limits = @version.read_limits(limit, page_size) 58 59 page = self.page(page_size: limits[:page_size], ) 60 61 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 62 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb 145 def to_s 146 '#<Twilio.Conversations.V1.WebhookList>' 147 end