Class: Twilio::REST::Knowledge::V2::SearchInstance

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, kb_id: nil) ⇒ SearchInstance

Initialize the SearchInstance

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

  • sid (String)

    The SID of the Call resource to fetch.



293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'lib/twilio-ruby/rest/knowledge/v2/search.rb', line 293

def initialize(version, payload , kb_id: nil)
    
    apiV1Version = ApiV1Version.new version.domain, version
    super(apiV1Version)
    
    # Marshaled Properties
    @properties = { 
        'chunks' => payload['chunks'],
    }

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

Instance Method Details

#chunksArray<KnowledgeChunkResult>

Returns:

  • (Array<KnowledgeChunkResult>)


321
322
323
# File 'lib/twilio-ruby/rest/knowledge/v2/search.rb', line 321

def chunks
    @properties['chunks']
end

#contextSearchContext

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

Returns:



312
313
314
315
316
317
# File 'lib/twilio-ruby/rest/knowledge/v2/search.rb', line 312

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

#create(knowledge_search: :unset) ⇒ SearchInstance

Create the SearchInstance

Parameters:

  • knowledge_search (KnowledgeSearch) (defaults to: :unset)

Returns:



329
330
331
332
333
334
335
# File 'lib/twilio-ruby/rest/knowledge/v2/search.rb', line 329

def create(knowledge_search: :unset
)

    context.create(
        knowledge_search: knowledge_search, 
    )
end

#inspectObject

Provide a detailed, user friendly representation



346
347
348
349
# File 'lib/twilio-ruby/rest/knowledge/v2/search.rb', line 346

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

#to_sObject

Provide a user friendly representation



339
340
341
342
# File 'lib/twilio-ruby/rest/knowledge/v2/search.rb', line 339

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