Class: Twilio::REST::Knowledge::V2::KnowledgeInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/knowledge/v2/knowledge.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, kb_id: nil, knowledge_id: nil) ⇒ KnowledgeInstance

Initialize the KnowledgeInstance

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 Knowledge resource.

  • sid (String)

    The SID of the Call resource to fetch.



607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 607

def initialize(version, payload , kb_id: nil, knowledge_id: nil)
    
    apiV1Version = ApiV1Version.new version.domain, version
    super(apiV1Version)
    
    # Marshaled Properties
    @properties = { 
        'name' => payload['name'],
        'description' => payload['description'],
        'source' => payload['source'],
        'id' => payload['id'],
        'status' => payload['status'],
        'created_at' => Twilio.deserialize_iso8601_datetime(payload['created_at']),
        'updated_at' => Twilio.deserialize_iso8601_datetime(payload['updated_at']),
        'code' => payload['code'],
        'message' => payload['message'],
        'more_info' => payload['more_info'],
    }

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

Instance Method Details

#codeString

Returns The Twilio error code.

Returns:

  • (String)

    The Twilio error code.



686
687
688
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 686

def code
    @properties['code']
end

#contextKnowledgeContext

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

Returns:



635
636
637
638
639
640
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 635

def context
    unless @instance_context
        @instance_context = KnowledgeContext.new(@version , @params['kb_id'], @params['knowledge_id'])
    end
    @instance_context
end

#created_atTime

Returns The date and time in GMT when the Knowledge was created specified in ISO 8601 format.

Returns:

  • (Time)

    The date and time in GMT when the Knowledge was created specified in ISO 8601 format.



674
675
676
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 674

def created_at
    @properties['created_at']
end

#deleteBoolean

Delete the KnowledgeInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



705
706
707
708
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 705

def delete

    context.delete
end

#descriptionString

Returns A detailed description of the knowledge source and when to use it. This helps provide context about the content and its intended purpose.

Returns:

  • (String)

    A detailed description of the knowledge source and when to use it. This helps provide context about the content and its intended purpose.



650
651
652
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 650

def description
    @properties['description']
end

#fetchKnowledgeInstance

Fetch the KnowledgeInstance

Returns:



713
714
715
716
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 713

def fetch

    context.fetch
end

#idString

Returns The unique identifier of knowledge source.

Returns:

  • (String)

    The unique identifier of knowledge source.



662
663
664
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 662

def id
    @properties['id']
end

#inspectObject

Provide a detailed, user friendly representation



743
744
745
746
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 743

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

#messageString

Returns A human readable message describing the error.

Returns:

  • (String)

    A human readable message describing the error.



692
693
694
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 692

def message
    @properties['message']
end

#more_infoString

Returns A URL to a Twilio error directory page with more information about the error code.

Returns:



698
699
700
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 698

def more_info
    @properties['more_info']
end

#nameString

Returns The name of the knowledge source.

Returns:

  • (String)

    The name of the knowledge source.



644
645
646
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 644

def name
    @properties['name']
end

#sourceKnowledgeSourceTypes

Returns:

  • (KnowledgeSourceTypes)


656
657
658
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 656

def source
    @properties['source']
end

#statusString

Returns The status of processing the knowledge source ('SCHEDULED', 'QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED').

Returns:

  • (String)

    The status of processing the knowledge source ('SCHEDULED', 'QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED').



668
669
670
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 668

def status
    @properties['status']
end

#to_sObject

Provide a user friendly representation



736
737
738
739
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 736

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

#update(refresh: :unset, knowledge_core: :unset) ⇒ KnowledgeInstance

Update the KnowledgeInstance

Parameters:

  • refresh (Boolean) (defaults to: :unset)

    When true, re-queues processing for this knowledge resource. Idempotent while the resource is already QUEUED or PROCESSING.

  • knowledge_core (KnowledgeCore) (defaults to: :unset)

Returns:



723
724
725
726
727
728
729
730
731
732
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 723

def update(
  refresh: :unset,
  knowledge_core: :unset
)

    context.update(
        refresh: refresh, 
        knowledge_core: knowledge_core, 
    )
end

#updated_atTime

Returns The date and time in GMT when the Knowledge was last updated specified in ISO 8601 format.

Returns:

  • (Time)

    The date and time in GMT when the Knowledge was last updated specified in ISO 8601 format.



680
681
682
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 680

def updated_at
    @properties['updated_at']
end