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:



51
52
53
54
55
56
57
58
59
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 51

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:



63
64
65
66
67
68
69
70
71
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 63

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



112
113
114
115
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 112

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

#to_sObject

Provide a user friendly representation



105
106
107
108
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 105

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:



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 80

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