Class: Twilio::REST::Conversations::V1::ConversationInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/conversations/v1/conversation.rb

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, sid: nil) ⇒ ConversationInstance

Initialize the ConversationInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • sid (String) (defaults to: nil)

    A 34 character string that uniquely identifies this resource.



336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 336

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

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'chat_service_sid' => payload['chat_service_sid'],
      'messaging_service_sid' => payload['messaging_service_sid'],
      'sid' => payload['sid'],
      'friendly_name' => payload['friendly_name'],
      'attributes' => payload['attributes'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'url' => payload['url'],
      'links' => payload['links'],
  }

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

Instance Method Details

#account_sidString

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

Returns:

  • (String)

    The unique id of the Account responsible for this conversation.



371
372
373
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 371

def 
  @properties['account_sid']
end

#attributesString

Returns An optional string metadata field you can use to store any data you wish.

Returns:

  • (String)

    An optional string metadata field you can use to store any data you wish.



401
402
403
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 401

def attributes
  @properties['attributes']
end

#chat_service_sidString

Returns The unique id of the Chat Service this conversation belongs to.

Returns:

  • (String)

    The unique id of the Chat Service this conversation belongs to.



377
378
379
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 377

def chat_service_sid
  @properties['chat_service_sid']
end

#contextConversationContext

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

Returns:



362
363
364
365
366
367
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 362

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

#date_createdTime

Returns The date that this resource was created.

Returns:

  • (Time)

    The date that this resource was created.



407
408
409
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 407

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date that this resource was last updated.

Returns:

  • (Time)

    The date that this resource was last updated.



413
414
415
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 413

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the ConversationInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



456
457
458
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 456

def delete
  context.delete
end

#fetchConversationInstance

Fetch a ConversationInstance

Returns:



463
464
465
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 463

def fetch
  context.fetch
end

#friendly_nameString

Returns The human-readable name of this conversation.

Returns:

  • (String)

    The human-readable name of this conversation.



395
396
397
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 395

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



497
498
499
500
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 497

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

Returns Absolute URLs to access the Participants of this Conversation.

Returns:

  • (String)

    Absolute URLs to access the Participants of this Conversation.



425
426
427
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 425

def links
  @properties['links']
end

#messagesmessages

Access the messages

Returns:



477
478
479
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 477

def messages
  context.messages
end

#messaging_service_sidString

Returns The unique id of the SMS Service this conversation belongs to.

Returns:

  • (String)

    The unique id of the SMS Service this conversation belongs to.



383
384
385
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 383

def messaging_service_sid
  @properties['messaging_service_sid']
end

#participantsparticipants

Access the participants

Returns:



470
471
472
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 470

def participants
  context.participants
end

#sidString

Returns A 34 character string that uniquely identifies this resource.

Returns:

  • (String)

    A 34 character string that uniquely identifies this resource.



389
390
391
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 389

def sid
  @properties['sid']
end

#to_sObject

Provide a user friendly representation



490
491
492
493
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 490

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

#update(friendly_name: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, messaging_service_sid: :unset) ⇒ ConversationInstance

Update the ConversationInstance

Parameters:

  • friendly_name (String) (defaults to: :unset)

    The human-readable name of this conversation, limited to 256 characters. Optional.

  • date_created (Time) (defaults to: :unset)

    The date that this resource was created.

  • date_updated (Time) (defaults to: :unset)

    The date that this resource was last updated.

  • attributes (String) (defaults to: :unset)

    An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. Note that if the attributes are not set “{}” will be returned.

  • messaging_service_sid (String) (defaults to: :unset)

    The unique id of the [SMS Service](www.twilio.com/docs/sms/services/api) this conversation belongs to.

Returns:



443
444
445
446
447
448
449
450
451
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 443

def update(friendly_name: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, messaging_service_sid: :unset)
  context.update(
      friendly_name: friendly_name,
      date_created: date_created,
      date_updated: date_updated,
      attributes: attributes,
      messaging_service_sid: messaging_service_sid,
  )
end

#urlString

Returns An absolute URL for this conversation.

Returns:

  • (String)

    An absolute URL for this conversation.



419
420
421
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 419

def url
  @properties['url']
end

#webhookswebhooks

Access the webhooks

Returns:



484
485
486
# File 'lib/twilio-ruby/rest/conversations/v1/conversation.rb', line 484

def webhooks
  context.webhooks
end