Class: Apologist::AgentClient

Inherits:
Object
  • Object
show all
Defined in:
lib/Apologist/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, base_url: nil, domain: nil, max_retries: 2) ⇒ void

Parameters:

  • api_key (String)
  • base_url (String, nil) (defaults to: nil)
  • domain (String, nil) (defaults to: nil)
  • max_retries (Integer) (defaults to: 2)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/Apologist/client.rb', line 11

def initialize(api_key:, base_url: nil, domain: nil, max_retries: 2)
  unless domain.nil?
    domain_value = domain.nil? ? "your-agent-domain.com" : domain
    environment_url_templates = {
      Apologist::Environment::DEFAULT => "https://#{domain_value}/api/v1"
    }
    base_url = base_url.nil? ? "https://#{domain_value}/api/v1" : environment_url_templates.fetch(base_url, base_url)
  end

  @raw_client = Apologist::Internal::Http::RawClient.new(
    base_url: base_url || Apologist::Environment::DEFAULT,
    headers: {
      "User-Agent" => "apologist/0.0.5",
      "X-Fern-Language" => "Ruby",
      "x-api-key" => api_key.to_s
    },
    max_retries: max_retries
  )
end

Instance Method Details

#benchmarksApologist::Benchmarks::Client



57
58
59
# File 'lib/Apologist/client.rb', line 57

def benchmarks
  @benchmarks ||= Apologist::Benchmarks::Client.new(client: @raw_client)
end

#channelsApologist::Channels::Client



62
63
64
# File 'lib/Apologist/client.rb', line 62

def channels
  @channels ||= Apologist::Channels::Client.new(client: @raw_client)
end

#chatApologist::Chat::Client



32
33
34
# File 'lib/Apologist/client.rb', line 32

def chat
  @chat ||= Apologist::Chat::Client.new(client: @raw_client)
end

#corpusApologist::Corpus::Client



37
38
39
# File 'lib/Apologist/client.rb', line 37

def corpus
  @corpus ||= Apologist::Corpus::Client.new(client: @raw_client)
end

#ct_asApologist::CtAs::Client



47
48
49
# File 'lib/Apologist/client.rb', line 47

def ct_as
  @ct_as ||= Apologist::CtAs::Client.new(client: @raw_client)
end

#evaluatorsApologist::Evaluators::Client



42
43
44
# File 'lib/Apologist/client.rb', line 42

def evaluators
  @evaluators ||= Apologist::Evaluators::Client.new(client: @raw_client)
end

#sharesApologist::Shares::Client



67
68
69
# File 'lib/Apologist/client.rb', line 67

def shares
  @shares ||= Apologist::Shares::Client.new(client: @raw_client)
end

#usersApologist::Users::Client



52
53
54
# File 'lib/Apologist/client.rb', line 52

def users
  @users ||= Apologist::Users::Client.new(client: @raw_client)
end