Class: ThreeScaleToolbox::ThreeScaleClientFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/3scale_toolbox/3scale_client_factory.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(remotes, remote_str, verify_ssl, verbose) ⇒ ThreeScaleClientFactory

Returns a new instance of ThreeScaleClientFactory.



11
12
13
14
15
16
# File 'lib/3scale_toolbox/3scale_client_factory.rb', line 11

def initialize(remotes, remote_str, verify_ssl, verbose)
  @remotes = remotes
  @remote_str = remote_str
  @verify_ssl = verify_ssl
  @verbose = verbose
end

Instance Attribute Details

#remote_strObject (readonly)

Returns the value of attribute remote_str.



9
10
11
# File 'lib/3scale_toolbox/3scale_client_factory.rb', line 9

def remote_str
  @remote_str
end

#remotesObject (readonly)

Returns the value of attribute remotes.



9
10
11
# File 'lib/3scale_toolbox/3scale_client_factory.rb', line 9

def remotes
  @remotes
end

#verboseObject (readonly)

Returns the value of attribute verbose.



9
10
11
# File 'lib/3scale_toolbox/3scale_client_factory.rb', line 9

def verbose
  @verbose
end

#verify_sslObject (readonly)

Returns the value of attribute verify_ssl.



9
10
11
# File 'lib/3scale_toolbox/3scale_client_factory.rb', line 9

def verify_ssl
  @verify_ssl
end

Class Method Details

.get(remotes, remote_str, verify_ssl, verbose = false) ⇒ Object



4
5
6
# File 'lib/3scale_toolbox/3scale_client_factory.rb', line 4

def get(remotes, remote_str, verify_ssl, verbose = false)
  new(remotes, remote_str, verify_ssl, verbose).call
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/3scale_toolbox/3scale_client_factory.rb', line 18

def call
  begin
    remote = Remotes.from_uri(remote_str)
  rescue InvalidUrlError
    remote = remotes.fetch(remote_str)
  end

  client = remote_client(**remote.merge(verify_ssl: verify_ssl))
  client = ProxyLogger.new(client) if verbose
  RemoteCache.new(client)
end