Class: ModelsLab::Client

Inherits:
Object
  • Object
show all
Includes:
HTTP
Defined in:
lib/modelslab/client.rb

Constant Summary collapse

CONFIG_KEYS =
%i[api_key uri_base request_timeout extra_headers].freeze

Instance Method Summary collapse

Methods included from HTTP

#connection, #json_post

Constructor Details

#initialize(config = {}, &faraday_middleware) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
16
17
18
# File 'lib/modelslab/client.rb', line 10

def initialize(config = {}, &faraday_middleware)
  CONFIG_KEYS.each do |key|
    instance_variable_set(
      "@#{key}",
      config[key].nil? ? ModelsLab.configuration.send(key) : config[key]
    )
  end
  @faraday_middleware = faraday_middleware
end

Instance Method Details

#enterpriseObject



24
25
26
# File 'lib/modelslab/client.rb', line 24

def enterprise
  @enterprise ||= Enterprise.new(client: self)
end

#imagesObject



20
21
22
# File 'lib/modelslab/client.rb', line 20

def images
  @images ||= ModelsLab::Images.new(client: self)
end