Class: Twilio::REST::Chat::V2::ServiceContext::UserContext::UserChannelContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, user_sid, channel_sid) ⇒ UserChannelContext

Initialize the UserChannelContext

Parameters:



164
165
166
167
168
169
170
171
172
173
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 164

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

    # Path Solution
    @solution = { service_sid: service_sid, user_sid: user_sid, channel_sid: channel_sid,  }
    @uri = "/Services/#{@solution[:service_sid]}/Users/#{@solution[:user_sid]}/Channels/#{@solution[:channel_sid]}"

    
end

Instance Method Details

#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean

Delete the UserChannelInstance

Parameters:

  • x_twilio_webhook_enabled (UserChannelEnumWebhookEnabledType) (defaults to: :unset)

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



178
179
180
181
182
183
184
185
186
187
188
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 178

def delete(
    x_twilio_webhook_enabled: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadata(x_twilio_webhook_enabled: :unset) ⇒ Boolean

Delete the UserChannelInstanceMetadata

Parameters:

  • x_twilio_webhook_enabled (UserChannelEnumWebhookEnabledType) (defaults to: :unset)

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 194

def (
  x_twilio_webhook_enabled: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      userChannel_instance = UserChannelInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      .new(@version, userChannel_instance, response.headers, response.status_code)
end

#fetchUserChannelInstance

Fetch the UserChannelInstance

Returns:



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 215

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    UserChannelInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        user_sid: @solution[:user_sid],
        channel_sid: @solution[:channel_sid],
    )
end

#fetch_with_metadataUserChannelInstance

Fetch the UserChannelInstanceMetadata

Returns:



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 236

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    user_channel_instance = UserChannelInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        user_sid: @solution[:user_sid],
        channel_sid: @solution[:channel_sid],
    )
    .new(
        @version,
        user_channel_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



344
345
346
347
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 344

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

#to_sObject

Provide a user friendly representation



337
338
339
340
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 337

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

#update(notification_level: :unset, last_consumed_message_index: :unset, last_consumption_timestamp: :unset) ⇒ UserChannelInstance

Update the UserChannelInstance

Parameters:

Returns:



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 266

def update(
    notification_level: :unset, 
    last_consumed_message_index: :unset, 
    last_consumption_timestamp: :unset
)

    data = Twilio::Values.of({
        'NotificationLevel' => notification_level,
        'LastConsumedMessageIndex' => last_consumed_message_index,
        'LastConsumptionTimestamp' => Twilio.serialize_iso8601_datetime(last_consumption_timestamp),
    })

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

#update_with_metadata(notification_level: :unset, last_consumed_message_index: :unset, last_consumption_timestamp: :unset) ⇒ UserChannelInstance

Update the UserChannelInstanceMetadata

Parameters:

Returns:



300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 300

def (
  notification_level: :unset, 
  last_consumed_message_index: :unset, 
  last_consumption_timestamp: :unset
)

    data = Twilio::Values.of({
        'NotificationLevel' => notification_level,
        'LastConsumedMessageIndex' => last_consumed_message_index,
        'LastConsumptionTimestamp' => Twilio.serialize_iso8601_datetime(last_consumption_timestamp),
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    user_channel_instance = UserChannelInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        user_sid: @solution[:user_sid],
        channel_sid: @solution[:channel_sid],
    )
    .new(
        @version,
        user_channel_instance,
        response.headers,
        response.status_code
    )
end