Class: Twilio::REST::IpMessaging::V2::ServiceContext::UserContext::UserChannelInstance

Inherits:
Twilio::REST::InstanceResource show all
Defined in:
lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, service_sid: nil, user_sid: nil, channel_sid: nil) ⇒ UserChannelInstance

Initialize the UserChannelInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String)

    The SID of the Account that created this UserChannel resource.

  • sid (String)

    The SID of the Call resource to fetch.



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/ip_messaging/v2/service/user/user_channel.rb', line 271

def initialize(version, payload , service_sid: nil, user_sid: nil, channel_sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'account_sid' => payload['account_sid'],
        'service_sid' => payload['service_sid'],
        'channel_sid' => payload['channel_sid'],
        'user_sid' => payload['user_sid'],
        'member_sid' => payload['member_sid'],
        'status' => payload['status'],
        'last_consumed_message_index' => payload['last_consumed_message_index'] == nil ? payload['last_consumed_message_index'] : payload['last_consumed_message_index'].to_i,
        'unread_messages_count' => payload['unread_messages_count'] == nil ? payload['unread_messages_count'] : payload['unread_messages_count'].to_i,
        'links' => payload['links'],
        'url' => payload['url'],
        'notification_level' => payload['notification_level'],
    }

    # Context
    @instance_context = nil
    @params = { 'service_sid' => service_sid  || @properties['service_sid']  ,'user_sid' => user_sid  || @properties['user_sid']  ,'channel_sid' => channel_sid  || @properties['channel_sid']  , }
end

Instance Method Details

#account_sidString

Returns:

  • (String)


307
308
309
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 307

def 
    @properties['account_sid']
end

#channel_sidString

Returns:

  • (String)


319
320
321
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 319

def channel_sid
    @properties['channel_sid']
end

#contextUserChannelContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



298
299
300
301
302
303
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 298

def context
    unless @instance_context
        @instance_context = UserChannelContext.new(@version , @params['service_sid'], @params['user_sid'], @params['channel_sid'])
    end
    @instance_context
end

#deleteBoolean

Delete the UserChannelInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



374
375
376
377
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 374

def delete

    context.delete
end

#fetchUserChannelInstance

Fetch the UserChannelInstance

Returns:



382
383
384
385
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 382

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



415
416
417
418
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 415

def inspect
    values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.IpMessaging.V2.UserChannelInstance #{values}>"
end

#last_consumed_message_indexString

Returns:

  • (String)


343
344
345
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 343

def last_consumed_message_index
    @properties['last_consumed_message_index']
end

Returns:

  • (Hash)


355
356
357
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 355

def links
    @properties['links']
end

#member_sidString

Returns:

  • (String)


331
332
333
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 331

def member_sid
    @properties['member_sid']
end

#notification_levelNotificationLevel

Returns:

  • (NotificationLevel)


367
368
369
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 367

def notification_level
    @properties['notification_level']
end

#service_sidString

Returns:

  • (String)


313
314
315
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 313

def service_sid
    @properties['service_sid']
end

#statusChannelStatus

Returns:

  • (ChannelStatus)


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

def status
    @properties['status']
end

#to_sObject

Provide a user friendly representation



408
409
410
411
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 408

def to_s
    values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.IpMessaging.V2.UserChannelInstance #{values}>"
end

#unread_messages_countString

Returns:

  • (String)


349
350
351
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 349

def unread_messages_count
    @properties['unread_messages_count']
end

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

Update the UserChannelInstance

Parameters:

  • notification_level (NotificationLevel) (defaults to: :unset)
  • last_consumed_message_index (String) (defaults to: :unset)
  • last_consumption_timestamp (Time) (defaults to: :unset)

Returns:



393
394
395
396
397
398
399
400
401
402
403
404
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 393

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

    context.update(
        notification_level: notification_level, 
        last_consumed_message_index: last_consumed_message_index, 
        last_consumption_timestamp: last_consumption_timestamp, 
    )
end

#urlString

Returns:

  • (String)


361
362
363
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 361

def url
    @properties['url']
end

#user_sidString

Returns:

  • (String)


325
326
327
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 325

def user_sid
    @properties['user_sid']
end