Class: VoiceML::AssistantsV1AssistantsResource

Inherits:
Object
  • Object
show all
Defined in:
lib/voiceml/resources/assistants_v1.rb

Overview

============================================================================

/v1/Assistants — 5 CRUD ops on the top-level Assistant resource. Fetch returns the AssistantWithToolsAndKnowledge shape (tools + knowledge inline).

Constant Summary collapse

CREATE_FIELDS =
%i[name owner personality_prompt model customer_ai segment_credential].freeze
UPDATE_FIELDS =
%i[name owner personality_prompt model customer_ai segment_credential].freeze

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ AssistantsV1AssistantsResource

Returns a new instance of AssistantsV1AssistantsResource.



69
70
71
# File 'lib/voiceml/resources/assistants_v1.rb', line 69

def initialize(transport)
  @transport = transport
end

Instance Method Details

#create(name:, **kwargs) ⇒ Object



81
82
83
84
85
86
# File 'lib/voiceml/resources/assistants_v1.rb', line 81

def create(name:, **kwargs)
  kwargs[:name] = name
  AssistantsV1Assistant.from_hash(
    @transport.request(:post, '/v1/Assistants', json: build_json(CREATE_FIELDS, kwargs))
  )
end

#delete(id) ⇒ Object



100
101
102
103
# File 'lib/voiceml/resources/assistants_v1.rb', line 100

def delete(id)
  @transport.request(:delete, "/v1/Assistants/#{id}")
  nil
end

#fetch(id) ⇒ Object



88
89
90
91
92
# File 'lib/voiceml/resources/assistants_v1.rb', line 88

def fetch(id)
  AssistantsV1AssistantWithToolsAndKnowledge.from_hash(
    @transport.request(:get, "/v1/Assistants/#{id}")
  )
end

#list(page_size: nil, page: nil, page_token: nil) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/voiceml/resources/assistants_v1.rb', line 73

def list(page_size: nil, page: nil, page_token: nil)
  params = {}
  params['PageSize']  = page_size  unless page_size.nil?
  params['Page']      = page       unless page.nil?
  params['PageToken'] = page_token unless page_token.nil?
  AssistantsV1AssistantList.new(@transport.request(:get, '/v1/Assistants', params: params))
end

#update(id, **kwargs) ⇒ Object



94
95
96
97
98
# File 'lib/voiceml/resources/assistants_v1.rb', line 94

def update(id, **kwargs)
  AssistantsV1Assistant.from_hash(
    @transport.request(:put, "/v1/Assistants/#{id}", json: build_json(UPDATE_FIELDS, kwargs))
  )
end