Class: AnswerLayer::Client
- Inherits:
-
Object
- Object
- AnswerLayer::Client
- Defined in:
- lib/answerlayer/client.rb
Constant Summary collapse
- DEFAULT_BASE_URL =
Configuration::DEFAULT_BASE_URL
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
- #connections ⇒ Object
- #dashboards ⇒ Object
- #get(path, params: nil) ⇒ Object
- #identity_broker ⇒ Object
-
#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
constructor
A new instance of Client.
- #inquiry ⇒ Object
- #post(path, body: nil) ⇒ Object
- #query ⇒ Object
- #query_results ⇒ Object
- #request(method:, path:, params: nil, body: nil, headers: {}, auth: :api_key, subject: false, form: nil, multipart: nil, download: false) ⇒ Object
- #saved_queries ⇒ Object
- #semantic ⇒ Object
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
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
7 8 9 |
# File 'lib/answerlayer/client.rb', line 7 def configuration @configuration end |
Instance Method Details
#connections ⇒ Object
34 35 36 |
# File 'lib/answerlayer/client.rb', line 34 def connections @connections ||= ConnectionsResource.new(self) end |
#dashboards ⇒ Object
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_broker ⇒ Object
62 63 64 |
# File 'lib/answerlayer/client.rb', line 62 def identity_broker @identity_broker ||= IdentityBrokerResource.new(self) end |
#inquiry ⇒ Object
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 |
#query ⇒ Object
38 39 40 |
# File 'lib/answerlayer/client.rb', line 38 def query @query ||= QueryResource.new(self) end |
#query_results ⇒ Object
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_queries ⇒ Object
46 47 48 |
# File 'lib/answerlayer/client.rb', line 46 def saved_queries @saved_queries ||= SavedQueriesResource.new(self) end |
#semantic ⇒ Object
58 59 60 |
# File 'lib/answerlayer/client.rb', line 58 def semantic @semantic ||= SemanticResource.new(self) end |