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

  • service_sid (String) (defaults to: nil)

    The unique id of the [Service](www.twilio.com/docs/api/chat/rest/services) this channel belongs to.

  • user_sid (String) (defaults to: nil)

    The unique id of the [User](www.twilio.com/docs/api/chat/rest/users) this Channel belongs to.

  • channel_sid (String) (defaults to: nil)

    The unique id of a Channel.



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

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,
      'user_sid' => user_sid,
      'channel_sid' => channel_sid || @properties['channel_sid'],
  }
end

Instance Method Details

#account_sidString

Returns The unique id of the Account responsible for this channel.

Returns:

  • (String)

    The unique id of the Account responsible for this channel.



283
284
285
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 283

def 
  @properties['account_sid']
end

#channel_sidString

Returns The unique id of a Channel.

Returns:

  • (String)

    The unique id of a Channel.



295
296
297
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 295

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:



269
270
271
272
273
274
275
276
277
278
279
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 269

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

#fetchUserChannelInstance

Fetch a UserChannelInstance

Returns:



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

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



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

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

#last_consumed_message_indexString

Returns The index of the last read Message in this Channel for this User.

Returns:

  • (String)

    The index of the last read Message in this Channel for this User.



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

def last_consumed_message_index
  @properties['last_consumed_message_index']
end

Returns The links.

Returns:

  • (String)

    The links



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

def links
  @properties['links']
end

#member_sidString

Returns The unique id of this User as a Member in this Channel.

Returns:

  • (String)

    The unique id of this User as a Member in this Channel.



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

def member_sid
  @properties['member_sid']
end

#notification_leveluser_channel.NotificationLevel

Returns The notification level of the User for this Channel.

Returns:

  • (user_channel.NotificationLevel)

    The notification level of the User for this Channel.



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

def notification_level
  @properties['notification_level']
end

#service_sidString

Returns The unique id of the Service this channel belongs to.

Returns:

  • (String)

    The unique id of the Service this channel belongs to.



289
290
291
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb', line 289

def service_sid
  @properties['service_sid']
end

#statususer_channel.ChannelStatus

Returns The status of the User on this Channel.

Returns:

  • (user_channel.ChannelStatus)

    The status of the User on this Channel.



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

def status
  @properties['status']
end

#to_sObject

Provide a user friendly representation



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

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

#unread_messages_countString

Returns The count of unread Messages in this Channel for this User.

Returns:

  • (String)

    The count of unread Messages in this Channel for this User.



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

def unread_messages_count
  @properties['unread_messages_count']
end

#update(notification_level: nil) ⇒ UserChannelInstance

Update the UserChannelInstance

Parameters:

  • notification_level (user_channel.NotificationLevel) (defaults to: nil)

    Push notification level to be assigned to Channel of the User.

Returns:



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

def update(notification_level: nil)
  context.update(notification_level: notification_level, )
end

#urlString

Returns An absolute URL for this User Channel.

Returns:

  • (String)

    An absolute URL for this User Channel.



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

def url
  @properties['url']
end

#user_sidString

Returns The unique id of the User this Channel belongs to.

Returns:

  • (String)

    The unique id of the User this Channel belongs to.



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

def user_sid
  @properties['user_sid']
end