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

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

Instance Method Summary collapse

Constructor Details

#initialize(version, conversation_sid, sid) ⇒ WebhookContext

Initialize the WebhookContext

Parameters:



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

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

Delete the WebhookInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



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

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

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

#delete_with_metadataBoolean

Delete the WebhookInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 282

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      webhook_instance = WebhookInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      .new(@version, webhook_instance, response.headers, response.status_code)
end

#fetchWebhookInstance

Fetch the WebhookInstance

Returns:



301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 301

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    WebhookInstance.new(
        @version,
        payload,
        conversation_sid: @solution[:conversation_sid],
        sid: @solution[:sid],
    )
end

#fetch_with_metadataWebhookInstance

Fetch the WebhookInstanceMetadata

Returns:



321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 321

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    webhook_instance = WebhookInstance.new(
        @version,
        response.body,
        conversation_sid: @solution[:conversation_sid],
        sid: @solution[:sid],
    )
    .new(
        @version,
        webhook_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



438
439
440
441
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 438

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

#to_sObject

Provide a user friendly representation



431
432
433
434
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 431

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 (Method) (defaults to: :unset)
  • 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:



352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 352

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,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    WebhookInstance.new(
        @version,
        payload,
        conversation_sid: @solution[:conversation_sid],
        sid: @solution[:sid],
    )
end

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

Update the WebhookInstanceMetadata

Parameters:

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

    The absolute url the webhook request should be sent to.

  • configuration_method (Method) (defaults to: :unset)
  • 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:



391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/webhook.rb', line 391

def (
  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,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    webhook_instance = WebhookInstance.new(
        @version,
        response.body,
        conversation_sid: @solution[:conversation_sid],
        sid: @solution[:sid],
    )
    .new(
        @version,
        webhook_instance,
        response.headers,
        response.status_code
    )
end