class Twilio::REST::Conversations::V1::ServiceContext::ConversationContext::WebhookList
Public Class Methods
Initialize the WebhookList
@param [Version] version Version
that contains the resource @param [String] chat_service_sid The SID of the {Conversation
Service}[https://www.twilio.com/docs/conversations/api/service-resource] the Participant resource is associated with.
@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/service/conversation/webhook.rb 26 def initialize(version, chat_service_sid: nil, conversation_sid: nil) 27 super(version) 28 29 # Path Solution 30 @solution = {chat_service_sid: chat_service_sid, conversation_sid: conversation_sid} 31 @uri = "/Services/#{@solution[:chat_service_sid]}/Conversations/#{@solution[:conversation_sid]}/Webhooks" 32 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/service/conversation/webhook.rb 51 def create(target: nil, configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_replay_after: :unset) 52 data = Twilio::Values.of({ 53 'Target' => target, 54 'Configuration.Url' => configuration_url, 55 'Configuration.Method' => configuration_method, 56 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e }, 57 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e }, 58 'Configuration.FlowSid' => configuration_flow_sid, 59 'Configuration.ReplayAfter' => configuration_replay_after, 60 }) 61 62 payload = @version.create('POST', @uri, data: data) 63 64 WebhookInstance.new( 65 @version, 66 payload, 67 chat_service_sid: @solution[:chat_service_sid], 68 conversation_sid: @solution[:conversation_sid], 69 ) 70 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/service/conversation/webhook.rb 110 def each 111 limits = @version.read_limits 112 113 page = self.page(page_size: limits[:page_size], ) 114 115 @version.stream(page, 116 limit: limits[:limit], 117 page_limit: limits[:page_limit]).each {|x| yield x} 118 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/service/conversation/webhook.rb 144 def get_page(target_url) 145 response = @version.domain.request( 146 'GET', 147 target_url 148 ) 149 WebhookPage.new(@version, response, @solution) 150 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/service/conversation/webhook.rb 83 def list(limit: nil, page_size: nil) 84 self.stream(limit: limit, page_size: page_size).entries 85 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/service/conversation/webhook.rb 127 def page(page_token: :unset, page_number: :unset, page_size: :unset) 128 params = Twilio::Values.of({ 129 'PageToken' => page_token, 130 'Page' => page_number, 131 'PageSize' => page_size, 132 }) 133 134 response = @version.page('GET', @uri, params: params) 135 136 WebhookPage.new(@version, response, @solution) 137 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/service/conversation/webhook.rb 98 def stream(limit: nil, page_size: nil) 99 limits = @version.read_limits(limit, page_size) 100 101 page = self.page(page_size: limits[:page_size], ) 102 103 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 104 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb 154 def to_s 155 '#<Twilio.Conversations.V1.WebhookList>' 156 end