Class: Twilio::REST::IpMessaging::V2::ServiceContext::ChannelContext::WebhookContext

Inherits:
Twilio::REST::InstanceContext show all
Defined in:
lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, channel_sid, sid) ⇒ WebhookContext

Initialize the WebhookContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The service_sid

  • channel_sid (String)

    The channel_sid

  • sid (String)

    The sid


190
191
192
193
194
195
196
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 190

def initialize(version, service_sid, channel_sid, sid)
  super(version)

  # Path Solution
  @solution = {service_sid: service_sid, channel_sid: channel_sid, sid: sid, }
  @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:channel_sid]}/Webhooks/#{@solution[:sid]}"
end

Instance Method Details

#deleteBoolean

Delete the WebhookInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


246
247
248
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 246

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

#fetchWebhookInstance

Fetch the WebhookInstance

Returns:


201
202
203
204
205
206
207
208
209
210
211
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 201

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

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

#inspectObject

Provide a detailed, user friendly representation


259
260
261
262
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 259

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

#to_sObject

Provide a user friendly representation


252
253
254
255
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 252

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

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

Update the WebhookInstance

Parameters:

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

    The configuration.url

  • configuration_method (webhook.Method) (defaults to: :unset)

    The configuration.method

  • configuration_filters (Array[String]) (defaults to: :unset)

    The configuration.filters

  • configuration_triggers (Array[String]) (defaults to: :unset)

    The configuration.triggers

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

    The configuration.flow_sid

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

    The configuration.retry_count

Returns:


222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb', line 222

def update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_retry_count: :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,
      'Configuration.RetryCount' => configuration_retry_count,
  })

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

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