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.



569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 569

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.



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

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:



597
598
599
600
601
602
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 597

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](en.wikipedia.org/wiki/ISO_8601) format.

Returns:



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

def created_at
    @properties['created_at']
end

#deleteBoolean

Delete the KnowledgeInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



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

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.



612
613
614
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 612

def description
    @properties['description']
end

#fetchKnowledgeInstance

Fetch the KnowledgeInstance

Returns:



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

def fetch

    context.fetch
end

#idString

Returns The unique identifier of knowledge source.

Returns:

  • (String)

    The unique identifier of knowledge source.



624
625
626
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 624

def id
    @properties['id']
end

#inspectObject

Provide a detailed, user friendly representation



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

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.



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

def message
    @properties['message']
end

#more_infoString

Returns A URL to a [Twilio error directory](www.twilio.com/docs/api/errors) page with more information about the error code.

Returns:



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

def more_info
    @properties['more_info']
end

#nameString

Returns The name of the knowledge source.

Returns:

  • (String)

    The name of the knowledge source.



606
607
608
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 606

def name
    @properties['name']
end

#sourceKnowledgeSourceTypes

Returns:

  • (KnowledgeSourceTypes)


618
619
620
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 618

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’).



630
631
632
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 630

def status
    @properties['status']
end

#to_sObject

Provide a user friendly representation



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

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:



685
686
687
688
689
690
691
692
693
694
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge.rb', line 685

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](en.wikipedia.org/wiki/ISO_8601) format.

Returns:



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

def updated_at
    @properties['updated_at']
end