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

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

Instance Method Summary collapse

Constructor Details

#initialize(version, chat_service_sid, conversation_sid, sid) ⇒ WebhookContext

Initialize the WebhookContext

Parameters:

  • version (Version)

    Version that contains the resource

  • chat_service_sid (String)

    The SID of the Conversation Service the Participant resource is associated with.

  • conversation_sid (String)

    The unique ID of the Conversation for this webhook.

  • sid (String)

    A 34 character string that uniquely identifies this resource.


206
207
208
209
210
211
212
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb', line 206

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

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

Instance Method Details

#deleteBoolean

Delete the WebhookInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


250
251
252
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb', line 250

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

#fetchWebhookInstance

Fetch the WebhookInstance

Returns:


257
258
259
260
261
262
263
264
265
266
267
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb', line 257

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

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

#inspectObject

Provide a detailed, user friendly representation


278
279
280
281
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb', line 278

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

#to_sObject

Provide a user friendly representation


271
272
273
274
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb', line 271

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 (Array[String]) (defaults to: :unset)

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

  • configuration_triggers (Array[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:


227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb', line 227

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,
      chat_service_sid: @solution[:chat_service_sid],
      conversation_sid: @solution[:conversation_sid],
      sid: @solution[:sid],
  )
end