Class: AnswerLayer::Client

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

Constant Summary collapse

DEFAULT_BASE_URL =
Configuration::DEFAULT_BASE_URL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil, bearer_token: nil, subject_org_id: nil, subject_user_id: nil, base_url: DEFAULT_BASE_URL, open_timeout: 10, read_timeout: 30, configuration: nil) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/answerlayer/client.rb', line 9

def initialize(api_key: nil, bearer_token: nil, subject_org_id: nil, subject_user_id: nil, base_url: DEFAULT_BASE_URL, open_timeout: 10, read_timeout: 30, configuration: nil)
  @configuration = configuration || Configuration.new(
    api_key: api_key,
    bearer_token: bearer_token,
    subject_org_id: subject_org_id,
    subject_user_id: subject_user_id,
    base_url: base_url,
    open_timeout: open_timeout,
    read_timeout: read_timeout
  )
  @request = Request.new(configuration: @configuration)
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



7
8
9
# File 'lib/answerlayer/client.rb', line 7

def configuration
  @configuration
end

Instance Method Details

#connectionsObject



34
35
36
# File 'lib/answerlayer/client.rb', line 34

def connections
  @connections ||= ConnectionsResource.new(self)
end

#dashboardsObject



50
51
52
# File 'lib/answerlayer/client.rb', line 50

def dashboards
  @dashboards ||= DashboardsResource.new(self)
end

#get(path, params: nil) ⇒ Object



22
23
24
# File 'lib/answerlayer/client.rb', line 22

def get(path, params: nil)
  request(method: :get, path: path, params: params)
end

#identity_brokerObject



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

def identity_broker
  @identity_broker ||= IdentityBrokerResource.new(self)
end

#inquiryObject



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

def inquiry
  @inquiry ||= InquiryResource.new(self)
end

#post(path, body: nil) ⇒ Object



26
27
28
# File 'lib/answerlayer/client.rb', line 26

def post(path, body: nil)
  request(method: :post, path: path, body: body)
end

#queryObject



38
39
40
# File 'lib/answerlayer/client.rb', line 38

def query
  @query ||= QueryResource.new(self)
end

#query_resultsObject



54
55
56
# File 'lib/answerlayer/client.rb', line 54

def query_results
  @query_results ||= QueryResultsResource.new(self)
end

#request(method:, path:, params: nil, body: nil, headers: {}, auth: :api_key, subject: false, form: nil, multipart: nil, download: false) ⇒ Object



30
31
32
# File 'lib/answerlayer/client.rb', line 30

def request(method:, path:, params: nil, body: nil, headers: {}, auth: :api_key, subject: false, form: nil, multipart: nil, download: false)
  @request.call(method: method, path: path, params: params, body: body, headers: headers, auth: auth, subject: subject, form: form, multipart: multipart, download: download)
end

#saved_queriesObject



46
47
48
# File 'lib/answerlayer/client.rb', line 46

def saved_queries
  @saved_queries ||= SavedQueriesResource.new(self)
end

#semanticObject



58
59
60
# File 'lib/answerlayer/client.rb', line 58

def semantic
  @semantic ||= SemanticResource.new(self)
end