Class: Twilio::REST::Chat::V1::ServiceContext::RoleInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/chat/v1/service/role.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, service_sid: nil, sid: nil) ⇒ RoleInstance

Initialize the RoleInstance

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/v1/services) this role belongs to.

  • sid (String) (defaults to: nil)

    The sid



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/v1/service/role.rb', line 247

def initialize(version, payload, service_sid: nil, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'account_sid' => payload['account_sid'],
      'service_sid' => payload['service_sid'],
      'friendly_name' => payload['friendly_name'],
      'type' => payload['type'],
      'permissions' => payload['permissions'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'url' => payload['url'],
  }

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

Instance Method Details

#account_sidString

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

Returns:

  • (String)

    The unique id of the Account responsible for this role.



287
288
289
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 287

def 
  @properties['account_sid']
end

#contextRoleContext

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

Returns:



272
273
274
275
276
277
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 272

def context
  unless @instance_context
    @instance_context = RoleContext.new(@version, @params['service_sid'], @params['sid'], )
  end
  @instance_context
end

#date_createdTime

Returns The date that this resource was created in ISO 8601 format.

Returns:

  • (Time)

    The date that this resource was created in ISO 8601 format.



317
318
319
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 317

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date that this resource was last updated in ISO 8601 format.

Returns:

  • (Time)

    The date that this resource was last updated in ISO 8601 format.



323
324
325
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 323

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the RoleInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



343
344
345
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 343

def delete
  context.delete
end

#fetchRoleInstance

Fetch a RoleInstance

Returns:



336
337
338
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 336

def fetch
  context.fetch
end

#friendly_nameString

Returns The human-readable name of this role.

Returns:

  • (String)

    The human-readable name of this role.



299
300
301
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 299

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



365
366
367
368
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 365

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

#permissionsString

Returns A JSON array of the permissions this role has.

Returns:

  • (String)

    A JSON array of the permissions this role has.



311
312
313
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 311

def permissions
  @properties['permissions']
end

#service_sidString

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

Returns:

  • (String)

    The unique id of the Service this role belongs to.



293
294
295
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 293

def service_sid
  @properties['service_sid']
end

#sidString

Returns A 34 character string that uniquely identifies this resource.

Returns:

  • (String)

    A 34 character string that uniquely identifies this resource.



281
282
283
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 281

def sid
  @properties['sid']
end

#to_sObject

Provide a user friendly representation



358
359
360
361
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 358

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

#typerole.RoleType

Returns What kind of role this is.

Returns:

  • (role.RoleType)

    What kind of role this is.



305
306
307
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 305

def type
  @properties['type']
end

#update(permission: nil) ⇒ RoleInstance

Update the RoleInstance

Parameters:

  • permission (String) (defaults to: nil)

    (multiple) A permission this role should have. Consult the table above for the list of possible permissions.

Returns:



352
353
354
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 352

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

#urlString

Returns An absolute URL for this role.

Returns:

  • (String)

    An absolute URL for this role.



329
330
331
# File 'lib/twilio-ruby/rest/chat/v1/service/role.rb', line 329

def url
  @properties['url']
end