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

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/conversations/v1/service/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, chat_service_sid: nil, sid: nil) ⇒ ConversationInstance

Initialize the ConversationInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • chat_service_sid (String) (defaults to: nil)

    The unique id of the [Chat Service](www.twilio.com/docs/chat/rest/service-resource) this conversation belongs to.

  • sid (String) (defaults to: nil)

    A 34 character string that uniquely identifies this resource. Can also be the unique_name of the Conversation.



381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 381

def initialize(version, payload, chat_service_sid: nil, 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'],
      'unique_name' => payload['unique_name'],
      'attributes' => payload['attributes'],
      'state' => payload['state'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'timers' => payload['timers'],
      'url' => payload['url'],
      'links' => payload['links'],
  }

  # Context
  @instance_context = nil
  @params = {'chat_service_sid' => chat_service_sid, '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.



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

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.



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

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.



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

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:



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

def context
  unless @instance_context
    @instance_context = ConversationContext.new(@version, @params['chat_service_sid'], @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.



467
468
469
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 467

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.



473
474
475
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 473

def date_updated
  @properties['date_updated']
end

#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean

Delete the ConversationInstance

Parameters:

  • x_twilio_webhook_enabled (conversation.WebhookEnabledType) (defaults to: :unset)

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



536
537
538
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 536

def delete(x_twilio_webhook_enabled: :unset)
  context.delete(x_twilio_webhook_enabled: x_twilio_webhook_enabled, )
end

#fetchConversationInstance

Fetch the ConversationInstance

Returns:



543
544
545
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 543

def fetch
  context.fetch
end

#friendly_nameString

Returns The human-readable name of this conversation.

Returns:

  • (String)

    The human-readable name of this conversation.



443
444
445
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 443

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



577
578
579
580
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 577

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

Returns Absolute URLs to access the Participants, Messages and Webhooks of this Conversation.

Returns:

  • (String)

    Absolute URLs to access the Participants, Messages and Webhooks of this Conversation.



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

def links
  @properties['links']
end

#messagesmessages

Access the messages

Returns:



557
558
559
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 557

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.



431
432
433
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 431

def messaging_service_sid
  @properties['messaging_service_sid']
end

#participantsparticipants

Access the participants

Returns:



550
551
552
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 550

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.



437
438
439
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 437

def sid
  @properties['sid']
end

#stateconversation.State

Returns Current state of this conversation.

Returns:

  • (conversation.State)

    Current state of this conversation.



461
462
463
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 461

def state
  @properties['state']
end

#timersHash

Returns Timer date values for this conversation.

Returns:

  • (Hash)

    Timer date values for this conversation.



479
480
481
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 479

def timers
  @properties['timers']
end

#to_sObject

Provide a user friendly representation



570
571
572
573
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 570

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

#unique_nameString

Returns An application-defined string that uniquely identifies the resource.

Returns:

  • (String)

    An application-defined string that uniquely identifies the resource



449
450
451
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 449

def unique_name
  @properties['unique_name']
end

#update(friendly_name: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, messaging_service_sid: :unset, state: :unset, timers_inactive: :unset, timers_closed: :unset, x_twilio_webhook_enabled: :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.

  • state (conversation.State) (defaults to: :unset)

    Current state of this conversation. Can be either active, inactive or closed and defaults to active

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

    ISO8601 duration when conversation will be switched to inactive state. Minimum value for this timer is 1 minute.

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

    ISO8601 duration when conversation will be switched to closed state. Minimum value for this timer is 10 minutes.

  • x_twilio_webhook_enabled (conversation.WebhookEnabledType) (defaults to: :unset)

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:



517
518
519
520
521
522
523
524
525
526
527
528
529
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 517

def update(friendly_name: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, messaging_service_sid: :unset, state: :unset, timers_inactive: :unset, timers_closed: :unset, x_twilio_webhook_enabled: :unset)
  context.update(
      friendly_name: friendly_name,
      date_created: date_created,
      date_updated: date_updated,
      attributes: attributes,
      messaging_service_sid: messaging_service_sid,
      state: state,
      timers_inactive: timers_inactive,
      timers_closed: timers_closed,
      x_twilio_webhook_enabled: x_twilio_webhook_enabled,
  )
end

#urlString

Returns An absolute URL for this conversation.

Returns:

  • (String)

    An absolute URL for this conversation.



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

def url
  @properties['url']
end

#webhookswebhooks

Access the webhooks

Returns:



564
565
566
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 564

def webhooks
  context.webhooks
end