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:



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

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:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/twilio-ruby/rest/conversations/v1/service/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,
        chat_service_sid: @solution[:chat_service_sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



125
126
127
128
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 125

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

#to_sObject

Provide a user friendly representation



118
119
120
121
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 118

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:



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb', line 87

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,
    })

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