Class: Twilio::REST::Messaging::V1::WebhookContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/messaging/v1/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) ⇒ WebhookContext

Initialize the WebhookContext



72
73
74
75
76
77
78
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 72

def initialize(version)
  super(version)

  # Path Solution
  @solution = {}
  @uri = "/Sessions/Webhooks"
end

Instance Method Details

#fetchWebhookInstance

Fetch a WebhookInstance



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 83

def fetch
  params = Twilio::Values.of({})

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

  WebhookInstance.new(@version, payload, )
end

#inspectObject

Provide a detailed, user friendly representation



143
144
145
146
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 143

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

#to_sObject

Provide a user friendly representation



136
137
138
139
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 136

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

#update(webhook_method: :unset, webhook_filters: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, pre_webhook_retry_count: :unset, post_webhook_retry_count: :unset, target: :unset) ⇒ WebhookInstance

Update the WebhookInstance



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/twilio-ruby/rest/messaging/v1/webhook.rb', line 114

def update(webhook_method: :unset, webhook_filters: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, pre_webhook_retry_count: :unset, post_webhook_retry_count: :unset, target: :unset)
  data = Twilio::Values.of({
      'WebhookMethod' => webhook_method,
      'WebhookFilters' => Twilio.serialize_list(webhook_filters) { |e| e },
      'PreWebhookUrl' => pre_webhook_url,
      'PostWebhookUrl' => post_webhook_url,
      'PreWebhookRetryCount' => pre_webhook_retry_count,
      'PostWebhookRetryCount' => post_webhook_retry_count,
      'Target' => target,
  })

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

  WebhookInstance.new(@version, payload, )
end