Class: Twilio::REST::Knowledge::V2::KnowledgeBasisContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/knowledge/v2/knowledge_basis.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, kb_id) ⇒ KnowledgeBasisContext

Initialize the KnowledgeBasisContext

Parameters:

  • version (Version)

    Version that contains the resource

  • kb_id (String)

    A unique Knowledge Base ID using Twilio Type ID (TTID) format



292
293
294
295
296
297
298
299
300
301
302
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge_basis.rb', line 292

def initialize(version, kb_id)
    
    apiV1Version = ApiV1Version.new version.domain, version
    super(apiV1Version)

    # Path Solution
    @solution = { kb_id: kb_id,  }
    @uri = "/ControlPlane/KnowledgeBases/#{@solution[:kb_id]}"

    
end

Instance Method Details

#deleteBoolean

Delete the KnowledgeBasisInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge_basis.rb', line 306

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    response = @version.('DELETE', @uri, headers: headers)
    KnowledgeBasisInstance.new(
      @version,
      response.body,
        kb_id: @solution[:kb_id],
    )
    
end

#delete_with_metadataBoolean

Delete the KnowledgeBasisInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge_basis.rb', line 324

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      knowledgeBasis_instance = KnowledgeBasisInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      KnowledgeBasisInstanceMetadata.new(@version, knowledgeBasis_instance, response.headers, response.status_code)
end

#fetchKnowledgeBasisInstance

Fetch the KnowledgeBasisInstance

Returns:



343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge_basis.rb', line 343

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    KnowledgeBasisInstance.new(
        @version,
        payload,
        kb_id: @solution[:kb_id],
    )
end

#fetch_with_metadataKnowledgeBasisInstance

Fetch the KnowledgeBasisInstanceMetadata

Returns:



362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge_basis.rb', line 362

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    knowledge_basis_instance = KnowledgeBasisInstance.new(
        @version,
        response.body,
        kb_id: @solution[:kb_id],
    )
    KnowledgeBasisInstanceMetadata.new(
        @version,
        knowledge_basis_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



448
449
450
451
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge_basis.rb', line 448

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Knowledge.V2.KnowledgeBasisContext #{context}>"
end

#to_sObject

Provide a user friendly representation



441
442
443
444
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge_basis.rb', line 441

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Knowledge.V2.KnowledgeBasisContext #{context}>"
end

#update(if_match: :unset, update_knowledge_base_request: nil) ⇒ KnowledgeBasisInstance

Update the KnowledgeBasisInstance

Parameters:

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

    Allows for optimistic concurrency control by making the request conditional. Server will only act if the resource’s current Entity Tag (ETag) matches the one provided, preventing accidental overwrites.

  • update_knowledge_base_request (UpdateKnowledgeBaseRequest) (defaults to: nil)

Returns:



389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge_basis.rb', line 389

def update(
  if_match: :unset,
  update_knowledge_base_request: nil
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    payload = @version.update('PATCH', @uri, headers: headers, data: update_knowledge_base_request.to_json)
    KnowledgeBasisInstance.new(
        @version,
        payload,
        kb_id: @solution[:kb_id],
    )
end

#update_with_metadata(if_match: :unset, update_knowledge_base_request: nil) ⇒ KnowledgeBasisInstance

Update the KnowledgeBasisInstanceMetadata

Parameters:

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

    Allows for optimistic concurrency control by making the request conditional. Server will only act if the resource’s current Entity Tag (ETag) matches the one provided, preventing accidental overwrites.

  • update_knowledge_base_request (UpdateKnowledgeBaseRequest) (defaults to: nil)

Returns:



413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/twilio-ruby/rest/knowledge/v2/knowledge_basis.rb', line 413

def (
  if_match: :unset,
update_knowledge_base_request: nil
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    response = @version.('PATCH', @uri, headers: headers, data: update_knowledge_base_request.to_json)
    knowledge_basis_instance = KnowledgeBasisInstance.new(
        @version,
        response.body,
        kb_id: @solution[:kb_id],
    )
    KnowledgeBasisInstanceMetadata.new(
        @version,
        knowledge_basis_instance,
        response.headers,
        response.status_code
    )
end