Class: Twilio::REST::Conversations::V1::ConversationContext::WebhookContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb

Overview

PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact [email protected].

Instance Method Summary collapse

Constructor Details

#initialize(version, conversation_sid, sid) ⇒ WebhookContext

Initialize the WebhookContext

Parameters:



200
201
202
203
204
205
206
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 200

def initialize(version, conversation_sid, sid)
  super(version)

  # Path Solution
  @solution = {conversation_sid: conversation_sid, sid: sid, }
  @uri = "/Conversations/#{@solution[:conversation_sid]}/Webhooks/#{@solution[:sid]}"
end

Instance Method Details

#deleteBoolean

Deletes the WebhookInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



267
268
269
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 267

def delete
  @version.delete('delete', @uri)
end

#fetchWebhookInstance

Fetch a WebhookInstance

Returns:



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 211

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  WebhookInstance.new(
      @version,
      payload,
      conversation_sid: @solution[:conversation_sid],
      sid: @solution[:sid],
  )
end

#inspectObject

Provide a detailed, user friendly representation



280
281
282
283
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 280

def inspect
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Conversations.V1.WebhookContext #{context}>"
end

#to_sObject

Provide a user friendly representation



273
274
275
276
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 273

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Conversations.V1.WebhookContext #{context}>"
end

#update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset) ⇒ WebhookInstance

Update the WebhookInstance

Parameters:

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

    The absolute url the webhook request should be sent to.

  • configuration_method (webhook.Method) (defaults to: :unset)

    The HTTP method to be used when sending a webhook request.

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

    The list of events, firing webhook event for this Conversation.

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

    The list of keywords, firing webhook event for this Conversation.

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

    The studio flow sid, where the webhook should be sent to.

Returns:



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 241

def update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset)
  data = Twilio::Values.of({
      'Configuration.Url' => configuration_url,
      'Configuration.Method' => configuration_method,
      'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e },
      'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e },
      'Configuration.FlowSid' => configuration_flow_sid,
  })

  payload = @version.update(
      'POST',
      @uri,
      data: data,
  )

  WebhookInstance.new(
      @version,
      payload,
      conversation_sid: @solution[:conversation_sid],
      sid: @solution[:sid],
  )
end