Class: Twilio::REST::Conversations::V1::ConfigurationContext::WebhookContext

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

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ WebhookContext

Initialize the WebhookContext

Parameters:

  • version (Version)

    Version that contains the resource



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

def initialize(version)
    super(version)
    

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

    
end

Instance Method Details

#fetchWebhookInstance

Fetch the WebhookInstance

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/twilio-ruby/rest/conversations/v1/configuration/webhook.rb', line 64

def fetch

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

#fetch_with_metadataWebhookInstance

Fetch the WebhookInstanceMetadata

Returns:



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

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,
    )
    .new(
        @version,
        webhook_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



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

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

#to_sObject

Provide a user friendly representation



186
187
188
189
# File 'lib/twilio-ruby/rest/conversations/v1/configuration/webhook.rb', line 186

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

#update(method: :unset, filters: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, target: :unset) ⇒ WebhookInstance

Update the WebhookInstance

Parameters:

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

    The HTTP method to be used when sending a webhook request.

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

    The list of webhook event triggers that are enabled for this Service: onMessageAdded, onMessageUpdated, onMessageRemoved, onMessageAdd, onMessageUpdate, onMessageRemove, onConversationUpdated, onConversationRemoved, onConversationAdd, onConversationAdded, onConversationRemove, onConversationUpdate, onConversationStateUpdated, onParticipantAdded, onParticipantUpdated, onParticipantRemoved, onParticipantAdd, onParticipantRemove, onParticipantUpdate, onDeliveryUpdated, onUserAdded, onUserUpdate, onUserUpdated

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

  • target (Target) (defaults to: :unset)

Returns:



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/twilio-ruby/rest/conversations/v1/configuration/webhook.rb', line 111

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

    data = Twilio::Values.of({
        'Method' => method,
        'Filters' => Twilio.serialize_list(filters) { |e| e },
        'PreWebhookUrl' => pre_webhook_url,
        'PostWebhookUrl' => post_webhook_url,
        'Target' => target,
    })

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

#update_with_metadata(method: :unset, filters: :unset, pre_webhook_url: :unset, post_webhook_url: :unset, target: :unset) ⇒ WebhookInstance

Update the WebhookInstanceMetadata

Parameters:

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

    The HTTP method to be used when sending a webhook request.

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

    The list of webhook event triggers that are enabled for this Service: onMessageAdded, onMessageUpdated, onMessageRemoved, onMessageAdd, onMessageUpdate, onMessageRemove, onConversationUpdated, onConversationRemoved, onConversationAdd, onConversationAdded, onConversationRemove, onConversationUpdate, onConversationStateUpdated, onParticipantAdded, onParticipantUpdated, onParticipantRemoved, onParticipantAdd, onParticipantRemove, onParticipantUpdate, onDeliveryUpdated, onUserAdded, onUserUpdate, onUserUpdated

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

  • target (Target) (defaults to: :unset)

Returns:



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/twilio-ruby/rest/conversations/v1/configuration/webhook.rb', line 148

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

    data = Twilio::Values.of({
        'Method' => method,
        'Filters' => Twilio.serialize_list(filters) { |e| e },
        'PreWebhookUrl' => pre_webhook_url,
        'PostWebhookUrl' => post_webhook_url,
        'Target' => target,
    })

    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,
    )
    .new(
        @version,
        webhook_instance,
        response.headers,
        response.status_code
    )
end