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

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, chat_service_sid: nil) ⇒ WebhookInstance

Initialize the WebhookInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String)

    The SID of the Account that created this Webhook resource.

  • sid (String)

    The SID of the Call resource to fetch.



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 169

def initialize(version, payload , chat_service_sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'account_sid' => payload['account_sid'],
        'chat_service_sid' => payload['chat_service_sid'],
        'pre_webhook_url' => payload['pre_webhook_url'],
        'post_webhook_url' => payload['post_webhook_url'],
        'filters' => payload['filters'],
        'method' => payload['method'],
        'url' => payload['url'],
    }

    # Context
    @instance_context = nil
    @params = { 'chat_service_sid' => chat_service_sid  || @properties['chat_service_sid']  , }
end

Instance Method Details

#account_sidString

Returns The unique ID of the [Account](www.twilio.com/docs/iam/api/account) responsible for this service.

Returns:



201
202
203
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 201

def 
    @properties['account_sid']
end

#chat_service_sidString

Returns The unique ID of the [Conversation Service](www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to.

Returns:



207
208
209
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 207

def chat_service_sid
    @properties['chat_service_sid']
end

#contextWebhookContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



192
193
194
195
196
197
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 192

def context
    unless @instance_context
        @instance_context = WebhookContext.new(@version , @params['chat_service_sid'])
    end
    @instance_context
end

#fetchWebhookInstance

Fetch the WebhookInstance

Returns:



244
245
246
247
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 244

def fetch

    context.fetch
end

#filtersArray<String>

Returns 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.

Returns:

  • (Array<String>)

    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.



225
226
227
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 225

def filters
    @properties['filters']
end

#inspectObject

Provide a detailed, user friendly representation



280
281
282
283
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 280

def inspect
    values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Conversations.V1.WebhookInstance #{values}>"
end

#methodMethod

Returns:

  • (Method)


231
232
233
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 231

def method
    @properties['method']
end

#post_webhook_urlString

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

Returns:

  • (String)

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



219
220
221
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 219

def post_webhook_url
    @properties['post_webhook_url']
end

#pre_webhook_urlString

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

Returns:

  • (String)

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



213
214
215
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 213

def pre_webhook_url
    @properties['pre_webhook_url']
end

#to_sObject

Provide a user friendly representation



273
274
275
276
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 273

def to_s
    values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Conversations.V1.WebhookInstance #{values}>"
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:



256
257
258
259
260
261
262
263
264
265
266
267
268
269
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 256

def update(
    pre_webhook_url: :unset, 
    post_webhook_url: :unset, 
    filters: :unset, 
    method: :unset
)

    context.update(
        pre_webhook_url: pre_webhook_url, 
        post_webhook_url: post_webhook_url, 
        filters: filters, 
        method: method, 
    )
end

#urlString

Returns An absolute API resource URL for this webhook.

Returns:

  • (String)

    An absolute API resource URL for this webhook.



237
238
239
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 237

def url
    @properties['url']
end