Class: Twilio::REST::Autopilot::V1::AssistantContext::WebhookContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/autopilot/v1/assistant/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, assistant_sid, sid) ⇒ WebhookContext

Initialize the WebhookContext



187
188
189
190
191
192
193
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 187

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

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

Instance Method Details

#deleteBoolean

Delete the WebhookInstance



242
243
244
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 242

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

#fetchWebhookInstance

Fetch the WebhookInstance



198
199
200
201
202
203
204
205
206
207
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 198

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

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

#inspectObject

Provide a detailed, user friendly representation



255
256
257
258
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 255

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

#to_sObject

Provide a user friendly representation



248
249
250
251
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 248

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

#update(unique_name: :unset, events: :unset, webhook_url: :unset, webhook_method: :unset) ⇒ WebhookInstance

Update the WebhookInstance



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 221

def update(unique_name: :unset, events: :unset, webhook_url: :unset, webhook_method: :unset)
  data = Twilio::Values.of({
      'UniqueName' => unique_name,
      'Events' => events,
      'WebhookUrl' => webhook_url,
      'WebhookMethod' => webhook_method,
  })

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

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