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

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

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

  • account_sid (String)

    The SID of the Account that created this Conversation resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 756

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'],
        'bindings' => payload['bindings'],
    }

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

Instance Method Details

#account_sidString

Returns The unique ID of the [Account](www.twilio.com/docs/iam/api/account) responsible for this conversation.

Returns:



796
797
798
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 796

def 
    @properties['account_sid']
end

#attributesString

Returns 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.

Returns:

  • (String)

    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.



832
833
834
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 832

def attributes
    @properties['attributes']
end

#bindingsHash

Returns:

  • (Hash)


874
875
876
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 874

def bindings
    @properties['bindings']
end

#chat_service_sidString

Returns The unique ID of the [Conversation Service](www.twilio.com/docs/conversations/api/service-resource) this conversation belongs to.

Returns:



802
803
804
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 802

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:



787
788
789
790
791
792
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 787

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.



844
845
846
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 844

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.



850
851
852
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 850

def date_updated
    @properties['date_updated']
end

#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean

Delete the ConversationInstance

Parameters:

  • x_twilio_webhook_enabled (ServiceConversationEnumWebhookEnabledType) (defaults to: :unset)

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



882
883
884
885
886
887
888
889
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 882

def delete(
  x_twilio_webhook_enabled: :unset
)

    context.delete(
        x_twilio_webhook_enabled: x_twilio_webhook_enabled, 
    )
end

#fetchConversationInstance

Fetch the ConversationInstance

Returns:



894
895
896
897
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 894

def fetch

    context.fetch
end

#friendly_nameString

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

Returns:

  • (String)

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



820
821
822
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 820

def friendly_name
    @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



975
976
977
978
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 975

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


868
869
870
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 868

def links
    @properties['links']
end

#messagesmessages

Access the messages

Returns:



962
963
964
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 962

def messages
    context.messages
end

#messaging_service_sidString

Returns The unique ID of the [Messaging Service](www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to.

Returns:



808
809
810
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 808

def messaging_service_sid
    @properties['messaging_service_sid']
end

#participantsparticipants

Access the participants

Returns:



948
949
950
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 948

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.



814
815
816
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 814

def sid
    @properties['sid']
end

#stateState

Returns:

  • (State)


838
839
840
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 838

def state
    @properties['state']
end

#timersHash

Returns Timer date values representing state update for this conversation.

Returns:

  • (Hash)

    Timer date values representing state update for this conversation.



856
857
858
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 856

def timers
    @properties['timers']
end

#to_sObject

Provide a user friendly representation



968
969
970
971
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 968

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. It can be used to address the resource in place of the resource’s ‘sid` in the URL.

Returns:

  • (String)

    An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource’s ‘sid` in the URL.



826
827
828
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 826

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, unique_name: :unset, bindings_email_address: :unset, bindings_email_name: :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 [Messaging Service](www.twilio.com/docs/messaging/api/service-resource) this conversation belongs to.

  • state (State) (defaults to: :unset)
  • 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.

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

    An application-defined string that uniquely identifies the resource. It can be used to address the resource in place of the resource’s ‘sid` in the URL.

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

    The default email address that will be used when sending outbound emails in this conversation.

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

    The default name that will be used when sending outbound emails in this conversation.

  • x_twilio_webhook_enabled (ServiceConversationEnumWebhookEnabledType) (defaults to: :unset)

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:



914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 914

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, 
  unique_name: :unset, 
  bindings_email_address: :unset, 
  bindings_email_name: :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, 
        unique_name: unique_name, 
        bindings_email_address: bindings_email_address, 
        bindings_email_name: bindings_email_name, 
        x_twilio_webhook_enabled: x_twilio_webhook_enabled, 
    )
end

#urlString

Returns An absolute API resource URL for this conversation.

Returns:

  • (String)

    An absolute API resource URL for this conversation.



862
863
864
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 862

def url
    @properties['url']
end

#webhookswebhooks

Access the webhooks

Returns:



955
956
957
# File 'lib/twilio-ruby/rest/conversations/v1/service/conversation.rb', line 955

def webhooks
    context.webhooks
end