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

Parameters:

  • Version that contains the resource

  • The SID of the Assistant that is the parent of the resource to update.

  • The Twilio-provided string that uniquely identifies the Webhook resource to update.



167
168
169
170
171
172
173
174
175
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 167

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

Returns:

  • True if delete succeeds, false otherwise



179
180
181
182
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 179

def delete

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

#fetchWebhookInstance

Fetch the WebhookInstance

Returns:

  • Fetched WebhookInstance



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

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



238
239
240
241
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 238

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

#to_sObject

Provide a user friendly representation



231
232
233
234
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 231

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

Parameters:

  • (defaults to: :unset)

    An application-defined string that uniquely identifies the new resource. It can be used as an alternative to the sid in the URL path to address the resource. This value must be unique and 64 characters or less in length.

  • (defaults to: :unset)

    The list of space-separated events that this Webhook will subscribe to.

  • (defaults to: :unset)

    The URL associated with this Webhook.

  • (defaults to: :unset)

    The method to be used when calling the webhook's URL.

Returns:

  • Updated WebhookInstance



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/twilio-ruby/rest/autopilot/v1/assistant/webhook.rb', line 205

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