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

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

Instance Method Summary collapse

Constructor Details

#initialize(version, chat_service_sid) ⇒ WebhookContext

Initialize the WebhookContext

Parameters:

  • version (Version)

    Version that contains the resource

  • chat_service_sid (String)

    The unique ID of the Conversation Service this conversation belongs to.


73
74
75
76
77
78
79
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 73

def initialize(version, chat_service_sid)
  super(version)

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

Instance Method Details

#fetchWebhookInstance

Fetch the WebhookInstance

Returns:


115
116
117
118
119
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 115

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

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

#inspectObject

Provide a detailed, user friendly representation


130
131
132
133
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 130

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

#to_sObject

Provide a user friendly representation


123
124
125
126
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 123

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

#update(pre_webhook_url: :unset, post_webhook_url: :unset, filters: :unset, method: :unset) ⇒ WebhookInstance

Update the WebhookInstance

Parameters:

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

    The absolute url the pre-event webhook request should be sent to.

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

    The absolute url the post-event webhook request should be sent to.

  • filters (Array[String]) (defaults to: :unset)

    The list of events that your configured webhook targets will receive. Events not configured here will not fire. Possible values are `onParticipantAdd`, `onParticipantAdded`, `onDeliveryUpdated`, `onConversationUpdated`, `onConversationRemove`, `onParticipantRemove`, `onConversationUpdate`, `onMessageAdd`, `onMessageRemoved`, `onParticipantUpdated`, `onConversationAdded`, `onMessageAdded`, `onConversationAdd`, `onConversationRemoved`, `onParticipantUpdate`, `onMessageRemove`, `onMessageUpdated`, `onParticipantRemoved`, `onMessageUpdate` or `onConversationStateUpdated`.

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

    The HTTP method to be used when sending a webhook request. One of `GET` or `POST`.

Returns:


99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 99

def update(pre_webhook_url: :unset, post_webhook_url: :unset, filters: :unset, method: :unset)
  data = Twilio::Values.of({
      'PreWebhookUrl' => pre_webhook_url,
      'PostWebhookUrl' => post_webhook_url,
      'Filters' => Twilio.serialize_list(filters) { |e| e },
      'Method' => method,
  })

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

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