Sha256: 32170cd6d98b337058040f0f22951275330821ca85db6ea8a3e608bd1d21b90e

Contents?: true

Size: 947 Bytes

Versions: 13

Compression:

Stored size: 947 Bytes

Contents

module ThreeScaleToolbox
  class ThreeScaleClientFactory
    class << self
      def get(remotes, remote_str, verify_ssl, verbose = false)
        new(remotes, remote_str, verify_ssl, verbose).call
      end
    end

    attr_reader :remotes, :remote_str, :verify_ssl, :verbose

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

    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))
      return ProxyLogger.new(client) if verbose

      client
    end

    private

    def remote_client(endpoint:, authentication:, verify_ssl:)
      ThreeScale::API.new(endpoint: endpoint, provider_key: authentication, verify_ssl: verify_ssl)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
3scale_toolbox-0.17.1 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.17.0 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.16.0 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.15.0 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.14.0 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.13.0 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.12.4 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.12.3 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.12.2 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.11.0 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.10.0 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.9.0 lib/3scale_toolbox/3scale_client_factory.rb
3scale_toolbox-0.8.0 lib/3scale_toolbox/3scale_client_factory.rb