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:



172
173
174
175
176
177
178
179
180
181
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 172

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



186
187
188
189
190
191
192
193
194
195
196
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 186

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



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 202

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

#fetchUserChannelInstance

Fetch the UserChannelInstance

Returns:



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 223

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:



244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 244

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

#inspectObject

Provide a detailed, user friendly representation



352
353
354
355
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 352

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

#to_sObject

Provide a user friendly representation



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

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:



274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 274

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:



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
333
334
335
336
337
338
339
340
# File 'lib/twilio-ruby/rest/chat/v2/service/user/user_channel.rb', line 308

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